diff --git a/docs/introduction/support_operation_list.md b/docs/introduction/support_operation_list.md index 1a0ba4e3c60b6dafdb42fc97299847894069b714..1ae8986f5544154958fb42684fd83a7a55110168 100644 --- a/docs/introduction/support_operation_list.md +++ b/docs/introduction/support_operation_list.md @@ -159,8 +159,7 @@ | not_equal | Y |   |   |   |   |   |   |   |   |   | | one_hot | Y |   |   |   |   |   |   |   |   |   | | pixel_shuffle | Y |   |   | Y | Y |   |   |   |   |   | -| pow |   |   |   |   |   |   |   |   |   |   | -| power |   |   |   | Y |   |   |   |   |   |   | +| pow |   |   |   | Y |   |   |   |   |   |   | | print | Y |   |   |   |   |   |   |   |   |   | | read_from_array | Y |   |   |   |   |   |   |   |   |   | | reciprocal |   |   |   | Y |   |   |   |   |   |   | diff --git a/lite/backends/arm/math/CMakeLists.txt b/lite/backends/arm/math/CMakeLists.txt index 88c449e6a9d8b8078802e90dded5db1162459d3f..26fcd8335e39cb6af02c4e9a2c348bf44a4624a3 100644 --- a/lite/backends/arm/math/CMakeLists.txt +++ b/lite/backends/arm/math/CMakeLists.txt @@ -101,8 +101,8 @@ if (NOT HAS_ARM_MATH_LIB_DIR) activation.cc yolo_box.cc dropout.cc - power.cc - interpolate.cc + pow.cc + interpolate.cc argmax.cc axpy.cc fill_bias_relu.cc diff --git a/lite/backends/arm/math/funcs.h b/lite/backends/arm/math/funcs.h index f1ac1d63a1b40e2ead5e976e0bffe6c435a2545b..b2afa514cc00f78a931608e2bfbb3562df8b16d6 100644 --- a/lite/backends/arm/math/funcs.h +++ b/lite/backends/arm/math/funcs.h @@ -15,6 +15,7 @@ #pragma once #include + #include #include @@ -48,7 +49,7 @@ #include "lite/backends/arm/math/packed_sgemm_c4.h" #include "lite/backends/arm/math/pad2d.h" #include "lite/backends/arm/math/pooling.h" -#include "lite/backends/arm/math/power.h" +#include "lite/backends/arm/math/pow.h" #include "lite/backends/arm/math/prior_box.h" #include "lite/backends/arm/math/reduce_max.h" #include "lite/backends/arm/math/reduce_mean.h" diff --git a/lite/backends/arm/math/power.cc b/lite/backends/arm/math/pow.cc similarity index 91% rename from lite/backends/arm/math/power.cc rename to lite/backends/arm/math/pow.cc index 752c63d9170a6758631045b0ed8f4952bfc12c9b..aef8277ee8712eae57531da0b8b09b5ccc962cb8 100644 --- a/lite/backends/arm/math/power.cc +++ b/lite/backends/arm/math/pow.cc @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lite/backends/arm/math/power.h" +#include "lite/backends/arm/math/pow.h" + #include "lite/backends/arm/math/funcs.h" namespace paddle { @@ -26,13 +27,13 @@ void power(const float* din, const int num, float scale_, float shift_, - float power_) { + float factor_) { int cnt = num >> 4; int remain = num % 16; bool _do_power = true; bool _do_scale = true; bool _do_shift = true; - if (fabsf(power_ - 1.f) < 1e-6f) { + if (fabsf(factor_ - 1.f) < 1e-6f) { _do_power = false; } if (fabsf(scale_ - 1.f) < 1e-6f) { @@ -45,7 +46,7 @@ void power(const float* din, const float* ptr_in = din; float32x4_t vscale = vdupq_n_f32(scale_); float32x4_t vshift = vdupq_n_f32(shift_); - float32x4_t vpower = vdupq_n_f32(power_); + float32x4_t vpower = vdupq_n_f32(factor_); #pragma omp parallel for for (int nums = 0; nums < cnt; ++nums) { float32x4_t vr0 = vld1q_f32(ptr_in); @@ -84,7 +85,7 @@ void power(const float* din, ptr_out += 4; } for (int j = 0; j < remain; ++j) { - ptr_out[0] = std::pow((ptr_in[0] * scale_ + shift_), power_); + ptr_out[0] = std::pow((ptr_in[0] * scale_ + shift_), factor_); ptr_in++; ptr_out++; } diff --git a/lite/backends/arm/math/power.h b/lite/backends/arm/math/pow.h similarity index 84% rename from lite/backends/arm/math/power.h rename to lite/backends/arm/math/pow.h index 7b9074918d28bed15b583f4a8c58f2c461df1aea..9a01ec6e4766b44a934d06fcd5e98318b9381df8 100644 --- a/lite/backends/arm/math/power.h +++ b/lite/backends/arm/math/pow.h @@ -20,12 +20,12 @@ namespace arm { namespace math { template -void power(const T* din, - T* dout, - const int num, - float scale_, - float shift_, - float power_); +void pow(const T* din, + T* dout, + const int num, + float scale_, + float shift_, + float factor_); } /* namespace math */ } /* namespace arm */ diff --git a/lite/kernels/arm/pow_compute.cc b/lite/kernels/arm/pow_compute.cc index f0f6c724ad18f2bc085d2c1e053c2900a55c75da..4a081e03fdeb9ef00978ffa0e908956b1d9e22b8 100644 --- a/lite/kernels/arm/pow_compute.cc +++ b/lite/kernels/arm/pow_compute.cc @@ -29,9 +29,7 @@ void PowCompute::Run() { float shift = 0.0; float power = param.factor; - // fixme: update lite::arm::math::power if necessary, for scale and shift is - // not used - lite::arm::math::power( + lite::arm::math::pow( x_data, output_data, x_dims.production(), scale, shift, power); } diff --git a/lite/operators/CMakeLists.txt b/lite/operators/CMakeLists.txt index 6cdf815a6f03f0e36b95acc4f8e6f15dc64b4de2..e6b761e5a141edb04cd61a0d74033609a70f5fbb 100644 --- a/lite/operators/CMakeLists.txt +++ b/lite/operators/CMakeLists.txt @@ -60,7 +60,6 @@ add_operator(sign_op extra SRCS sign_op.cc DEPS ${op_DEPS}) add_operator(negative_op extra SRCS negative_op.cc DEPS ${op_DEPS}) add_operator(crop_op extra SRCS crop_op.cc DEPS ${op_DEPS}) add_operator(assign_op extra SRCS assign_op.cc DEPS ${op_DEPS}) -add_operator(power_op extra SRCS power_op.cc DEPS ${op_DEPS}) add_operator(group_norm_op extra SRCS group_norm_op.cc DEPS ${op_DEPS}) add_operator(norm_op extra SRCS norm_op.cc DEPS ${op_DEPS}) diff --git a/lite/operators/power_op.cc b/lite/operators/power_op.cc deleted file mode 100644 index 83c9edfaca1505746640280633bf6d47cddc6146..0000000000000000000000000000000000000000 --- a/lite/operators/power_op.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2019 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. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "lite/operators/power_op.h" -#include "lite/core/op_lite.h" -#include "lite/core/op_registry.h" -#include "lite/core/tensor.h" - -namespace paddle { -namespace lite { -namespace operators { - -bool PowerOp::CheckShape() const { - CHECK_OR_FALSE(param_.X); - CHECK_OR_FALSE(param_.Out); - return true; -} - -bool PowerOp::InferShapeImpl() const { - param_.Out->Resize(param_.X->dims()); - return true; -} - -bool PowerOp::AttachImpl(const cpp::OpDesc &op_desc, lite::Scope *scope) { - auto X = op_desc.Input("X").front(); - auto Out = op_desc.Output("Out").front(); - param_.X = scope->FindVar(X)->GetMutable(); - param_.Out = scope->FindVar(Out)->GetMutable(); - param_.scale = op_desc.GetAttr("scale"); - param_.shift = op_desc.GetAttr("shift"); - param_.power = op_desc.GetAttr("power"); - CHECK(param_.X); - CHECK(param_.Out); - - return true; -} - -} /* namespace operators */ -} /* namespace lite */ -} /* namespace paddle */ - -REGISTER_LITE_OP(power, paddle::lite::operators::PowerOp); diff --git a/lite/operators/power_op.h b/lite/operators/power_op.h deleted file mode 100644 index 0b2ab71dbf7ba1a2b68bd7d1bc1e60be6b9fa6a4..0000000000000000000000000000000000000000 --- a/lite/operators/power_op.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2019 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. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once -#include -#include -#include "lite/core/op_lite.h" -#include "lite/core/scope.h" -#include "lite/utils/all.h" - -namespace paddle { -namespace lite { -namespace operators { - -/** - * @deprecated There is NO power op in paddle fluid - */ -class PowerOp : public OpLite { - public: - PowerOp() {} - - explicit PowerOp(const std::string &op_type) : OpLite(op_type) {} - - bool CheckShape() const override; - - bool InferShapeImpl() const override; - - bool AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) override; - - void AttachKernel(KernelBase *kernel) override { kernel->SetParam(param_); } - - std::string DebugString() const override { return "power"; } - -#ifdef LITE_WITH_PROFILE - void GetOpRuntimeInfo(paddle::lite::profile::OpCharacter *ch) { - ch->input_shape = ch->DimToStr(param_.X->dims()); - ch->output_shape = ch->DimToStr(param_.Out->dims()); - // ch->remark = ""; - ch->macs = param_.Out->numel() * 3.0f; - } -#endif - - private: - mutable PowerParam param_; -}; - -} /* namespace operators */ -} /* namespace lite */ -} /* namespace paddle */