1 #include <caffe2/ideep/ideep_utils.h> 10 USE_IDEEP_DEF_ALIASES();
11 USE_IDEEP_OPERATOR_FUNCTIONS();
15 axes_(OperatorBase ::GetRepeatedArgument<int>(
"axes")) {}
17 bool RunOnDevice()
override {
19 int numAxes = axes_.size();
21 const char* data_dims =
nullptr;
22 auto* output = OperatorBase::Output<Tensor>(OUTPUT, CPU);
24 if (OperatorBase::InputBlob(DATA).template IsType<itensor>()) {
25 auto& data = Input(DATA);
26 numDims = data.ndims();
27 auto idims = data.get_dims();
28 dims.assign(idims.begin(), idims.end());
29 data_dims =
reinterpret_cast<const char*
>(dims.data());
31 auto& data = OperatorBase::Input<Tensor>(DATA, CPU);
33 data_dims =
reinterpret_cast<const char*
>(data.sizes().data());
37 output->Resize(numDims);
38 int64_t* output_data = output->template mutable_data<int64_t>();
39 context_.CopyBytesSameDevice(
40 numDims *
sizeof(int64_t), data_dims, output_data);
44 output->Resize(numAxes);
45 auto out =
reinterpret_cast<char*
>(output->template mutable_data<int64_t>());
46 for (
int i = 0; i < numAxes; i++) {
48 CAFFE_ENFORCE_LT(axis, numDims,
"Axis out of range");
49 CAFFE_ENFORCE_GE(axis, 0,
"Each axis should be non-negative");
50 context_.CopyBytesSameDevice(
51 sizeof(int64_t), data_dims + axis *
sizeof(int64_t), out);
52 out +=
sizeof(int64_t);
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...