Caffe2 - C++ API
A deep learning, cross platform ML framework
ensure_cpu_output_op.cc
1 #include "caffe2/operators/ensure_cpu_output_op.h"
2 
3 namespace caffe2 {
4 
5 // From CPU Context, the op takes CPU tensor as input, and produces
6 // TensorCPU
7 REGISTER_CPU_OPERATOR(EnsureCPUOutput, EnsureCPUOutputOp<CPUContext>);
8 
9 OPERATOR_SCHEMA(EnsureCPUOutput)
10  .NumInputs(1)
11  .NumOutputs(1)
12  .IdenticalTypeAndShape()
13  .InputsCanCrossDevices()
14  .DeviceInferenceFunction([](const OperatorDef& def) {
15  auto op_device =
16  def.has_device_option() ? def.device_option() : DeviceOption();
17  auto cpu_option = DeviceOption();
18  vector<DeviceOption> in_dev(def.input_size(), op_device);
19  vector<DeviceOption> out_dev(def.output_size(), cpu_option);
20  return std::make_pair(in_dev, out_dev);
21  })
22  .SetDoc(R"DOC(
23 This Op always create TensorCPU output, and may involves cross-device MemCpy.
24 Under CPU Context, this Op takes TensorCPU as input. Under the CUDA Context,
25 this Op accepts either CUDA or CPU Tensor input.
26 )DOC")
27  .Input(0, "input", "The input CUDA or CPU tensor.")
28  .Output(0, "output", "TensorCPU that is a copy of the input.");
29 
30 NO_GRADIENT(EnsureCPUOutput);
31 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13