Caffe2 - C++ API
A deep learning, cross platform ML framework
batch_sparse_to_dense_op.h
1 // Copyright 2004-present Facebook. All Rights Reserved.
2 
3 #ifndef CAFFE2_OPERATORS_BATCH_SPARSE_TO_DENSE_OP_H_
4 #define CAFFE2_OPERATORS_BATCH_SPARSE_TO_DENSE_OP_H_
5 
6 #include "caffe2/core/context.h"
7 #include "caffe2/core/operator.h"
8 #include "caffe2/utils/math.h"
9 
10 namespace caffe2 {
11 
12 template <typename T, class Context>
13 class BatchSparseToDenseOp : public Operator<Context> {
14  public:
15  USE_OPERATOR_CONTEXT_FUNCTIONS;
16  BatchSparseToDenseOp(const OperatorDef& operator_def, Workspace* ws)
17  : Operator<Context>(operator_def, ws),
18  OP_SINGLE_ARG(TIndex, "dense_last_dim", dense_last_dim_, -1),
19  OP_SINGLE_ARG(T, "default_value", default_value_, static_cast<T>(0)) {}
20  bool RunOnDevice() override;
21 
22  private:
23  TIndex dense_last_dim_;
24  T default_value_;
25  INPUT_TAGS(LENGTHS, INDICES, VALUES);
26 };
27 
28 template <typename T, class Context>
29 class BatchDenseToSparseOp : public Operator<Context> {
30  public:
31  USE_OPERATOR_CONTEXT_FUNCTIONS;
32  BatchDenseToSparseOp(const OperatorDef& operator_def, Workspace* ws)
33  : Operator<Context>(operator_def, ws) {}
34  bool RunOnDevice() override;
35 
36  private:
37  TIndex dense_last_dim_;
38  INPUT_TAGS(LENGTHS, INDICES, DENSE);
39 };
40 
41 } // namespace caffe2
42 
43 #endif // CAFFE2_OPERATORS_BATCH_SPARSE_TO_DENSE_OP_H_
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
Definition: workspace.h:47
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...