Merged
reducemean新增batch一致性 #3646
sunzhongwen1Add on Jun 30
reducemean新增batch一致性 #3646
Merged
Total: 3 files changed+27-24
| @@ -28,10 +28,10 @@ using namespace Ops::Base; | |||
| 28 | namespace optiling { | 28 | namespace optiling { |
| 29 | static constexpr int32_t SIZE4 = 4; | 29 | static constexpr int32_t SIZE4 = 4; |
| 30 | static constexpr int32_t SIZE2 = 2; | 30 | static constexpr int32_t SIZE2 = 2; |
| 31 | +static constexpr int32_t BATCH_INVARIANT_LEVEL = 3; | ||
| 31 | 32 | ||
| 32 | -static ge::graphStatus DoTilingAscendC( | 33 | +static ge::graphStatus DoTilingAscendC(gert::TilingContext* context, const ReduceOpCompileInfo* compileInfo, |
| 33 | - gert::TilingContext* context, const ReduceOpCompileInfo* compileInfo, ReduceOpInputParam& opInput, | 34 | + ReduceOpInputParam& opInput, ReduceTilingKey& key) |
| 34 | - ReduceTilingKey& key) | ||
| 35 | { | 35 | { |
| 36 | ge::graphStatus status = ge::GRAPH_FAILED; | 36 | ge::graphStatus status = ge::GRAPH_FAILED; |
| 37 | 37 | ||
| @@ -41,11 +41,10 @@ static ge::graphStatus DoTilingAscendC( | |||
| 41 | status = Tiling4ReduceOp<ReduceMean::ReduceMeanDag<half, float>::OpDag>(context, opInput, key, compileInfo); | 41 | status = Tiling4ReduceOp<ReduceMean::ReduceMeanDag<half, float>::OpDag>(context, opInput, key, compileInfo); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | - OP_CHECK_IF( | 44 | + OP_CHECK_IF((status == ge::GRAPH_FAILED), |
| 45 | - (status == ge::GRAPH_FAILED), | 45 | + OP_LOGE_FOR_INVALID_DTYPE(context->GetNodeName(), "x", Ops::Base::ToString(opInput.inputDtype).c_str(), |
| 46 | - OP_LOGE_FOR_INVALID_DTYPE( | 46 | + "bfloat16, float16 or float"), |
| 47 | - context->GetNodeName(), "x", Ops::Base::ToString(opInput.inputDtype).c_str(), "bfloat16, float16 or float"), | 47 | + return ge::GRAPH_FAILED); |
| 48 | - return ge::GRAPH_FAILED); | ||
| 49 | return status; | 48 | return status; |
| 50 | } | 49 | } |
| 51 | 50 | ||
| @@ -54,9 +53,13 @@ static ge::graphStatus Tiling4ReduceMean(gert::TilingContext* context) | |||
| 54 | auto compile_info = reinterpret_cast<const ReduceOpCompileInfo*>(context->GetCompileInfo()); | 53 | auto compile_info = reinterpret_cast<const ReduceOpCompileInfo*>(context->GetCompileInfo()); |
| 55 | OP_CHECK_NULL_WITH_CONTEXT(context, compile_info); | 54 | OP_CHECK_NULL_WITH_CONTEXT(context, compile_info); |
| 56 | ReduceOpInputParam opInput; | 55 | ReduceOpInputParam opInput; |
| 57 | - OP_CHECK_IF( | 56 | + ReduceTilingKey key; |
| 58 | - (ReduceOpTmpl::GetInputParam(context, opInput, 0, 1, 0) == ge::GRAPH_FAILED), | 57 | + // 获取确定性级别,如果为3开启batch一致性 |
| 59 | - OP_LOGE(context->GetNodeName(), "ReduceOp get x input param failed"), return ge::GRAPH_FAILED); | 58 | + if (context->GetDeterministicLevel() == BATCH_INVARIANT_LEVEL) { |
| 59 | + key.batchInvariant = 1; | ||
| 60 | + } | ||
| 61 | + OP_CHECK_IF((ReduceOpTmpl::GetInputParam(context, opInput, 0, 1, 0, key) == ge::GRAPH_FAILED), | ||
| 62 | + OP_LOGE(context->GetNodeName(), "ReduceOp get x input param failed"), return ge::GRAPH_FAILED); | ||
| 60 | 63 | ||
| 61 | if (opInput.axes.empty()) { | 64 | if (opInput.axes.empty()) { |
| 62 | auto attrs = context->GetAttrs(); | 65 | auto attrs = context->GetAttrs(); |
| @@ -70,15 +73,14 @@ static ge::graphStatus Tiling4ReduceMean(gert::TilingContext* context) | |||
| 70 | } | 73 | } |
| 71 | } | 74 | } |
| 72 | 75 | ||
| 73 | - ReduceTilingKey key; | 76 | + OP_CHECK_IF((DoTilingAscendC(context, compile_info, opInput, key) == ge::GRAPH_FAILED), |
| 74 | - OP_CHECK_IF( | 77 | + OP_LOGE(context->GetNodeName(), "DoTiling Failed for ReduceMean"), return ge::GRAPH_FAILED); |
| 75 | - (DoTilingAscendC(context, compile_info, opInput, key) == ge::GRAPH_FAILED), | ||
| 76 | - OP_LOGE(context->GetNodeName(), "DoTiling Failed for ReduceMean"), return ge::GRAPH_FAILED); | ||
| 77 | uint64_t tilingKey; | 78 | uint64_t tilingKey; |
| 78 | GEN_REDUCE_TILING_KEY(tilingKey, key); | 79 | GEN_REDUCE_TILING_KEY(tilingKey, key); |
| 79 | - OP_LOGI( | 80 | + OP_LOGI(context->GetNodeName(), |
| 80 | - context->GetNodeName(), "patternID:%u, loopARCount:%u, loopInnerARCount:%u, isContiguous:%d, Tiling Key is:%lu", | 81 | + "patternID:%u, loopARCount:%u, loopInnerARCount:%u, isContiguous:%d, batchInvariant:%d, Tiling Key is:%lu", |
| 81 | - key.patternID, key.loopARCount, key.loopInnerARCount, key.isContiguous ? 1 : 0, tilingKey); | 82 | + key.patternID, key.loopARCount, key.loopInnerARCount, key.isContiguous ? 1 : 0, key.batchInvariant ? 1 : 0, |
| 83 | + tilingKey); | ||
| 82 | context->SetTilingKey(tilingKey); | 84 | context->SetTilingKey(tilingKey); |
| 83 | return ge::GRAPH_SUCCESS; | 85 | return ge::GRAPH_SUCCESS; |
| 84 | } | 86 | } |
| @@ -17,9 +17,9 @@ | |||
| 17 | #define _REDUCE_MEAN_TILING_KEY_H_ | 17 | #define _REDUCE_MEAN_TILING_KEY_H_ |
| 18 | 18 | ||
| 19 | #include "atvoss/reduce/reduce_tiling_key_decl.h" | 19 | #include "atvoss/reduce/reduce_tiling_key_decl.h" |
| 20 | -#include "atvoss/reduce/reduce_tiling_key_decl_non_contiguous.h" | 20 | +#include "atvoss/reduce/reduce_tiling_key_decl_batch_invariant.h" |
| 21 | -#include "atvoss/reduce/reduce_tiling_key_sel_non_contiguous.h" | 21 | +#include "atvoss/reduce/reduce_tiling_key_sel_batch_invariant.h" |
| 22 | 22 | ||
| 23 | -ASCENDC_TPL_ARGS_DECL(ReduceMean, REDUCE_TPL_KEY_DECL_NON_CONTIGUOUS()); | 23 | +ASCENDC_TPL_ARGS_DECL(ReduceMean, REDUCE_TPL_KEY_DECL_BATCH_INVARIANT()); |
| 24 | 24 | ||
| 25 | -#endif | 25 | +#endif |
| @@ -29,6 +29,7 @@ static constexpr int32_t SIZE8 = 8; | |||
| 29 | static constexpr int32_t SIZE4 = 4; | 29 | static constexpr int32_t SIZE4 = 4; |
| 30 | static constexpr int32_t SIZE2 = 2; | 30 | static constexpr int32_t SIZE2 = 2; |
| 31 | static constexpr int32_t SIZE1 = 1; | 31 | static constexpr int32_t SIZE1 = 1; |
| 32 | +static constexpr int32_t BATCH_INVARIANT_LEVEL = 3; | ||
| 32 | static ge::graphStatus DoTiling(gert::TilingContext* context, ReduceOpInputParam& opInput, ReduceTilingKey& key) | 33 | static ge::graphStatus DoTiling(gert::TilingContext* context, ReduceOpInputParam& opInput, ReduceTilingKey& key) |
| 33 | { | 34 | { |
| 34 | ge::graphStatus status = ge::GRAPH_FAILED; | 35 | ge::graphStatus status = ge::GRAPH_FAILED; |
| @@ -56,8 +57,8 @@ static ge::graphStatus Tiling4ReduceSum(gert::TilingContext* context) | |||
| 56 | 57 | ||
| 57 | ReduceOpInputParam opInput; | 58 | ReduceOpInputParam opInput; |
| 58 | ReduceTilingKey key; | 59 | ReduceTilingKey key; |
| 59 | - // 获取确定性级别,如果为2(暂定)开启batch一致性 | 60 | + // 获取确定性级别,如果为3开启batch一致性 |
| 60 | - if (context->GetDeterministicLevel() == 2) { | 61 | + if (context->GetDeterministicLevel() == BATCH_INVARIANT_LEVEL) { |
| 61 | key.batchInvariant = 1; | 62 | key.batchInvariant = 1; |
| 62 | } | 63 | } |
| 63 | OP_CHECK_IF((ReduceOpTmpl::GetInputParam(context, opInput, 0, 1, 0, key) == ge::GRAPH_FAILED), | 64 | OP_CHECK_IF((ReduceOpTmpl::GetInputParam(context, opInput, 0, 1, 0, key) == ge::GRAPH_FAILED), |