已合并
avgpool3d_backward 确定性计算性能优化 #512
jiangqi创建于 2025年12月26日
avgpool3d_backward 确定性计算性能优化 #512
已合并
jiangqi创建于 2025年12月26日
8 个文件变更+132-53
@@ -7,4 +7,4 @@
7# See LICENSE in the root of the software repository for the full text of the License.7# See LICENSE in the root of the software repository for the full text of the License.
8# ============================================================================8# ============================================================================
9 9 
10-add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE convolution_backward ACLNNTYPE aclnn_exclude DEPENDENCIES matmul.common mat_mul_v3 batch_mat_mul_v3)10+add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE convolution_backward ACLNNTYPE aclnn_exclude DEPENDENCIES matmul.common mat_mul_v3 batch_mat_mul_v3 convolution_forward)
@@ -9,4 +9,4 @@
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10message(STATUS "=== Debug: start ops.pooling.avg_pool3_d.op_host.CMakeLists.txt ")10message(STATUS "=== Debug: start ops.pooling.avg_pool3_d.op_host.CMakeLists.txt ")
11 11 
12-add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE avg_pool3_d ACLNNTYPE aclnn_exclude DEPENDENCIES pool_3d_common rms_norm norm_common matmul.common batch_mat_mul_v3 mat_mul_v3)12+add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE avg_pool3_d ACLNNTYPE aclnn_exclude DEPENDENCIES pool_3d_common rms_norm norm_common)
@@ -9,4 +9,4 @@
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10message(STATUS "=== Debug: start ops.pooling.avg_pool3_d_grad.op_host.CMakeLists.txt ")10message(STATUS "=== Debug: start ops.pooling.avg_pool3_d_grad.op_host.CMakeLists.txt ")
11 11 
12-add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE avg_pool3_d_grad ACLNNTYPE aclnn_exclude DEPENDENCIES avg_pool3_d)12+add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE avg_pool3_d_grad ACLNNTYPE aclnn_exclude DEPENDENCIES avg_pool3_d convolution_backward)
@@ -116,6 +116,13 @@ private:
116 const uint64_t baseDo, const uint64_t baseHo, const uint64_t baseWo, const uint64_t baseDi,116 const uint64_t baseDo, const uint64_t baseHo, const uint64_t baseWo, const uint64_t baseDi,
117 const uint64_t baseHi, const uint64_t baseWi, const ge::DataType& dtype);117 const uint64_t baseHi, const uint64_t baseWi, const ge::DataType& dtype);
118 118 
119+ ge::graphStatus InitBaseParams(gert::Shape& gradShape, ge::DataType& dtype);
120+ void CalcShapeVars(const gert::Shape& gradShape, int64_t& ncShape, int64_t& ndhwShape, int64_t& cShape);
121+ void SetWorkspace(ge::DataType dtype, int64_t ncShape);
122+ void CalcCoreNumAndDetermineFlag(const AvgPool3DGradCubeCompileInfo* compileInfo,
123+ int64_t ncShape, int64_t ndhwShape, int64_t gradDim0);
124+ void DispatchTilingStrategy(uint64_t ubSizePlatform, ge::DataType dtype,
125+ int64_t cShape, int64_t ndhwShape);
119private:126private:
120 gert::TilingContext* tilingContext_ = nullptr;127 gert::TilingContext* tilingContext_ = nullptr;
121 AvgPool3dGradTilingParam tilingData_;128 AvgPool3dGradTilingParam tilingData_;
@@ -542,16 +549,53 @@ ge::graphStatus AvgPool3dGradTiling::Init()
542{549{
543 OP_LOGD(tilingContext_->GetNodeName(), "Tiling initing");550 OP_LOGD(tilingContext_->GetNodeName(), "Tiling initing");
544 auto compileInfo = static_cast<const AvgPool3DGradCubeCompileInfo*>(tilingContext_->GetCompileInfo());551 auto compileInfo = static_cast<const AvgPool3DGradCubeCompileInfo*>(tilingContext_->GetCompileInfo());
545- if (compileInfo == nullptr) {552+ OP_CHECK_IF(compileInfo == nullptr,
546- OP_LOGE(tilingContext_->GetNodeName(), "compile info is nullptr");553+ OP_LOGE(tilingContext_->GetNodeName(), "compile info is nullptr"),
547- return ge::GRAPH_FAILED;554+ return ge::GRAPH_FAILED);
555+
556+ gert::Shape gradShape;
557+ ge::DataType dtype;
558+ OP_CHECK_IF(InitBaseParams(gradShape, dtype) != ge::GRAPH_SUCCESS,
559+ OP_LOGE(tilingContext_->GetNodeName(), "InitBaseParams failed"),
560+ return ge::GRAPH_FAILED);
561+ 
562+ int64_t ndhwShape = 1;
563+ int64_t ncShape = 1;
564+ int64_t cShape = 1;
565+ CalcShapeVars(gradShape, ncShape, ndhwShape, cShape);
566+ 
567+ auto ret = InitDHW();
568+ if (ret != ge::GRAPH_SUCCESS) {
569+ return ret;
548 }570 }
549- auto gradShape = tilingContext_->GetInputShape(1)->GetStorageShape();571+ 
550- auto dtype = tilingContext_->GetInputDesc(1)->GetDataType();572+ SetWorkspace(dtype, ncShape);
573+ CalcCoreNumAndDetermineFlag(compileInfo, ncShape, ndhwShape, gradShape.GetDim(0));
574+ 
575+ OP_CHECK_IF(coreNum_ == 0UL,
576+ OP_LOGE(tilingContext_->GetNodeName(), "CoreNum is zero, error."),
577+ return ge::GRAPH_FAILED);
578+ uint64_t ubSizePlatform = compileInfo->ub_size;
579+ DispatchTilingStrategy(ubSizePlatform, dtype, cShape, ndhwShape);
580+ if (dtype == ge::DT_BF16 || dtype == ge::DT_FLOAT16) {
581+ int64_t inDhwShape = static_cast<int64_t>(inDHW_.d * inDHW_.h * inDHW_.w);
582+ Tiling4CastCopyOut(static_cast<int64_t>(ubSizePlatform), ncShape, inDhwShape);
583+ }
584+ 
585+ SetTilingKey(dtype);
586+ return ge::GRAPH_SUCCESS;
587+}
588+ 
589+ge::graphStatus AvgPool3dGradTiling::InitBaseParams(gert::Shape& gradShape, ge::DataType& dtype)
590+{
591+ gradShape = tilingContext_->GetInputShape(1)->GetStorageShape();
592+ dtype = tilingContext_->GetInputDesc(1)->GetDataType();
551 auto attrs = tilingContext_->GetAttrs();593 auto attrs = tilingContext_->GetAttrs();
594+
552 countIncludePad_ = static_cast<uint64_t>(*attrs->GetAttrPointer<bool>(COUNT_IDX));595 countIncludePad_ = static_cast<uint64_t>(*attrs->GetAttrPointer<bool>(COUNT_IDX));
553 divisorOverride_ = static_cast<int64_t>(*attrs->GetAttrPointer<int>(DIVISOR_IDX));596 divisorOverride_ = static_cast<int64_t>(*attrs->GetAttrPointer<int>(DIVISOR_IDX));
554 dataFormat_ = attrs->GetStr(FORMAT_IDX);597 dataFormat_ = attrs->GetStr(FORMAT_IDX);
598+ 
555 if (dataFormat_ != "NDHWC" && dataFormat_ != "NCDHW") {599 if (dataFormat_ != "NDHWC" && dataFormat_ != "NCDHW") {
556 OP_LOGE(tilingContext_->GetNodeName(), "invalid data_format, should be NCDHW or NDHWC");600 OP_LOGE(tilingContext_->GetNodeName(), "invalid data_format, should be NCDHW or NDHWC");
557 return ge::GRAPH_FAILED;601 return ge::GRAPH_FAILED;
@@ -561,76 +605,87 @@ ge::graphStatus AvgPool3dGradTiling::Init()
561 OP_LOGE(tilingContext_->GetNodeName(), "gradShape dim num is not 5");605 OP_LOGE(tilingContext_->GetNodeName(), "gradShape dim num is not 5");
562 return ge::GRAPH_FAILED;606 return ge::GRAPH_FAILED;
563 }607 }
608+ return ge::GRAPH_SUCCESS;
609+}
564 610 
565- int64_t ndhwShape = 1;611+void AvgPool3dGradTiling::CalcShapeVars(const gert::Shape& gradShape, int64_t& ncShape, int64_t& ndhwShape, int64_t& cShape)
566- int64_t ncShape = 1;612+{
567- int64_t cShape = 1;
568 if (dataFormat_ == "NDHWC") {613 if (dataFormat_ == "NDHWC") {
569 cShape = gradShape.GetDim(GRAD_SHAPE - 1);614 cShape = gradShape.GetDim(GRAD_SHAPE - 1);
615+ ndhwShape = 1;
570 for (int i = NDHWC_N_DIM; i < NDHWC_D_DIM + ATTR_SIZE; i++) {616 for (int i = NDHWC_N_DIM; i < NDHWC_D_DIM + ATTR_SIZE; i++) {
571 ndhwShape *= gradShape.GetDim(i);617 ndhwShape *= gradShape.GetDim(i);
572 }618 }
573 ncShape = gradShape.GetDim(0) * cShape;619 ncShape = gradShape.GetDim(0) * cShape;
574 } else {620 } else {
621+ // NCDHW
575 N_ = gradShape.GetDim(0);622 N_ = gradShape.GetDim(0);
576 C_ = gradShape.GetDim(1);623 C_ = gradShape.GetDim(1);
577 ncShape = static_cast<int64_t>(N_ * C_);624 ncShape = static_cast<int64_t>(N_ * C_);
578 }625 }
626+}
579 627 
580- auto ret = InitDHW();628+void AvgPool3dGradTiling::SetWorkspace(ge::DataType dtype, int64_t ncShape)
581- if (ret != ge::GRAPH_SUCCESS) {629+{
582- return ret;
583- }
584 size_t sysWorkspaceSize = 16UL * 1024UL * 1024UL;630 size_t sysWorkspaceSize = 16UL * 1024UL * 1024UL;
585 size_t castWorkspaceSize = 0;631 size_t castWorkspaceSize = 0;
586- size_t* currentWorkSpace = tilingContext_->GetWorkspaceSizes(1);632+
587 if (dtype == ge::DT_BF16 || dtype == ge::DT_FLOAT16) {633 if (dtype == ge::DT_BF16 || dtype == ge::DT_FLOAT16) {
588- castWorkspaceSize = static_cast<size_t>(inDHW_.d) * static_cast<size_t>(inDHW_.h) *634+ size_t totalElements = static_cast<size_t>(inDHW_.d) * static_cast<size_t>(inDHW_.h) *
589- static_cast<size_t>(inDHW_.w) * static_cast<size_t>(ncShape) * sizeof(float);635+ static_cast<size_t>(inDHW_.w) * static_cast<size_t>(ncShape);
636+ castWorkspaceSize = totalElements * sizeof(float);
590 }637 }
591- sysWorkspaceSize += castWorkspaceSize;638+ 
592- currentWorkSpace[0] = sysWorkspaceSize;639+ size_t* currentWorkSpace = tilingContext_->GetWorkspaceSizes(1);
593- // compute corenum + normalCoreNCNum + lastCoreNCNum640+ currentWorkSpace[0] = sysWorkspaceSize + castWorkspaceSize;
641+}
642+ 
643+void AvgPool3dGradTiling::CalcCoreNumAndDetermineFlag(const AvgPool3DGradCubeCompileInfo* compileInfo,
644+ int64_t ncShape, int64_t ndhwShape, int64_t gradDim0)
645+{
594 if (dataFormat_ == "NDHWC") {646 if (dataFormat_ == "NDHWC") {
595 coreNum_ = std::min(compileInfo->core_num, static_cast<uint32_t>(ndhwShape));647 coreNum_ = std::min(compileInfo->core_num, static_cast<uint32_t>(ndhwShape));
596 } else {648 } else {
597- if (isOnlyT_ != static_cast<uint64_t>(0)) {649+ // NCDHW
598- coreNum_ = std::min(compileInfo->core_num, static_cast<uint32_t>(ncShape * outDHW_.d));650+ int64_t taskCount = (isOnlyT_ != 0) ? (ncShape * outDHW_.d) : (ncShape * outDHW_.d * outDHW_.h * outDHW_.w);
599- } else {651+ coreNum_ = std::min(compileInfo->core_num, static_cast<uint32_t>(taskCount));
600- coreNum_ =
601- std::min(compileInfo->core_num, static_cast<uint32_t>(ncShape * outDHW_.d * outDHW_.h * outDHW_.w));
602- }
603- }
604- if (dataFormat_ == "NCDHW" && isOnlyT_ == static_cast<uint64_t>(0)) {
605- isDetermine_ = 1UL;
606- } else if (tilingContext_->GetDeterministic() == 1) {
607- coreNum_ = 1UL;
608- isDetermine_ = 1UL;
609- }
610- if (coreNum_ == 0UL) {
611- OP_LOGE(tilingContext_->GetNodeName(), "coreNum is zero, error.");
612- return ge::GRAPH_FAILED;
613 }652 }
614 653 
615- // tiling for HW or C654+ bool isDeterministic = (tilingContext_->GetDeterministic() == 1);
616- uint64_t ubSizePlatform = compileInfo->ub_size;655+ if (!isDeterministic || isOverlap_ != 1) {
617- if ((isOnlyT_ == static_cast<uint64_t>(0)) && dataFormat_ == "NCDHW") {656+ return;
618- Tiling4Block(ubSizePlatform, dtype);657+ }
619- } else if ((isOnlyT_ != static_cast<uint64_t>(0)) && dataFormat_ == "NCDHW") {658+ 
620- Tiling4HWParam(ubSizePlatform, dtype);659+ // 进入确定性计算逻辑
660+ if (dataFormat_ == "NCDHW" && isOnlyT_ == 0) {
661+ isDetermine_ = 1UL;
621 } else {662 } else {
663+ // 此分支包含 (NDHWC) 或 (NCDHW && isOnlyT_ != 0)
664+ if (isOnlyT_ != 0) {
665+ coreNum_ = std::min(compileInfo->core_num, static_cast<uint32_t>(ncShape));
666+ } else {
667+ coreNum_ = std::min(compileInfo->core_num, static_cast<uint32_t>(gradDim0));
668+ }
669+ isDetermine_ = 1UL;
670+ }
671+}
672+ 
673+void AvgPool3dGradTiling::DispatchTilingStrategy(uint64_t ubSizePlatform, ge::DataType dtype,
674+ int64_t cShape, int64_t ndhwShape)
675+{
676+ if (dataFormat_ == "NCDHW") {
677+ if (isOnlyT_ == 0) {
678+ Tiling4Block(ubSizePlatform, dtype);
679+ } else {
680+ Tiling4HWParam(ubSizePlatform, dtype);
681+ }
682+ } else {
683+ // NDHWC
622 Tiling4CParam(ubSizePlatform, cShape, ndhwShape, dtype);684 Tiling4CParam(ubSizePlatform, cShape, ndhwShape, dtype);
623 }685 }
624- 
625- int64_t inDhwShape = static_cast<int64_t>(inDHW_.d * inDHW_.h * inDHW_.w);
626- if (dtype == ge::DT_BF16 || dtype == ge::DT_FLOAT16) {
627- Tiling4CastCopyOut(static_cast<int64_t>(ubSizePlatform), ncShape, inDhwShape);
628- }
629- // set tiling key
630- SetTilingKey(dtype);
631- return ge::GRAPH_SUCCESS;
632}686}
633 687 
688+ 
634ge::graphStatus AvgPool3dGradTiling::SetKernelTiling()689ge::graphStatus AvgPool3dGradTiling::SetKernelTiling()
635{690{
636 tilingContext_->SetBlockDim(coreNum_);691 tilingContext_->SetBlockDim(coreNum_);
@@ -19,6 +19,8 @@
19#include "opdev/tensor_view_utils.h"19#include "opdev/tensor_view_utils.h"
20#include "opdev/framework_op.h"20#include "opdev/framework_op.h"
21#include "aclnn_kernels/common/op_error_check.h"21#include "aclnn_kernels/common/op_error_check.h"
22+#include "opdev/platform.h"
23+#include "runtime/context.h"
22 24 
23#include "aclnn_kernels/contiguous.h"25#include "aclnn_kernels/contiguous.h"
24#include "level0/padv3.h"26#include "level0/padv3.h"
@@ -313,7 +315,23 @@ const aclTensor* TransGrad2CDHW(const aclTensor* gradOutput, aclOpExecutor* exec
313 int64_t depth = gradShape.GetDim(gradDimNum - 3);315 int64_t depth = gradShape.GetDim(gradDimNum - 3);
314 int64_t height = gradShape.GetDim(gradDimNum - 2);316 int64_t height = gradShape.GetDim(gradDimNum - 2);
315 int64_t weight = gradShape.GetDim(gradDimNum - 1);317 int64_t weight = gradShape.GetDim(gradDimNum - 1);
316- FVector<int64_t> reshapeVec = {num, mergeNC, depth, height, weight};318+ 
319+ uint32_t coreNum = GetCurrentPlatformInfo().GetVectorCoreNum();
CANN-robot
CANN-robotCANN-robot2025年12月26日

代码结构与可维护性: 函数TransGrad2CDHW中新增的确定性逻辑(第319-333行)与原始功能(reshape梯度tensor)耦合在一起,降低了代码的可读性和可维护性。该逻辑根据系统确定性配置和核心数调整reshape维度,属于性能优化策略,应单独提取为辅助函数。

问题类型: 代码结构与可维护性 文件路径: pooling/avg_pool3_d_grad/op_host/op_api/aclnn_avgpool3d_backward.cpp 行号: 319 问题代码:

uint32_t coreNum = GetCurrentPlatformInfo().GetVectorCoreNum();
int64_t usedCoreNum = 1;
int64_t deterministicValue = 0;
rtError_t retRts = rtCtxGetSysParamOpt(SYS_OPT_DETERMINISTIC, &deterministicValue);
if (retRts != RT_ERROR_NONE) {
    deterministicValue = 0;
}
if (deterministicValue != 0) {
    for (size_t i = coreNum;i >= 1;i--) {
        if (mergeNC % i == 0) {
            usedCoreNum = i;
            break;
        }
    }
}

修改建议:

将确定性逻辑提取到一个独立函数中,例如:int64_t GetUsedCoreNumForDeterministic(int64_t mergeNC); 并在TransGrad2CDHW中调用。

此评论由代码审查工具自动生成

likedislike
320+ int64_t usedCoreNum = 1;
321+ int64_t deterministicValue = 0;
322+ rtError_t retRts = rtCtxGetSysParamOpt(SYS_OPT_DETERMINISTIC, &deterministicValue);
323+ if (retRts != RT_ERROR_NONE) {
324+ deterministicValue = 0;
325+ }
326+ if (deterministicValue != 0) {
327+ for (size_t i = coreNum;i >= 1;i--) {
328+ if (mergeNC % i == 0) {
329+ usedCoreNum = i;
330+ break;
331+ }
332+ }
333+ }
334+ FVector<int64_t> reshapeVec = {usedCoreNum, mergeNC / usedCoreNum, depth, height, weight};
317 aclIntArray* reshapeArray = executor->AllocIntArray(reshapeVec.data(), reshapeVec.size());335 aclIntArray* reshapeArray = executor->AllocIntArray(reshapeVec.data(), reshapeVec.size());
318 CHECK_RET(reshapeArray != nullptr, nullptr);336 CHECK_RET(reshapeArray != nullptr, nullptr);
319 auto grad5hd = l0op::Reshape(gradOutput, reshapeArray, executor);337 auto grad5hd = l0op::Reshape(gradOutput, reshapeArray, executor);
@@ -55,11 +55,12 @@ const aclTensor* AvgPool3DGrad(
55 op::Shape outShape;55 op::Shape outShape;
56 outShape.SetDimNum(EXPECT_GRAD_SHAPE);56 outShape.SetDimNum(EXPECT_GRAD_SHAPE);
57 if (dataFormat == "NDHWC") {57 if (dataFormat == "NDHWC") {
58+ auto nSize = gradShape.GetDim(0);
58 auto ncSize = gradShape.GetDim(gradSize - 1);59 auto ncSize = gradShape.GetDim(gradSize - 1);
59 auto depth = selfShape.GetDim(selfSize - D_DIM_OFFSET);60 auto depth = selfShape.GetDim(selfSize - D_DIM_OFFSET);
60 auto height = selfShape.GetDim(selfSize - H_DIM_OFFSET);61 auto height = selfShape.GetDim(selfSize - H_DIM_OFFSET);
61 auto weight = selfShape.GetDim(selfSize - W_DIM_OFFSET);62 auto weight = selfShape.GetDim(selfSize - W_DIM_OFFSET);
62- outShape.SetDim(0, 1);63+ outShape.SetDim(0, nSize);
CANN-robot
CANN-robotCANN-robot2025年12月26日

代码结构与可维护性: 在dataFormat为'NDHWC'时,outShape.SetDim(0, nSize)使用了从gradShape获取的nSize,而outShape.SetDim(OUTW_DIM, ncSize)使用了gradShape的最后一个维度。这里存在潜在的逻辑不一致:当dataFormat为'NDHWC'时,gradOutput的shape应为[N, D, H, W, C],但代码将gradShape的最后一个维度赋给了outShape的OUTW_DIM(即第4维,对应W),这似乎与语义不符。OUTW_DIM常量定义为4,通常表示宽度维度,但在'NDHWC'格式下,输出outShape被构造为[N, D, H, W, C],其中第4维(OUTW_DIM)应该是通道C,而不是宽度W。这可能是命名或逻辑错误。

问题类型: 代码结构与可维护性 文件路径: pooling/avg_pool3_d_grad/op_host/op_api/avgpool3d_backward.cpp 行号: 63 问题代码:

outShape.SetDim(0, nSize);
outShape.SetDim(1, depth);
outShape.SetDim(OUTD_DIM, height);
outShape.SetDim(OUTH_DIM, weight);
outShape.SetDim(OUTW_DIM, ncSize);

修改建议:

1. 检查常量命名OUTD_DIM、OUTH_DIM、OUTW_DIM是否与dataFormat='NDHWC'时的输出shape语义一致。如果这些常量是基于'NCDHW'格式定义的,则应在'NDHWC'分支中重新解释或使用不同的常量。2. 添加注释说明在'NDHWC'格式下,输出shape各维度的含义(N, D, H, W, C)。3. 考虑将OUTW_DIM重命名为更通用的名称(如CHANNEL_DIM),或根据dataFormat动态计算索引。

此评论由代码审查工具自动生成

likedislike
63 outShape.SetDim(1, depth);64 outShape.SetDim(1, depth);
64 outShape.SetDim(OUTD_DIM, height);65 outShape.SetDim(OUTD_DIM, height);
65 outShape.SetDim(OUTH_DIM, weight);66 outShape.SetDim(OUTH_DIM, weight);
@@ -138,6 +138,9 @@ __aicore__ inline void KernelAvgPool3DGradCast<T>::ProcessAndCopyout()
138 for (auto i = index; i < indexEnd; ++i) {138 for (auto i = index; i < indexEnd; ++i) {
139 auto ubIndex = i - index;139 auto ubIndex = i - index;
140 this->ProcessPerLine(i, ubIndex);140 this->ProcessPerLine(i, ubIndex);
141+#if defined(DETERMINISTIC_MODE) && DETERMINISTIC_MODE == 1
142+ PipeBarrier<PIPE_MTE3>();
143+#endif
141 }144 }
142 SetFlag<HardEvent::V_MTE2>(this->eventIdV2Mte2);145 SetFlag<HardEvent::V_MTE2>(this->eventIdV2Mte2);
143 SetFlag<HardEvent::MTE3_V>(this->eventIdMte3ToV);146 SetFlag<HardEvent::MTE3_V>(this->eventIdMte3ToV);
@@ -16,6 +16,7 @@
16#include "op_api_ut_common/tensor_desc.h"16#include "op_api_ut_common/tensor_desc.h"
17#include "op_api_ut_common/scalar_desc.h"17#include "op_api_ut_common/scalar_desc.h"
18#include "op_api_ut_common/op_api_ut.h"18#include "op_api_ut_common/op_api_ut.h"
19+#include "opdev/platform.h"
19 20 
20#include "../../../op_host/op_api/aclnn_avgpool2d_backward.h"21#include "../../../op_host/op_api/aclnn_avgpool2d_backward.h"
21 22 
@@ -230,6 +231,7 @@ TEST_F(l2_avgpool2dbackward_test, ascend910B2_test_avgpool2dbackward_kernel_size
230// BF16,输入是四维,不支持的芯片插Mul, cubeMathType = 0 支持的走3d231// BF16,输入是四维,不支持的芯片插Mul, cubeMathType = 0 支持的走3d
231TEST_F(l2_avgpool2dbackward_test, ascend310P_test_avgpool2dbackwardbackward_global_avg_pool_bf16)232TEST_F(l2_avgpool2dbackward_test, ascend310P_test_avgpool2dbackwardbackward_global_avg_pool_bf16)
232{233{
234+ op::SocVersionManager versionManager(op::SocVersion::ASCEND310P);
233 vector<int64_t> vector_grad_output = {5, 4, 6, 6};235 vector<int64_t> vector_grad_output = {5, 4, 6, 6};
234 vector<int64_t> vector_self = {5, 4, 13, 13};236 vector<int64_t> vector_self = {5, 4, 13, 13};
235 vector<int64_t> vector_kernel_size = {3, 3};237 vector<int64_t> vector_kernel_size = {3, 3};