已合并
fix: 删除硬编码DT_MAX边界值的测试用例&&gaf用例修复 #4846
yelongjian创建于 11 小时前
fix: 删除硬编码DT_MAX边界值的测试用例&&gaf用例修复 #4846
已合并
共 6 个文件变更+13-24
| @@ -439,10 +439,8 @@ class AscGraphAttr : public AfAttrGroupsBase { | |||
| 439 | // [HI] 图上的轴 | 439 | // [HI] 图上的轴 |
| 440 | std::vector<AxisPtr> axis; | 440 | std::vector<AxisPtr> axis; |
| 441 | 441 | ||
| 442 | - | ||
| 443 | // 图级调度信息。axis 在进入优化流程前可同步到各节点的 sched.axis。 | 442 | // 图级调度信息。axis 在进入优化流程前可同步到各节点的 sched.axis。 |
| 444 | GraphSchedInfo sched{}; | 443 | GraphSchedInfo sched{}; |
| 445 | - | ||
| 446 | 444 | ||
| 447 | // TODO 待正式方案后删除 | 445 | // TODO 待正式方案后删除 |
| 448 | TransInfoRoadOfGraph trans_info_road; | 446 | TransInfoRoadOfGraph trans_info_road; |
| @@ -169,9 +169,6 @@ target_compile_definitions(autofuse PRIVATE | |||
| 169 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 | 169 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 |
| 170 | google=ascend_private | 170 | google=ascend_private |
| 171 | AUTOFUSE_USE_GE_METADEF | 171 | AUTOFUSE_USE_GE_METADEF |
| 172 | - # Keep the test-only autofuse library ABI-compatible with the external | ||
| 173 | - # CANN AscIR library until the matching package is available. | ||
| 174 | - AUTOFUSE_ST_COMPAT_CANN | ||
| 175 | ) | 172 | ) |
| 176 | 173 | ||
| 177 | target_include_directories(autofuse PUBLIC | 174 | target_include_directories(autofuse PUBLIC |
| @@ -29,10 +29,6 @@ target_compile_definitions(autofusion_st PRIVATE | |||
| 29 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 | 29 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 |
| 30 | google=ascend_private | 30 | google=ascend_private |
| 31 | AUTOFUSE_USE_GE_METADEF | 31 | AUTOFUSE_USE_GE_METADEF |
| 32 | - # The ST target currently links a CANN AscIR library with the old | ||
| 33 | - # AscGraphAttr layout. Keep this test target ABI-compatible until the | ||
| 34 | - # matching CANN package is available. | ||
| 35 | - AUTOFUSE_ST_COMPAT_CANN | ||
| 36 | ) | 32 | ) |
| 37 | 33 | ||
| 38 | target_compile_options(autofusion_st PRIVATE ${ASCGEN_DT_COMPILE_OPTION} | 34 | target_compile_options(autofusion_st PRIVATE ${ASCGEN_DT_COMPILE_OPTION} |
| @@ -25,9 +25,6 @@ target_compile_definitions(autofusion_ut PRIVATE | |||
| 25 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 | 25 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 |
| 26 | google=ascend_private | 26 | google=ascend_private |
| 27 | AUTOFUSE_USE_GE_METADEF | 27 | AUTOFUSE_USE_GE_METADEF |
| 28 | - # Keep this test executable ABI-compatible with the external CANN | ||
| 29 | - # AscIR library, just like the shared test autofuse target. | ||
| 30 | - AUTOFUSE_ST_COMPAT_CANN | ||
| 31 | ) | 28 | ) |
| 32 | 29 | ||
| 33 | target_compile_options(autofusion_ut PRIVATE ${ASCGEN_DT_COMPILE_OPTION} | 30 | target_compile_options(autofusion_ut PRIVATE ${ASCGEN_DT_COMPILE_OPTION} |
| @@ -149,12 +149,6 @@ def test_tensor_desc_rejects_invalid_data_type(data_type): | |||
| 149 | TensorDesc(None, data_type) | 149 | TensorDesc(None, data_type) |
| 150 | 150 | ||
| 151 | 151 | ||
| 152 | - | ||
| 153 | -def test_tensor_desc_rejects_data_type_boundary(): | ||
| 154 | - with pytest.raises(ValueError, match="less than DataType.DT_MAX"): | ||
| 155 | - TensorDesc(None, DataType.DT_MAX) | ||
| 156 | - | ||
| 157 | - | ||
| 158 | 152 | ||
| 159 | def test_tensor_desc_shape_view_expires_with_owner(): | 153 | def test_tensor_desc_shape_view_expires_with_owner(): |
| 160 | desc = TensorDesc([1], DataType.DT_FLOAT) | 154 | desc = TensorDesc([1], DataType.DT_FLOAT) |
| @@ -778,8 +778,10 @@ TEST_F(InferenceRuleUtest, InvalidDtype1) { | |||
| 778 | 778 | ||
| 779 | const auto handle = ge::DtypeInferenceRule::FromJsonString(ctx_maker.Str()); | 779 | const auto handle = ge::DtypeInferenceRule::FromJsonString(ctx_maker.Str()); |
| 780 | ASSERT_NE(handle, nullptr); | 780 | ASSERT_NE(handle, nullptr); |
| 781 | - ASSERT_EQ(handle->Error(), | 781 | + std::string expected = "Element 28 in 'dtype' field is out of range [0," + |
| 782 | - "Element 28 in 'dtype' field is out of range [0,43(DT_MAX)) and cannot be 28(DT_UNDEFINED)."); | 782 | + std::to_string(static_cast<int>(ge::DataType::DT_MAX)) + |
| 783 | + "(DT_MAX)) and cannot be 28(DT_UNDEFINED)."; | ||
| 784 | + ASSERT_EQ(handle->Error(), expected); | ||
| 783 | } | 785 | } |
| 784 | 786 | ||
| 785 | TEST_F(InferenceRuleUtest, InvalidDtype2) { | 787 | TEST_F(InferenceRuleUtest, InvalidDtype2) { |
| @@ -788,8 +790,11 @@ TEST_F(InferenceRuleUtest, InvalidDtype2) { | |||
| 788 | 790 | ||
| 789 | const auto handle = ge::DtypeInferenceRule::FromJsonString(ctx_maker.Str()); | 791 | const auto handle = ge::DtypeInferenceRule::FromJsonString(ctx_maker.Str()); |
| 790 | ASSERT_NE(handle, nullptr); | 792 | ASSERT_NE(handle, nullptr); |
| 791 | - ASSERT_EQ(handle->Error(), | 793 | + std::string expected = "Element " + std::to_string(static_cast<int>(ge::DataType::DT_MAX)) + |
| 792 | - "Element 43 in 'dtype' field is out of range [0,43(DT_MAX)) and cannot be 28(DT_UNDEFINED)."); | 794 | + " in 'dtype' field is out of range [0," + |
| 795 | + std::to_string(static_cast<int>(ge::DataType::DT_MAX)) + "(DT_MAX)) and cannot be " + | ||
| 796 | + std::to_string(static_cast<int>(ge::DataType::DT_UNDEFINED)) + "(DT_UNDEFINED)."; | ||
| 797 | + ASSERT_EQ(handle->Error(), expected); | ||
| 793 | } | 798 | } |
| 794 | 799 | ||
| 795 | TEST_F(InferenceRuleUtest, InvalidDtype3) { | 800 | TEST_F(InferenceRuleUtest, InvalidDtype3) { |
| @@ -798,8 +803,10 @@ TEST_F(InferenceRuleUtest, InvalidDtype3) { | |||
| 798 | 803 | ||
| 799 | const auto handle = ge::DtypeInferenceRule::FromJsonString(ctx_maker.Str()); | 804 | const auto handle = ge::DtypeInferenceRule::FromJsonString(ctx_maker.Str()); |
| 800 | ASSERT_NE(handle, nullptr); | 805 | ASSERT_NE(handle, nullptr); |
| 801 | - ASSERT_EQ(handle->Error(), | 806 | + std::string expected = "Element -1 in 'dtype' field is out of range [0," + |
| 802 | - "Element -1 in 'dtype' field is out of range [0,43(DT_MAX)) and cannot be 28(DT_UNDEFINED)."); | 807 | + std::to_string(static_cast<int>(ge::DataType::DT_MAX)) + "(DT_MAX)) and cannot be " + |
| 808 | + std::to_string(static_cast<int>(ge::DataType::DT_UNDEFINED)) + "(DT_UNDEFINED)."; | ||
| 809 | + ASSERT_EQ(handle->Error(), expected); | ||
| 803 | } | 810 | } |
| 804 | 811 | ||
| 805 | TEST_F(InferenceRuleUtest, DtypesFormatError) { | 812 | TEST_F(InferenceRuleUtest, DtypesFormatError) { |