diff --git a/src/framework/op_registry.h b/src/framework/op_registry.h index 8e22e74b4fe250a9c2ba79321a3d8fa6484d5d2e..a76cc7e4910d1639a10fcc839e9073a837fd89f5 100644 --- a/src/framework/op_registry.h +++ b/src/framework/op_registry.h @@ -108,7 +108,7 @@ class OpRegistry { __op_registrar_##op_type##_##device_name(#op_type); \ int TouchOpRegistrar_##op_type##_##device_name() { \ __op_registrar_##op_type##_##device_name.Touch(); \ - printf(" registering !! \n"); \ + printf(" registering !! \n"); \ return 0; \ } diff --git a/src/io/executor.cpp b/src/io/executor.cpp index 1837273d6b95e5864606063a0b95a4175e468b00..82c3eae5d92fac19b2ed94fb587497236afd917d 100644 --- a/src/io/executor.cpp +++ b/src/io/executor.cpp @@ -355,8 +355,9 @@ std::shared_ptr Executor::Predict( const auto &pInfo = profile[i]; uint64_t timeCost = pInfo.runEnd - pInfo.runBegin; _tp[ops[i]->Type()] += timeCost; - // fprintf(pf, "%d\t%s\t%d\t%llu\t%llu\t%llu\n", i, ops[i]->Type().c_str(), - // pInfo.tid, pInfo.runBegin, pInfo.runEnd, timeCost); + // fprintf(pf, "%d\t%s\t%d\t%llu\t%llu\t%llu\n", i, + // ops[i]->Type().c_str(), + // pInfo.tid, pInfo.runBegin, pInfo.runEnd, timeCost); } // fclose(pf); diff --git a/src/io/paddle_mobile.cpp b/src/io/paddle_mobile.cpp index 850b60d5e14a929fe823654d1b055cac55c38d65..3d5735f8da66db6f4b5f139f8261a4cd9cf0f796 100644 --- a/src/io/paddle_mobile.cpp +++ b/src/io/paddle_mobile.cpp @@ -75,7 +75,7 @@ void PaddleMobile::Clear() { } template -PaddleMobile::~PaddleMobile(){ +PaddleMobile::~PaddleMobile() { executor_ = nullptr; loader_ = nullptr; } diff --git a/src/io/paddle_mobile.h b/src/io/paddle_mobile.h index 82436a283db449c6ad2e39f2423579d27e1c699e..3ce39e0ae1ffc7e193f6f4308a911875fdf95076 100644 --- a/src/io/paddle_mobile.h +++ b/src/io/paddle_mobile.h @@ -61,6 +61,7 @@ class PaddleMobile { void Clear(); ~PaddleMobile(); + private: std::shared_ptr> loader_; std::shared_ptr> executor_; diff --git a/src/ios_io/PaddleMobile.h b/src/ios_io/PaddleMobile.h index 1e635dd0a8a28285226c049f590e46dc421d091f..863c0d004440dc6098eb7dc1ed490fde20f237c9 100644 --- a/src/ios_io/PaddleMobile.h +++ b/src/ios_io/PaddleMobile.h @@ -1,11 +1,11 @@ /* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/ios_io/PaddleMobile.mm b/src/ios_io/PaddleMobile.mm index b24edf592cdaf9db6b12a6c511798a3262e44f55..f5ec2afb2a996ec4932d99ea93362e06ddf28a14 100644 --- a/src/ios_io/PaddleMobile.mm +++ b/src/ios_io/PaddleMobile.mm @@ -1,11 +1,11 @@ /* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/operators/fetch_op.cpp b/src/operators/fetch_op.cpp index dbcfaaa9abb6d6775c9c6304dc043b1db9b4749f..cdbe413c955b931a16e716aa2e18d2a018a53bab 100644 --- a/src/operators/fetch_op.cpp +++ b/src/operators/fetch_op.cpp @@ -29,5 +29,3 @@ REGISTER_OPERATOR_MALI_GPU(fetch, ops::FetchOp); #endif #ifdef PADDLE_MOBILE_FPGA #endif - - diff --git a/src/operators/fetch_op.h b/src/operators/fetch_op.h index aa39e33419338d4855284921d3bdaf6d19069d7d..5614fef8fe1a5b2e234b29e6d7b52cc4c2719008 100644 --- a/src/operators/fetch_op.h +++ b/src/operators/fetch_op.h @@ -44,7 +44,6 @@ class FetchOp : public framework::OperatorBase { FetchParam param_; }; - } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/fusion_conv_add.cpp b/src/operators/fusion_conv_add.cpp index 1524791196a6ac5aea17dc93aef7390714187891..be70370f9de0963bbe6625513257be890e36dacb 100644 --- a/src/operators/fusion_conv_add.cpp +++ b/src/operators/fusion_conv_add.cpp @@ -48,8 +48,7 @@ void FusionConvAddOp::InferShape() const { #ifdef PADDLE_MOBILE_CPU #ifndef CONV_ADD_REGISTER -framework::FusionOpRegistrar convadd_registrar( - new FusionConvAddMatcher()); +framework::FusionOpRegistrar convadd_registrar(new FusionConvAddMatcher()); #define CONV_ADD_REGISTER #endif diff --git a/src/operators/im2sequence_op.h b/src/operators/im2sequence_op.h index 1eb180b54da38a614491e15b39cc64a8d6e0ea53..0695da9308d33ca2b86a5e052210507beb9a82d3 100644 --- a/src/operators/im2sequence_op.h +++ b/src/operators/im2sequence_op.h @@ -59,4 +59,3 @@ USE_OP_CPU(im2sequence); #endif #endif - diff --git a/src/operators/kernel/central-arm-func/batchnorm_arm_func.h b/src/operators/kernel/central-arm-func/batchnorm_arm_func.h index 276f6afe1b9be999929881ad5ca3aafc6def9c87..2845e5f8b7d18e1c446e0eac73e730b59f9e4550 100644 --- a/src/operators/kernel/central-arm-func/batchnorm_arm_func.h +++ b/src/operators/kernel/central-arm-func/batchnorm_arm_func.h @@ -231,37 +231,35 @@ void BatchnormCompute(const BatchNormParam ¶m) { } #endif float *inv_std_ptr = new float[C]; - for (int i = 0; i < C; i++) { - inv_std_ptr[i] = - 1 / static_cast(pow((variance_ptr[i] + epsilon), 0.5)); - } - - Tensor new_scale; - auto new_scale_ptr = - new_scale.mutable_data(framework::make_ddim({C})); - Tensor new_bias; - auto new_bias_ptr = new_bias.mutable_data(framework::make_ddim({C})); + for (int i = 0; i < C; i++) { + inv_std_ptr[i] = + 1 / static_cast(pow((variance_ptr[i] + epsilon), 0.5)); + } - /// ((x - est_mean) * (inv_var) * scale + bias equal to - /// (x * inv_var * scale) + (bias - est_mean * inv_var * scale) - for (int i = 0; i < C; i++) { - new_scale_ptr[i] = inv_std_ptr[i] * scale_ptr[i]; - new_bias_ptr[i] = - bias_ptr[i] - mean_ptr[i] * inv_std_ptr[i] * scale_ptr[i]; - { - for (int n = 0; n < N; n++) { - for (int h = 0; h < H; h++) { - int tmp_index = n * stride0 + i * stride1 + h * stride2; - for (int w = 0; w < W; w++) { - int index = tmp_index + w; - out_ptr[index] = - input_x_ptr[index] * new_scale_ptr[i] + new_bias_ptr[i]; - } + Tensor new_scale; + auto new_scale_ptr = new_scale.mutable_data(framework::make_ddim({C})); + Tensor new_bias; + auto new_bias_ptr = new_bias.mutable_data(framework::make_ddim({C})); + + /// ((x - est_mean) * (inv_var) * scale + bias equal to + /// (x * inv_var * scale) + (bias - est_mean * inv_var * scale) + for (int i = 0; i < C; i++) { + new_scale_ptr[i] = inv_std_ptr[i] * scale_ptr[i]; + new_bias_ptr[i] = bias_ptr[i] - mean_ptr[i] * inv_std_ptr[i] * scale_ptr[i]; + { + for (int n = 0; n < N; n++) { + for (int h = 0; h < H; h++) { + int tmp_index = n * stride0 + i * stride1 + h * stride2; + for (int w = 0; w < W; w++) { + int index = tmp_index + w; + out_ptr[index] = + input_x_ptr[index] * new_scale_ptr[i] + new_bias_ptr[i]; } } } } - delete[] inv_std_ptr; + } + delete[] inv_std_ptr; } } // namespace operators diff --git a/src/operators/math/gemm.cpp b/src/operators/math/gemm.cpp index 0cc0598474efd24dade0ec1c76902ceb32e6bf16..e9974df967b293317c3014803bec27d2da73fca3 100644 --- a/src/operators/math/gemm.cpp +++ b/src/operators/math/gemm.cpp @@ -129,14 +129,13 @@ void PackMatrixB_(int k, int n, int n_tail, const float *B, int ldb, } #else for (i = 0; i < k; ++i) { - Bij = &B(i, j); - *buffer++ = *Bij; - *buffer++ = *(Bij + 1); - *buffer++ = *(Bij + 2); - *buffer++ = *(Bij + 3); - } + Bij = &B(i, j); + *buffer++ = *Bij; + *buffer++ = *(Bij + 1); + *buffer++ = *(Bij + 2); + *buffer++ = *(Bij + 3); + } #endif - } if (n_tail != 0) { for (i = 0; i < k; ++i) { diff --git a/src/operators/math/pool_2x2.cpp b/src/operators/math/pool_2x2.cpp index 1d5efdad0e2355f8d0ad6980ba80684dc489a9fb..e0fd5da57cc91d4f1c55c560134398126517db29 100644 --- a/src/operators/math/pool_2x2.cpp +++ b/src/operators/math/pool_2x2.cpp @@ -102,7 +102,7 @@ void Pool2x2Avg(vector strides, vector paddings, const Tensor *input, #if __ARM_NEON #ifdef ARMV7 -const int batch_size = input->dims()[0]; + const int batch_size = input->dims()[0]; const int input_height = input->dims()[2]; @@ -173,7 +173,7 @@ const int batch_size = input->dims()[0]; } #else - //TODO(): to imp other asm +// TODO(): to imp other asm #endif diff --git a/src/operators/math/pooling.cpp b/src/operators/math/pooling.cpp index 4287408394f1a7f407154938f3e83e9fac3543a2..a8f6c77170433ce77ddb0e3d25808dbdd0382bb1 100644 --- a/src/operators/math/pooling.cpp +++ b/src/operators/math/pooling.cpp @@ -57,7 +57,7 @@ class PoolFunctor { T *output_data = output->mutable_data(); for (int i = 0; i < batch_size; i++) { - #pragma omp parallel for + // #pragma omp parallel for for (int c = 0; c < output_channels; ++c) { for (int ph = 0; ph < output_height; ++ph) { int hstart = ph * stride_height - padding_height; diff --git a/src/operators/transpose_op.h b/src/operators/transpose_op.h index 439ab2b6e1c25681cd74d028c1a892fb6db83eeb..25cf07c4c9253736d513505e5f8eba6147f3740c 100644 --- a/src/operators/transpose_op.h +++ b/src/operators/transpose_op.h @@ -50,7 +50,6 @@ class TransposeOp : public framework::OperatorWithKernel< } // namespace operators } // namespace paddle_mobile - #ifdef PADDLE_MOBILE_CPU USE_OP_CPU(transpose); #endif diff --git a/test/common/test_openmp.cpp b/test/common/test_openmp.cpp index 790c434101e20478853b7079533403d65dc829ba..b9a112b5f0051eb471e06bd5e261949032c9d200 100644 --- a/test/common/test_openmp.cpp +++ b/test/common/test_openmp.cpp @@ -17,7 +17,7 @@ limitations under the License. */ int main(void) { #ifdef PADDLE_MOBILE_USE_OPENMP - #pragma omp parallel num_threads(2) + // #pragma omp parallel num_threads(2) { // int thread_id = omp_get_thread_num(); // int nthreads = omp_get_num_threads();