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  template <class... Args>
17  explicit BatchSparseToDenseOp(Args&&... args)
18  : Operator<Context>(std::forward<Args>(args)...),
19  OP_SINGLE_ARG(int64_t, "dense_last_dim", dense_last_dim_, -1),
20  OP_SINGLE_ARG(T, "default_value", default_value_, static_cast<T>(0)) {}
21  bool RunOnDevice() override;
22 
23  private:
24  int64_t dense_last_dim_;
25  T default_value_;
26  INPUT_TAGS(LENGTHS, INDICES, VALUES);
27 };
28 
29 template <typename T, class Context>
30 class BatchDenseToSparseOp : public Operator<Context> {
31  public:
32  USE_OPERATOR_CONTEXT_FUNCTIONS;
33  template <class... Args>
34  explicit BatchDenseToSparseOp(Args&&... args)
35  : Operator<Context>(std::forward<Args>(args)...) {}
36  bool RunOnDevice() override;
37 
38  private:
39  int64_t dense_last_dim_;
40  INPUT_TAGS(LENGTHS, INDICES, DENSE);
41 };
42 
43 } // namespace caffe2
44 
45 #endif // CAFFE2_OPERATORS_BATCH_SPARSE_TO_DENSE_OP_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13