From 677fbe79170a3ffad6fb2efcd120d43e3c2552c2 Mon Sep 17 00:00:00 2001 From: yangfei Date: Wed, 31 Oct 2018 18:02:09 +0800 Subject: [PATCH] repair bug of softmax and conv_add_relu op --- src/operators/fusion_conv_add_relu_op.h | 5 ++--- src/operators/math/softmax.cpp | 23 +++++++++++++++------- tools/android-debug-script/push2android.sh | 12 +++++++---- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/operators/fusion_conv_add_relu_op.h b/src/operators/fusion_conv_add_relu_op.h index 1335ce7b6c..d70de45337 100644 --- a/src/operators/fusion_conv_add_relu_op.h +++ b/src/operators/fusion_conv_add_relu_op.h @@ -29,9 +29,8 @@ namespace operators { class FusionConvAddReluOpMatcher : public framework::FusionOpMatcher { public: FusionConvAddReluOpMatcher() { - node_ = framework::Node(G_OP_TYPE_CONV); - node_ > std::make_shared(G_OP_TYPE_ELEMENTWISE_ADD) > - std::make_shared(G_OP_TYPE_RELU); + node_ = framework::Node(G_OP_TYPE_FUSION_CONV_ADD); + node_ > std::make_shared(G_OP_TYPE_RELU); } void FolderNodes( diff --git a/src/operators/math/softmax.cpp b/src/operators/math/softmax.cpp index dba88c9396..2ab9953d73 100644 --- a/src/operators/math/softmax.cpp +++ b/src/operators/math/softmax.cpp @@ -140,15 +140,24 @@ class SoftmaxFuntor { public: void operator()(const framework::Tensor *X, framework::Tensor *Y) { - const DDim dDim = X->dims(); - for (int i = 0; i < dDim[0]; ++i) { - framework::Tensor sub_X = X->Slice(i, i + 1); - framework::Tensor sub_Y = Y->Slice(i, i + 1); - + const DDim dDim = X->dims(); + int dim1 = dDim[dDim.size()-1]; + int dim0 = X->numel()/dim1/dDim[0]; + framework::DDim matrix_shape = {dim0,dim1}; + for (int i = 0; i < dDim[0]; ++i) { + framework::Tensor sub_X = X->Slice(i, i + 1); + framework::Tensor sub_Y = Y->Slice(i, i + 1); + sub_X.Resize(matrix_shape); + sub_Y.Resize(matrix_shape); + for(int j=0;j