2 #include "caffe2/core/operator.h"     3 #include "caffe2/core/stats.h"     4 #include "caffe2/core/tensor.h"     5 #include "caffe2/core/types.h"    13         given_name_(GetSingleArgument<std::string>(
    15             operator_def.input().Get(0))),
    16         magnitude_expand_(GetSingleArgument<int64_t>(
"magnitude_expand", 1)),
    17         bound_(GetSingleArgument<bool>(
"bound", 
false)),
    18         has_default_(HasSingleArgumentOfType<float>(
"default_value")),
    19         default_value_(GetSingleArgument<float>(
"default_value", 0.0)),
    22   bool RunOnDevice()
 override {
    32         double>>::call(
this, 
Input(0));
    36   bool DoRunWithType() {
    37     V input = default_value_;
    40     if (
Input(0).
template data<V>()) {
    41       input = *
Input(0).template data<V>();
    42     } 
else if (!has_default_) {
    44           "Default value must be provided when recieving empty tensors for ",
    49         std::numeric_limits<int64_t>::max() / magnitude_expand_;
    55       } 
else if (input <= -bound_value) {
    56         int_value = std::numeric_limits<int64_t>::min();
    57       } 
else if (input >= bound_value) {
    58         int_value = std::numeric_limits<int64_t>::max();
    60         int_value = input * magnitude_expand_;
    64           std::abs(static_cast<int64_t>(input)) < bound_value,
    65           "Input value is too large for the given magnitude expansion!");
    66       CAFFE_ENFORCE(!isNan(input), 
"Input value cannot be NaN!");
    67       int_value = input * magnitude_expand_;
    70     CAFFE_EVENT(stat_, stat_value, int_value);
    76   const std::string given_name_;
    77   const int64_t magnitude_expand_;
    79   const bool has_default_;
    80   const float default_value_;
    92     return input != input;
 
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
 
const Tensor & Input(int idx, DeviceType type=CPUContext::GetDeviceType())
Retrieve a non-owning reference to the input at position 'idx' for this operator. ...
 
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...