Caffe2 - C++ API
A deep learning, cross platform ML framework
index_hash_ops.cc
1 #include "caffe2/operators/index_hash_ops.h"
2 
3 namespace caffe2 {
4 namespace {
5 
6 REGISTER_CPU_OPERATOR(IndexHash, IndexHashOp<CPUContext>);
7 
8 OPERATOR_SCHEMA(IndexHash)
9  .NumInputs(1)
10  .NumOutputs(1)
11  .SetDoc(R"DOC(
12 This operator translates a list of indices into a list of hashed indices.
13 A seed can be fed as an argument to change the behavior of the hash function.
14 If a modulo is specified, all the hashed indices will be modulo the
15 specified number. All input and output indices are enforced to be positive.
16 )DOC")
17  .Input(0, "Indices", "Input feature indices.")
18  .Output(0, "HashedIndices", "Hashed feature indices.")
19  .Arg("seed", "seed for the hash function")
20  .Arg("modulo", "must be > 0, hashed ids will be modulo this number")
21  .TensorInferenceFunction([](const OperatorDef& /* unused */,
22  const vector<TensorShape>& in) {
23  std::vector<TensorShape> out(1);
24  std::vector<int64_t> output_dims = GetDimsVector(in[0]);
25  out[0] = CreateTensorShape(output_dims, in[0].data_type());
26  return out;
27  });
28 
29 SHOULD_NOT_DO_GRADIENT(IndexHash);
30 
31 } // namespace
32 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13