1 #include <caffe2/ideep/ideep_utils.h> 7 USE_IDEEP_DEF_ALIASES();
8 USE_IDEEP_OPERATOR_FUNCTIONS();
13 if (operator_def.type().substr(0, 4) ==
"Relu") {
15 }
else if (operator_def.type().substr(0, 9) ==
"LeakyRelu") {
17 alpha_ =
static_cast<float>(
18 OperatorBase::GetSingleArgument<float>(
"alpha", 0.01));
21 LOG(FATAL) <<
"Unsupported Relu method: " << operator_def.type();
26 bool RunOnDevice()
override {
27 const auto& X = Input(INPUT);
28 auto* Y = Output(OUTPUT);
30 ideep::eltwise_forward::compute(
31 X, *Y, ialgo::eltwise_relu, iprop::forward_training, alpha_);
45 USE_IDEEP_DEF_ALIASES();
46 USE_IDEEP_OPERATOR_FUNCTIONS();
51 if (operator_def.type().substr(0, 12) ==
"ReluGradient") {
53 }
else if (operator_def.type().substr(0, 17) ==
"LeakyReluGradient") {
55 alpha_ =
static_cast<float>(
56 OperatorBase::GetSingleArgument<float>(
"alpha", 0.01));
59 LOG(FATAL) <<
"Unsupported Relu method: " << operator_def.type();
64 bool RunOnDevice()
override {
65 const auto& Y = Input(OUTPUT);
66 const auto& dY = Input(OUTPUT_GRAD);
67 auto* dX = Output(INPUT_GRAD);
69 ideep::eltwise_backward::compute(Y, dY, *dX, ialgo::eltwise_relu, alpha_);
77 INPUT_TAGS(OUTPUT, OUTPUT_GRAD);
78 OUTPUT_TAGS(INPUT_GRAD);
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 ...
bool HasArgument(const string &name) const
Checks if the operator has an argument of the given name.