已合并
修复pooling作用域 #2512
胡一航创建于 3月10日
修复pooling作用域 #2512
已合并
共 10 个文件变更+18-30
| @@ -37,6 +37,7 @@ | |||
| 37 | #include "aclnn_kernels/common/op_error_check.h" | 37 | #include "aclnn_kernels/common/op_error_check.h" |
| 38 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" | 38 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" |
| 39 | using namespace op; | 39 | using namespace op; |
| 40 | +using namespace Pool3DCommon; | ||
| 40 | #ifdef __cplusplus | 41 | #ifdef __cplusplus |
| 41 | extern "C" { | 42 | extern "C" { |
| 42 | #endif | 43 | #endif |
| @@ -20,6 +20,8 @@ | |||
| 20 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" | 20 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" |
| 21 | #include "adaptive_max_pool_common.h" | 21 | #include "adaptive_max_pool_common.h" |
| 22 | using namespace op; | 22 | using namespace op; |
| 23 | +using namespace AdaptiveMaxPoolCommon; | ||
| 24 | +using namespace Pool3DCommon; | ||
| 23 | #ifdef __cplusplus | 25 | #ifdef __cplusplus |
| 24 | extern "C" { | 26 | extern "C" { |
| 25 | #endif | 27 | #endif |
| @@ -20,6 +20,8 @@ | |||
| 20 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" | 20 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" |
| 21 | #include "adaptive_max_pool_common.h" | 21 | #include "adaptive_max_pool_common.h" |
| 22 | using namespace op; | 22 | using namespace op; |
| 23 | +using namespace AdaptiveMaxPoolCommon; | ||
| 24 | +using namespace Pool3DCommon; | ||
| 23 | #ifdef __cplusplus | 25 | #ifdef __cplusplus |
| 24 | extern "C" { | 26 | extern "C" { |
| 25 | #endif | 27 | #endif |
| @@ -27,10 +27,7 @@ | |||
| 27 | #include "adaptive_max_pool_common.h" | 27 | #include "adaptive_max_pool_common.h" |
| 28 | using namespace op; | 28 | using namespace op; |
| 29 | 29 | ||
| 30 | -#ifdef __cplusplus | 30 | +namespace AdaptiveMaxPoolCommon { |
| 31 | -extern "C" { | ||
| 32 | -#endif | ||
| 33 | - | ||
| 34 | static const std::initializer_list<DataType> NULL_DTYPE_SUPPORT_LIST = {}; | 31 | static const std::initializer_list<DataType> NULL_DTYPE_SUPPORT_LIST = {}; |
| 35 | static const std::initializer_list<DataType> GRAD_DTYPE_SUPPORT_LIST = { | 32 | static const std::initializer_list<DataType> GRAD_DTYPE_SUPPORT_LIST = { |
| 36 | DataType::DT_BF16, DataType::DT_FLOAT16, DataType::DT_FLOAT}; | 33 | DataType::DT_BF16, DataType::DT_FLOAT16, DataType::DT_FLOAT}; |
| @@ -57,8 +54,7 @@ bool CheckNotNullPtr( | |||
| 57 | OP_CHECK_NULL(gradInput, return false); | 54 | OP_CHECK_NULL(gradInput, return false); |
| 58 | return true; | 55 | return true; |
| 59 | } | 56 | } |
| 60 | - | 57 | +const std::initializer_list<op::DataType> GetDtypeSupportListBySocVersion() |
| 61 | -static const std::initializer_list<op::DataType> GetDtypeSupportListBySocVersion() | ||
| 62 | { | 58 | { |
| 63 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 59 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); |
| 64 | switch (socVersion) { | 60 | switch (socVersion) { |
| @@ -107,7 +103,7 @@ bool CheckShapeSame( | |||
| 107 | return true; | 103 | return true; |
| 108 | } | 104 | } |
| 109 | 105 | ||
| 110 | -static bool CheckDtypeValid( | 106 | +bool CheckDtypeValid( |
| 111 | const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, const aclTensor* gradInput) | 107 | const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, const aclTensor* gradInput) |
| 112 | { | 108 | { |
| 113 | OP_CHECK_DTYPE_NOT_SAME(self, gradOutput, return false); | 109 | OP_CHECK_DTYPE_NOT_SAME(self, gradOutput, return false); |
| @@ -183,7 +179,5 @@ const aclTensor* selectLevelZeroOperation( | |||
| 183 | 179 | ||
| 184 | return nullptr; | 180 | return nullptr; |
| 185 | } | 181 | } |
| 186 | - | ||
| 187 | -#ifdef __cplusplus | ||
| 188 | } | 182 | } |
| 189 | -#endif | 183 | + |
| @@ -16,17 +16,13 @@ | |||
| 16 | #include "opdev/make_op_executor.h" | 16 | #include "opdev/make_op_executor.h" |
| 17 | #include "opdev/framework_op.h" | 17 | #include "opdev/framework_op.h" |
| 18 | 18 | ||
| 19 | -#ifdef __cplusplus | 19 | +namespace AdaptiveMaxPoolCommon { |
| 20 | -extern "C" { | ||
| 21 | -#endif | ||
| 22 | bool CheckNotNullPtr(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, aclTensor* gradInput); | 20 | bool CheckNotNullPtr(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, aclTensor* gradInput); |
| 23 | -static const std::initializer_list<op::DataType> GetDtypeSupportListBySocVersion(); | 21 | +const std::initializer_list<op::DataType> GetDtypeSupportListBySocVersion(); |
| 24 | bool CheckShapeSame(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, const aclTensor* gradInput); | 22 | bool CheckShapeSame(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, const aclTensor* gradInput); |
| 25 | -static bool CheckDtypeValid(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, const aclTensor* gradInput); | 23 | +bool CheckDtypeValid(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, const aclTensor* gradInput); |
| 26 | aclnnStatus CheckParams(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, aclTensor* gradInput); | 24 | aclnnStatus CheckParams(const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, aclTensor* gradInput); |
| 27 | const aclTensor* selectLevelZeroOperation( | 25 | const aclTensor* selectLevelZeroOperation( |
| 28 | const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, aclTensor* /* gradInput */, | 26 | const aclTensor* gradOutput, const aclTensor* self, const aclTensor* indices, aclTensor* /* gradInput */, |
| 29 | aclOpExecutor* executor); | 27 | aclOpExecutor* executor); |
| 30 | -#ifdef __cplusplus | ||
| 31 | } | 28 | } |
| 32 | -#endif | ||
| @@ -46,6 +46,7 @@ | |||
| 46 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" | 46 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" |
| 47 | using namespace avgpool2d_conv2d_input_util; | 47 | using namespace avgpool2d_conv2d_input_util; |
| 48 | using namespace op; | 48 | using namespace op; |
| 49 | +using namespace Pool3DCommon; | ||
| 49 | namespace op { | 50 | namespace op { |
| 50 | static aclnnStatus CheckArrayDataAvgPoolBackWard( | 51 | static aclnnStatus CheckArrayDataAvgPoolBackWard( |
| 51 | const aclIntArray* kernelSize, const aclIntArray* stride, const aclIntArray* padding) | 52 | const aclIntArray* kernelSize, const aclIntArray* stride, const aclIntArray* padding) |
| @@ -27,7 +27,7 @@ | |||
| 27 | #include "opdev/platform.h" | 27 | #include "opdev/platform.h" |
| 28 | #include "op_api/aclnn_util.h" | 28 | #include "op_api/aclnn_util.h" |
| 29 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" | 29 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" |
| 30 | - | 30 | +using namespace Pool3DCommon; |
| 31 | using namespace op; | 31 | using namespace op; |
| 32 | #ifdef __cplusplus | 32 | #ifdef __cplusplus |
| 33 | extern "C" { | 33 | extern "C" { |
| @@ -25,7 +25,7 @@ | |||
| 25 | #include "opdev/framework_op.h" | 25 | #include "opdev/framework_op.h" |
| 26 | #include "op_api/aclnn_util.h" | 26 | #include "op_api/aclnn_util.h" |
| 27 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" | 27 | #include "pooling/pool_3d_common/op_api/pool_3d_util.h" |
| 28 | - | 28 | +using namespace Pool3DCommon; |
| 29 | using namespace op; | 29 | using namespace op; |
| 30 | #ifdef __cplusplus | 30 | #ifdef __cplusplus |
| 31 | extern "C" { | 31 | extern "C" { |
| @@ -22,9 +22,7 @@ | |||
| 22 | #include "opdev/platform.h" | 22 | #include "opdev/platform.h" |
| 23 | #include "pool_3d_util.h" | 23 | #include "pool_3d_util.h" |
| 24 | 24 | ||
| 25 | -#ifdef __cplusplus | 25 | +namespace Pool3DCommon { |
| 26 | -extern "C" { | ||
| 27 | -#endif | ||
| 28 | const aclTensor* View3Das5D(const aclTensor* input, aclOpExecutor* executor) | 26 | const aclTensor* View3Das5D(const aclTensor* input, aclOpExecutor* executor) |
| 29 | { | 27 | { |
| 30 | // CHW -> unsqueeze -> reformat -> NCDHW | 28 | // CHW -> unsqueeze -> reformat -> NCDHW |
| @@ -128,6 +126,4 @@ const aclTensor* View5DasCDHW(const aclTensor* input, const op::Format& format, | |||
| 128 | return reformatInput; | 126 | return reformatInput; |
| 129 | } | 127 | } |
| 130 | 128 | ||
| 131 | -#ifdef __cplusplus | ||
| 132 | } | 129 | } |
| 133 | -#endif | ||
| @@ -15,10 +15,7 @@ | |||
| 15 | #include "opdev/platform.h" | 15 | #include "opdev/platform.h" |
| 16 | #include "opdev/format_utils.h" | 16 | #include "opdev/format_utils.h" |
| 17 | 17 | ||
| 18 | -#ifdef __cplusplus | 18 | +namespace Pool3DCommon { |
| 19 | -extern "C" { | ||
| 20 | -#endif | ||
| 21 | - | ||
| 22 | const aclTensor* View3Das5D(const aclTensor* input, aclOpExecutor* executor); | 19 | const aclTensor* View3Das5D(const aclTensor* input, aclOpExecutor* executor); |
| 23 | const aclTensor* View4Das5D(const aclTensor* input, aclOpExecutor* executor); | 20 | const aclTensor* View4Das5D(const aclTensor* input, aclOpExecutor* executor); |
| 24 | const aclTensor* View5Das3D(const aclTensor* input, const op::Format& format, aclOpExecutor* executor); | 21 | const aclTensor* View5Das3D(const aclTensor* input, const op::Format& format, aclOpExecutor* executor); |
| @@ -26,8 +23,7 @@ const aclTensor* View5Das4D(const aclTensor* input, const op::Format& format, ac | |||
| 26 | const aclTensor* View3Das4D(const aclTensor* input, aclOpExecutor* executor); | 23 | const aclTensor* View3Das4D(const aclTensor* input, aclOpExecutor* executor); |
| 27 | const aclTensor* ViewCDHWas5D(const aclTensor* input, aclOpExecutor* executor); | 24 | const aclTensor* ViewCDHWas5D(const aclTensor* input, aclOpExecutor* executor); |
| 28 | const aclTensor* View5DasCDHW(const aclTensor* input, const op::Format& format, aclOpExecutor* executor); | 25 | const aclTensor* View5DasCDHW(const aclTensor* input, const op::Format& format, aclOpExecutor* executor); |
| 29 | -#ifdef __cplusplus | ||
| 30 | } | 26 | } |
| 31 | -#endif | 27 | + |
| 32 | 28 | ||
| 33 | #endif | 29 | #endif |