1 #include "caffe2/operators/ensure_cpu_output_op.h" 7 REGISTER_CPU_OPERATOR(EnsureCPUOutput, EnsureCPUOutputOp<CPUContext>);
9 OPERATOR_SCHEMA(EnsureCPUOutput)
12 .IdenticalTypeAndShape()
13 .InputsCanCrossDevices()
14 .DeviceInferenceFunction([](
const OperatorDef& def) {
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);
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. 27 .Input(0, "input",
"The input CUDA or CPU tensor.")
28 .Output(0,
"output",
"TensorCPU that is a copy of the input.");
30 NO_GRADIENT(EnsureCPUOutput);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...