Caffe2 - C++ API
A deep learning, cross platform ML framework
shape_op.h
1 
2 #pragma once
3 
4 #include "caffe2/core/context.h"
5 #include "caffe2/core/operator.h"
6 
7 namespace caffe2 {
8 
9 // RecordShapeOp records the shape of the input tensor to a vector of int. You
10 // mostly don't need this operator explicitly, and it is mostly used in the
11 // autodiff process.
12 template <class Context>
13 class ShapeOp : public Operator<Context> {
14  public:
15  USE_OPERATOR_CONTEXT_FUNCTIONS;
16  USE_SIMPLE_CTOR_DTOR(ShapeOp);
17 
18  bool RunOnDevice() override {
19  auto& input = Input(0);
20  auto* output = OperatorBase::Output<Tensor<Context>>(0);
21  output->Resize(input.ndim());
22  TIndex* output_data = output->template mutable_data<TIndex>();
23  context_.template CopyBytes<Context, Context>(
24  input.ndim() * sizeof(TIndex), input.dims().data(), output_data);
25  return true;
26  }
27 };
28 
29 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...