From 04be406d80a515b836c6aca311b7015132ecb0c8 Mon Sep 17 00:00:00 2001 From: liangchenghui Date: Mon, 19 Oct 2020 22:01:18 +0800 Subject: [PATCH] Add Softplus,SoftplusGrad for old backend.. --- mindspore/ccsrc/transform/graph_ir/op_adapter_map.h | 2 ++ .../graph_ir/op_declare/nonlinear_fuc_ops_declare.cc | 12 ++++++++++++ .../graph_ir/op_declare/nonlinear_fuc_ops_declare.h | 8 +++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/transform/graph_ir/op_adapter_map.h b/mindspore/ccsrc/transform/graph_ir/op_adapter_map.h index a98a7a00056c..411774f0866f 100644 --- a/mindspore/ccsrc/transform/graph_ir/op_adapter_map.h +++ b/mindspore/ccsrc/transform/graph_ir/op_adapter_map.h @@ -78,6 +78,8 @@ constexpr const char kNameApplyAdam[] = "Adam"; constexpr const char kNameExtractImagePatches[] = "ExtractImagePatches"; constexpr const char kNameReLU6[] = "ReLU6"; constexpr const char kNameReLU6Grad[] = "ReLU6Grad"; +constexpr const char kNameSoftplus[] = "Softplus"; +constexpr const char kNameSoftplusGrad[] = "SoftplusGrad"; constexpr const char kNameElu[] = "Elu"; constexpr const char kNameEluGrad[] = "EluGrad"; constexpr const char kNameTensorScatterUpdate[] = "TensorScatterUpdate"; diff --git a/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.cc b/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.cc index 1273bf765632..01904536d3df 100644 --- a/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.cc +++ b/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.cc @@ -71,6 +71,18 @@ ATTR_MAP(Relu6Grad) = EMPTY_ATTR_MAP; OUTPUT_MAP(Relu6Grad) = {{0, OUTPUT_DESC(backprops)}}; REG_ADPT_DESC(Relu6Grad, kNameReLU6Grad, ADPT_DESC(Relu6Grad)) +// Softplus +INPUT_MAP(Softplus) = {{1, INPUT_DESC(x)}}; +ATTR_MAP(Softplus) = EMPTY_ATTR_MAP; +OUTPUT_MAP(Softplus) = {{0, OUTPUT_DESC(y)}}; +REG_ADPT_DESC(Softplus, kNameSoftplus, ADPT_DESC(Softplus)) + +// SoftplusGrad +INPUT_MAP(SoftplusGrad) = {{1, INPUT_DESC(gradients)}, {2, INPUT_DESC(features)}}; +ATTR_MAP(SoftplusGrad) = EMPTY_ATTR_MAP; +OUTPUT_MAP(SoftplusGrad) = {{0, OUTPUT_DESC(backprops)}}; +REG_ADPT_DESC(SoftplusGrad, kNameSoftplusGrad, ADPT_DESC(SoftplusGrad)) + // ReluGrad INPUT_MAP(ReluGrad) = {{1, INPUT_DESC(gradients)}, {2, INPUT_DESC(features)}}; ATTR_MAP(ReluGrad) = EMPTY_ATTR_MAP; diff --git a/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.h b/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.h index 71b81f450b2a..bcd2d12c77c6 100644 --- a/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.h +++ b/mindspore/ccsrc/transform/graph_ir/op_declare/nonlinear_fuc_ops_declare.h @@ -19,8 +19,8 @@ #include #include -#include "transform/graph_ir/op_declare/op_declare_macro.h" #include "ops/nonlinear_fuc_ops.h" +#include "transform/graph_ir/op_declare/op_declare_macro.h" namespace mindspore::transform { DECLARE_OP_ADAPTER(ReluGrad) @@ -32,6 +32,12 @@ DECLARE_OP_USE_OUTPUT(Relu6) DECLARE_OP_ADAPTER(Relu6Grad) DECLARE_OP_USE_OUTPUT(Relu6Grad) +DECLARE_OP_ADAPTER(Softplus) +DECLARE_OP_USE_OUTPUT(Softplus) + +DECLARE_OP_ADAPTER(SoftplusGrad) +DECLARE_OP_USE_OUTPUT(SoftplusGrad) + DECLARE_OP_ADAPTER(Tanh) DECLARE_OP_USE_OUTPUT(Tanh) -- Gitee