提交 cb44f357 编写于 作者: E eclipsess

format

上级 9942f5ba
...@@ -60,8 +60,7 @@ std::unordered_map< ...@@ -60,8 +60,7 @@ std::unordered_map<
{G_OP_TYPE_TRANSPOSE, {{"X"}, {"Out"}}}, {G_OP_TYPE_TRANSPOSE, {{"X"}, {"Out"}}},
{G_OP_TYPE_BOX_CODER, {G_OP_TYPE_BOX_CODER,
{{"PriorBox", "PriorBoxVar", "TargetBox"}, {"OutputBox"}}}, {{"PriorBox", "PriorBoxVar", "TargetBox"}, {"OutputBox"}}},
{G_OP_TYPE_FUSION_CONV_ADD_BN_RELU, {G_OP_TYPE_FUSION_CONV_ADD_BN_RELU, {{"Input"}, {"Out"}}},
{{"Input"}, {"Out"}}},
{G_OP_TYPE_PRIOR_BOX, {{"Image", "Input"}, {"Boxes", "Variances"}}}, {G_OP_TYPE_PRIOR_BOX, {{"Image", "Input"}, {"Boxes", "Variances"}}},
{G_OP_TYPE_MULTICLASS_NMS, {{"BBoxes", "Scores"}, {"Out"}}}, {G_OP_TYPE_MULTICLASS_NMS, {{"BBoxes", "Scores"}, {"Out"}}},
{G_OP_TYPE_FC, {{"X", "Y", "Z"}, {"Out"}}}, {G_OP_TYPE_FC, {{"X", "Y", "Z"}, {"Out"}}},
......
...@@ -43,11 +43,13 @@ class FusionConvAddBNReluMatcher : public framework::FusionOpMatcher { ...@@ -43,11 +43,13 @@ class FusionConvAddBNReluMatcher : public framework::FusionOpMatcher {
vector<std::shared_ptr<framework::OpDesc>> origin_descs = vector<std::shared_ptr<framework::OpDesc>> origin_descs =
node->OpDescs(node_.Depth()); node->OpDescs(node_.Depth());
node->Folder(node_.Depth(), Type(), node->Folder(node_.Depth(), Type(),
{ {G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}}, {{G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}},
{G_OP_TYPE_BATCHNORM, {{"Scale", "Scale"}, {G_OP_TYPE_BATCHNORM,
{{"Scale", "Scale"},
{"Mean", "Mean"}, {"Mean", "Mean"},
{"Bias", "Bias"}, {"Bias", "Bias"},
{"Variance", "Variance"}}}}, removed_nodes); {"Variance", "Variance"}}}},
removed_nodes);
} }
std::string Type() { return G_OP_TYPE_FUSION_CONV_ADD_BN_RELU; } std::string Type() { return G_OP_TYPE_FUSION_CONV_ADD_BN_RELU; }
...@@ -78,7 +80,7 @@ class FusionConvAddBNReluOp ...@@ -78,7 +80,7 @@ class FusionConvAddBNReluOp
#ifdef PADDLE_MOBILE_CPU #ifdef PADDLE_MOBILE_CPU
//#ifndef FUSION_CONV_ADD_BN_RELU_REGISTER //#ifndef FUSION_CONV_ADD_BN_RELU_REGISTER
//static framework::FusionOpRegistrar fusion_conv_add_bn_relu_registrar( // static framework::FusionOpRegistrar fusion_conv_add_bn_relu_registrar(
// new FusionConvAddBNReluMatcher()); // new FusionConvAddBNReluMatcher());
//#define FUSION_CONV_ADD_BN_RELU_REGISTER //#define FUSION_CONV_ADD_BN_RELU_REGISTER
//#endif //#endif
......
...@@ -53,7 +53,7 @@ void BatchnormCompute(const BatchNormParam &param) { ...@@ -53,7 +53,7 @@ void BatchnormCompute(const BatchNormParam &param) {
"C must equal to variance.numel()"); "C must equal to variance.numel()");
int HXW = H * W; int HXW = H * W;
if (0&&HXW > 32) { if (0 && HXW > 32) {
int NXC = N * C; int NXC = N * C;
float *inv_std_ptr = new float[NXC * 4]; float *inv_std_ptr = new float[NXC * 4];
float *volatile new_scale_ptr = new float[NXC * 4]; float *volatile new_scale_ptr = new float[NXC * 4];
...@@ -222,15 +222,14 @@ void BatchnormCompute(const BatchNormParam &param) { ...@@ -222,15 +222,14 @@ void BatchnormCompute(const BatchNormParam &param) {
} }
} }
} }
} }
} }
// for(int i = 0; i < new_scale.numel(); i++){ // for(int i = 0; i < new_scale.numel(); i++){
// std::cout << "new_scale " << new_scale_ptr[i] <<std::endl; // std::cout << "new_scale " << new_scale_ptr[i] <<std::endl;
// } // }
// for(int i = 0; i < new_bias.numel(); i++){ // for(int i = 0; i < new_bias.numel(); i++){
// std::cout << "new_bias " << new_bias_ptr[i] <<std::endl; // std::cout << "new_bias " << new_bias_ptr[i] <<std::endl;
// } // }
delete[] inv_std_ptr; delete[] inv_std_ptr;
} }
......
...@@ -15,8 +15,8 @@ limitations under the License. */ ...@@ -15,8 +15,8 @@ limitations under the License. */
#ifdef FUSION_CONVADDBNRELU_OP #ifdef FUSION_CONVADDBNRELU_OP
#pragma once #pragma once
#include "operators/math/depthwiseconv3x3s1p1.h"
#include "operators/kernel/conv_add_bn_relu_kernel.h" #include "operators/kernel/conv_add_bn_relu_kernel.h"
#include "operators/math/depthwiseconv3x3s1p1.h"
#include "operators/op_param.h" #include "operators/op_param.h"
namespace paddle_mobile { namespace paddle_mobile {
namespace operators { namespace operators {
...@@ -130,11 +130,12 @@ void ConvAddBNReluCompute(const FusionConvAddBNReluParam &param) { ...@@ -130,11 +130,12 @@ void ConvAddBNReluCompute(const FusionConvAddBNReluParam &param) {
} }
auto output_ptr = output->data<float>(); auto output_ptr = output->data<float>();
for (int c = 0; c < output_matrix_shape[0]; c++){ for (int c = 0; c < output_matrix_shape[0]; c++) {
// int start = c * output_matrix_shape[1]; // int start = c * output_matrix_shape[1];
for (int j = 0; j < output_matrix_shape[1]; j++){ for (int j = 0; j < output_matrix_shape[1]; j++) {
// output_ptr[start + j] = output_ptr[start +j]*new_scale_ptr[c]+new_bias_ptr[c]; // output_ptr[start + j] = output_ptr[start
// output_ptr[start + j] = output_ptr[start+j]< 0 ? 0 : output_ptr[start +j]; // +j]*new_scale_ptr[c]+new_bias_ptr[c]; output_ptr[start + j] =
// output_ptr[start+j]< 0 ? 0 : output_ptr[start +j];
} }
} }
} }
......
...@@ -128,7 +128,7 @@ class AclBatchNormOp : public acl::ACLOperator { ...@@ -128,7 +128,7 @@ class AclBatchNormOp : public acl::ACLOperator {
}; };
template <> template <>
bool BatchNormKernel<GPU_MALI, float>::Init(BatchNormParam *param) const { bool BatchNormKernel<GPU_MALI, float>::Init(BatchNormParam* param) const {
AclBatchNormOp<GPU_MALI, float>* acl_op = AclBatchNormOp<GPU_MALI, float>* acl_op =
reinterpret_cast<AclBatchNormOp<GPU_MALI, float>*>(this->GetAclOp()); reinterpret_cast<AclBatchNormOp<GPU_MALI, float>*>(this->GetAclOp());
if (acl_op == nullptr) { if (acl_op == nullptr) {
......
...@@ -195,7 +195,7 @@ class AclConvOp : public acl::ACLOperator { ...@@ -195,7 +195,7 @@ class AclConvOp : public acl::ACLOperator {
}; };
template <> template <>
bool ConvKernel<GPU_MALI, float>::Init(ConvParam *param) const { bool ConvKernel<GPU_MALI, float>::Init(ConvParam* param) const {
AclConvOp<GPU_MALI, float>* acl_op = AclConvOp<GPU_MALI, float>* acl_op =
reinterpret_cast<AclConvOp<GPU_MALI, float>*>(this->GetAclOp()); reinterpret_cast<AclConvOp<GPU_MALI, float>*>(this->GetAclOp());
if (acl_op == nullptr) { if (acl_op == nullptr) {
......
...@@ -27,7 +27,8 @@ struct AddFunctor { ...@@ -27,7 +27,8 @@ struct AddFunctor {
}; };
template <> template <>
bool ElementwiseAddKernel<GPU_MALI, float>::Init(ElementwiseAddParam *param) const { bool ElementwiseAddKernel<GPU_MALI, float>::Init(
ElementwiseAddParam *param) const {
return true; return true;
} }
......
...@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "operators/math/depthwise_conv_3x3.h" #include "operators/math/depthwise_conv_3x3.h"
#include <vector>
#include <arm_neon.h> #include <arm_neon.h>
#include <vector>
namespace paddle_mobile { namespace paddle_mobile {
namespace operators { namespace operators {
......
...@@ -66,7 +66,8 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output, ...@@ -66,7 +66,8 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output,
float w21 = filter_data_tmp[7]; float w21 = filter_data_tmp[7];
float w22 = filter_data_tmp[8]; float w22 = filter_data_tmp[8];
output_data[0] =(w11 * input_data[0] + w12 * input_data[1] + w21 * input_data[l] + output_data[0] =
(w11 * input_data[0] + w12 * input_data[1] + w21 * input_data[l] +
w22 * input_data[l + 1] + bias_data[j]) * w22 * input_data[l + 1] + bias_data[j]) *
newscale_data[j] + newscale_data[j] +
newbias_data[j]; newbias_data[j];
...@@ -88,11 +89,13 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output, ...@@ -88,11 +89,13 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output,
w11 * input_data[l * l - 1] + bias_data[j]) * w11 * input_data[l * l - 1] + bias_data[j]) *
newscale_data[j] + newscale_data[j] +
newbias_data[j]; newbias_data[j];
if(if_relu){ if (if_relu) {
output_data[0] = output_data[0] < 0 ? 0 : output_data[0]; output_data[0] = output_data[0] < 0 ? 0 : output_data[0];
output_data[l-1] = output_data[l-1] < 0 ? 0 : output_data[l-1]; output_data[l - 1] = output_data[l - 1] < 0 ? 0 : output_data[l - 1];
output_data[(l-1)*l] = output_data[(l-1)*l] < 0 ? 0 : output_data[(l-1)*l]; output_data[(l - 1) * l] =
output_data[l * l - 1] = output_data[l * l - 1] < 0 ? 0 : output_data[l * l - 1]; output_data[(l - 1) * l] < 0 ? 0 : output_data[(l - 1) * l];
output_data[l * l - 1] =
output_data[l * l - 1] < 0 ? 0 : output_data[l * l - 1];
} }
for (int i = 1; i < l - 1; ++i) { for (int i = 1; i < l - 1; ++i) {
output_data[i * l] = output_data[i * l] =
...@@ -111,9 +114,10 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output, ...@@ -111,9 +114,10 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output,
w21 * input_data[i * l + l - 1 + l] + bias_data[j]) * w21 * input_data[i * l + l - 1 + l] + bias_data[j]) *
newscale_data[j] + newscale_data[j] +
newbias_data[j]; newbias_data[j];
if(if_relu){ if (if_relu) {
output_data[i * l] = output_data[i * l] < 0 ? 0 : output_data[i * l]; output_data[i * l] = output_data[i * l] < 0 ? 0 : output_data[i * l];
output_data[i * l + l - 1] = output_data[i * l + l - 1] < 0 ? 0 : output_data[i * l + l - 1]; output_data[i * l + l - 1] =
output_data[i * l + l - 1] < 0 ? 0 : output_data[i * l + l - 1];
} }
} }
...@@ -332,7 +336,6 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output, ...@@ -332,7 +336,6 @@ void DepthwiseConv3x3s1p1(const Tensor *input, Tensor filter, Tensor *output,
filter_data_tmp += 9; filter_data_tmp += 9;
} }
} }
} }
} // namespace math } // namespace math
} // namespace operators } // namespace operators
......
...@@ -823,9 +823,9 @@ class FusionConvAddParam : public OpParam { ...@@ -823,9 +823,9 @@ class FusionConvAddParam : public OpParam {
const int &Groups() const { return groups; } const int &Groups() const { return groups; }
void Set(Tensor *t) {t_ = t;} void Set(Tensor *t) { t_ = t; }
const Tensor *Get() const {return t_;} const Tensor *Get() const { return t_; }
protected: protected:
Tensor *bias_; Tensor *bias_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册