已合并
debug exp=1 #3534
wym_666创建于 6月25日
debug exp=1 #3534
已合并
wym_666创建于 6月25日
1 个文件变更+4-0
Mmath/pow/op_api/aclnn_pow.cpp+4-0
@@ -34,6 +34,7 @@ extern "C" {
34#endif34#endif
35 35 
36const float SQRT_EXP = 0.5;36const float SQRT_EXP = 0.5;
37+const float NOOP_EXP = 1.0;
37const float SQUARE_EXP = 2.0;38const float SQUARE_EXP = 2.0;
38const float CUBE_EXP = 3.0;39const float CUBE_EXP = 3.0;
39const float NEGTIVE_SQRT_EXP = -0.5;40const float NEGTIVE_SQRT_EXP = -0.5;
@@ -433,6 +434,7 @@ aclnnStatus aclnnPowTensorScalarGetWorkspaceSize(const aclTensor *self,
433 selfCast->GetDataType() == op::DataType::DT_INT64 ||434 selfCast->GetDataType() == op::DataType::DT_INT64 ||
434 selfCast->GetDataType() == op::DataType::DT_COMPLEX64 ||435 selfCast->GetDataType() == op::DataType::DT_COMPLEX64 ||
435 selfCast->GetDataType() == op::DataType::DT_COMPLEX128)));436 selfCast->GetDataType() == op::DataType::DT_COMPLEX128)));
437+ bool canNoUseOp = static_cast<float>(exponent->ToFloat()) == NOOP_EXP && !IsRegBase();
436 if (CheckSupportPows(selfCast, exponent)) {438 if (CheckSupportPows(selfCast, exponent)) {
437 auto expTensor = uniqueExecutor.get()->ConvertToTensor(exponent, promoteType);439 auto expTensor = uniqueExecutor.get()->ConvertToTensor(exponent, promoteType);
438 CHECK_RET(expTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);440 CHECK_RET(expTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -446,6 +448,8 @@ aclnnStatus aclnnPowTensorScalarGetWorkspaceSize(const aclTensor *self,
446 }448 }
447 // 当exponent为2.0时,使用square算子计算449 // 当exponent为2.0时,使用square算子计算
448 powOut = const_cast<aclTensor *>(l0op::Square(squareInput, uniqueExecutor.get()));450 powOut = const_cast<aclTensor *>(l0op::Square(squareInput, uniqueExecutor.get()));
451+ } else if (canNoUseOp) {
452+ powOut = const_cast<aclTensor *>(selfCast);
449 } else {453 } else {
450 auto expTensor = uniqueExecutor.get()->ConvertToTensor(exponent, promoteType);454 auto expTensor = uniqueExecutor.get()->ConvertToTensor(exponent, promoteType);
451 CHECK_RET(expTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);455 CHECK_RET(expTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);