Merged
docs: 修复注释与文档不一致(fill_diagonal_v2、fill_v2、fills 等 文件注释) #6599
TangPCAdd on 19 days ago
docs: 修复注释与文档不一致(fill_diagonal_v2、fill_v2、fills 等 文件注释) #6599
Merged
Total: 5 files changed+58-64
| @@ -8,7 +8,7 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | /*! | 10 | /*! |
| 11 | - * \file test_fill_diagonal_v2_proto.cpp | 11 | + * \file test_fill_diagonal_v2_infershape.cpp |
| 12 | * \brief | 12 | * \brief |
| 13 | */ | 13 | */ |
| 14 | #include <gtest/gtest.h> | 14 | #include <gtest/gtest.h> |
| @@ -17,14 +17,10 @@ | |||
| 17 | #include "base/registry/op_impl_space_registry_v2.h" | 17 | #include "base/registry/op_impl_space_registry_v2.h" |
| 18 | 18 | ||
| 19 | class FillDiagonalV2Test : public testing::Test { | 19 | class FillDiagonalV2Test : public testing::Test { |
| 20 | - protected: | 20 | +protected: |
| 21 | - static void SetUpTestCase() { | 21 | + static void SetUpTestCase() { std::cout << "fill_diagonal_v2 Proto Test SetUp" << std::endl; } |
| 22 | - std::cout << "fill_diagonal_v2 Proto Test SetUp" << std::endl; | ||
| 23 | - } | ||
| 24 | 22 | ||
| 25 | - static void TearDownTestCase() { | 23 | + static void TearDownTestCase() { std::cout << "fill_diagonal_v2 Proto Test TearDown" << std::endl; } |
| 26 | - std::cout << "fill_diagonal_v2 Proto Test TearDown" << std::endl; | ||
| 27 | - } | ||
| 28 | }; | 24 | }; |
| 29 | 25 | ||
| 30 | static std::vector<int64_t> ToVectorForFillDiagonalV2(const gert::Shape& shape) | 26 | static std::vector<int64_t> ToVectorForFillDiagonalV2(const gert::Shape& shape) |
| @@ -39,36 +35,31 @@ static std::vector<int64_t> ToVectorForFillDiagonalV2(const gert::Shape& shape) | |||
| 39 | 35 | ||
| 40 | static void ExeTestCaseForFillDiagonalV2( | 36 | static void ExeTestCaseForFillDiagonalV2( |
| 41 | std::vector<std::vector<int64_t> > expectResults, | 37 | std::vector<std::vector<int64_t> > expectResults, |
| 42 | - const std::vector<gert::StorageShape>& inputShapes, // 存储所有输入StorageShape参数 | 38 | + const std::vector<gert::StorageShape>& inputShapes, // 存储所有输入StorageShape参数 |
| 43 | - const std::vector<ge::DataType>& dtypes, // 存储所有DataType参数 | 39 | + const std::vector<ge::DataType>& dtypes, // 存储所有DataType参数 |
| 44 | - gert::StorageShape& outStorageShape, | 40 | + gert::StorageShape& outStorageShape, ge::graphStatus testCaseResult = ge::GRAPH_SUCCESS, bool attr = false) |
| 45 | - ge::graphStatus testCaseResult = ge::GRAPH_SUCCESS, | ||
| 46 | - bool attr = false) | ||
| 47 | { | 41 | { |
| 48 | // 从vector中取出对应参数(保持原顺序) | 42 | // 从vector中取出对应参数(保持原顺序) |
| 49 | const auto& selfStorageShape = inputShapes[0]; | 43 | const auto& selfStorageShape = inputShapes[0]; |
| 50 | const auto& fillValueStorageShape = inputShapes[1]; | 44 | const auto& fillValueStorageShape = inputShapes[1]; |
| 51 | - | 45 | + |
| 52 | ge::DataType input1Dtype = dtypes[0]; | 46 | ge::DataType input1Dtype = dtypes[0]; |
| 53 | ge::DataType input2Dtype = dtypes[1]; | 47 | ge::DataType input2Dtype = dtypes[1]; |
| 54 | ge::DataType outputDtype = dtypes[2]; | 48 | ge::DataType outputDtype = dtypes[2]; |
| 55 | 49 | ||
| 56 | /* make infershape context */ | 50 | /* make infershape context */ |
| 57 | - std::vector<gert::Tensor *> inputTensors = { | 51 | + std::vector<gert::Tensor*> inputTensors = {(gert::Tensor*)&selfStorageShape, (gert::Tensor*)&fillValueStorageShape}; |
| 58 | - (gert::Tensor *)&selfStorageShape, | 52 | + std::vector<gert::StorageShape*> outputShapes = {&outStorageShape}; |
| 59 | - (gert::Tensor *)&fillValueStorageShape | ||
| 60 | - }; | ||
| 61 | - std::vector<gert::StorageShape *> outputShapes = {&outStorageShape}; | ||
| 62 | auto contextHolder = gert::InferShapeContextFaker() | 53 | auto contextHolder = gert::InferShapeContextFaker() |
| 63 | - .SetOpType("FillDiagonalV2") | 54 | + .SetOpType("FillDiagonalV2") |
| 64 | - .NodeIoNum(2, 1) | 55 | + .NodeIoNum(2, 1) |
| 65 | - .NodeInputTd(0, input1Dtype, ge::FORMAT_ND, ge::FORMAT_ND) | 56 | + .NodeInputTd(0, input1Dtype, ge::FORMAT_ND, ge::FORMAT_ND) |
| 66 | - .NodeInputTd(1, input2Dtype, ge::FORMAT_ND, ge::FORMAT_ND) | 57 | + .NodeInputTd(1, input2Dtype, ge::FORMAT_ND, ge::FORMAT_ND) |
| 67 | - .NodeOutputTd(0, outputDtype, ge::FORMAT_ND, ge::FORMAT_ND) | 58 | + .NodeOutputTd(0, outputDtype, ge::FORMAT_ND, ge::FORMAT_ND) |
| 68 | - .InputTensors(inputTensors) | 59 | + .InputTensors(inputTensors) |
| 69 | - .OutputShapes(outputShapes) | 60 | + .OutputShapes(outputShapes) |
| 70 | - .Attr("wrap", attr) | 61 | + .Attr("wrap", attr) |
| 71 | - .Build(); | 62 | + .Build(); |
| 72 | 63 | ||
| 73 | /* get infershape func */ | 64 | /* get infershape func */ |
| 74 | auto spaceRegistry = gert::DefaultOpImplSpaceRegistryV2::GetInstance().GetSpaceRegistry(); | 65 | auto spaceRegistry = gert::DefaultOpImplSpaceRegistryV2::GetInstance().GetSpaceRegistry(); |
| @@ -88,13 +79,13 @@ TEST_F(FillDiagonalV2Test, fill_diagonal_v2_infer_shape) | |||
| 88 | 79 | ||
| 89 | // 用vector存储同类型参数(顺序与原参数列表一致) | 80 | // 用vector存储同类型参数(顺序与原参数列表一致) |
| 90 | std::vector<gert::StorageShape> inputShapes = { | 81 | std::vector<gert::StorageShape> inputShapes = { |
| 91 | - {{size1, size1}, {size1, size1}}, // self_shape | 82 | + {{size1, size1}, {size1, size1}}, // self_shape |
| 92 | - {{size1, size1}, {size1, size1}} // fill_value_shape | 83 | + {{size1, size1}, {size1, size1}} // fill_value_shape |
| 93 | }; | 84 | }; |
| 94 | std::vector<ge::DataType> dtypes = { | 85 | std::vector<ge::DataType> dtypes = { |
| 95 | - ge::DT_FLOAT16, // input1Dtype | 86 | + ge::DT_FLOAT16, // input1Dtype |
| 96 | - ge::DT_FLOAT, // input2Dtype | 87 | + ge::DT_FLOAT, // input2Dtype |
| 97 | - ge::DT_FLOAT16 // outputDtype | 88 | + ge::DT_FLOAT16 // outputDtype |
| 98 | }; | 89 | }; |
| 99 | 90 | ||
| 100 | std::vector<int64_t> expectResult = {size1, size1}; | 91 | std::vector<int64_t> expectResult = {size1, size1}; |
| @@ -102,4 +93,4 @@ TEST_F(FillDiagonalV2Test, fill_diagonal_v2_infer_shape) | |||
| 102 | bool attr = false; | 93 | bool attr = false; |
| 103 | // 简化后的函数调用 | 94 | // 简化后的函数调用 |
| 104 | ExeTestCaseForFillDiagonalV2({expectResult}, inputShapes, dtypes, outStorageShape, ge::GRAPH_SUCCESS, attr); | 95 | ExeTestCaseForFillDiagonalV2({expectResult}, inputShapes, dtypes, outStorageShape, ge::GRAPH_SUCCESS, attr); |
| 105 | -} | 96 | +} |
| @@ -26,20 +26,20 @@ struct FillDiagonalV2TilingData { | |||
| 26 | 26 | ||
| 27 | #pragma pack() | 27 | #pragma pack() |
| 28 | 28 | ||
| 29 | -#define CONVERT_TILING_DATA(tilingStruct, tilingDataPointer, tilingPointer) \ | 29 | +#define CONVERT_TILING_DATA(tilingStruct, tilingDataPointer, tilingPointer) \ |
| 30 | - __ubuf__ tilingStruct* tilingDataPointer = \ | 30 | + __ubuf__ tilingStruct* tilingDataPointer = reinterpret_cast<__ubuf__ tilingStruct*>( \ |
| 31 | - reinterpret_cast<__ubuf__ tilingStruct*>((__ubuf__ uint8_t*)(tilingPointer)); | 31 | + (__ubuf__ uint8_t*)(tilingPointer)); |
| 32 | 32 | ||
| 33 | #define INIT_TILING_DATA(tilingStruct, tilingDataPointer, tilingPointer) \ | 33 | #define INIT_TILING_DATA(tilingStruct, tilingDataPointer, tilingPointer) \ |
| 34 | - CONVERT_TILING_DATA(tilingStruct, tilingDataPointer, tilingPointer); | 34 | + CONVERT_TILING_DATA(tilingStruct, tilingDataPointer, tilingPointer); |
| 35 | 35 | ||
| 36 | -#define GET_TILING_DATA(tilingData, tilingPointer) \ | 36 | +#define GET_TILING_DATA(tilingData, tilingPointer) \ |
| 37 | - FillDiagonalV2TilingData tilingData; \ | 37 | + FillDiagonalV2TilingData tilingData; \ |
| 38 | - INIT_TILING_DATA(FillDiagonalV2TilingData, tilingDataPointer, tilingPointer); \ | 38 | + INIT_TILING_DATA(FillDiagonalV2TilingData, tilingDataPointer, tilingPointer); \ |
| 39 | - (tilingData).totalLength = tilingDataPointer->totalLength; \ | 39 | + (tilingData).totalLength = tilingDataPointer->totalLength; \ |
| 40 | - (tilingData).step = tilingDataPointer->step; \ | 40 | + (tilingData).step = tilingDataPointer->step; \ |
| 41 | - (tilingData).end = tilingDataPointer->end; \ | 41 | + (tilingData).end = tilingDataPointer->end; \ |
| 42 | - (tilingData).ubSize = tilingDataPointer->ubSize; \ | 42 | + (tilingData).ubSize = tilingDataPointer->ubSize; \ |
| 43 | - (tilingData).blockLength = tilingDataPointer->blockLength; \ | 43 | + (tilingData).blockLength = tilingDataPointer->blockLength; \ |
| 44 | - (tilingData).lastBlockLength = tilingDataPointer->lastBlockLength; | 44 | + (tilingData).lastBlockLength = tilingDataPointer->lastBlockLength; |
| 45 | -#endif // _FAST_OP_TEST_FILL_DIAGONAL_TILING_H_ | 45 | +#endif // _FAST_OP_TEST_FILL_DIAGONAL_V2_TILING_H_ |
| @@ -42,4 +42,4 @@ REG_OP(FillV2) | |||
| 42 | .OP_END_FACTORY_REG(FillV2) | 42 | .OP_END_FACTORY_REG(FillV2) |
| 43 | #endif | 43 | #endif |
| 44 | } // namespace ge | 44 | } // namespace ge |
| 45 | -#endif // OP_PROTO_FILL_V2_H_ | 45 | +#endif // FILL_V2_PROTO_H_ |
| @@ -9,7 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | /*! | 11 | /*! |
| 12 | - * \file test_fills_proto.cpp | 12 | + * \file test_fills_infershape.cpp |
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| @@ -19,22 +19,25 @@ | |||
| 19 | #include "infershape_case_executor.h" | 19 | #include "infershape_case_executor.h" |
| 20 | 20 | ||
| 21 | class FillsInfershape : public testing::Test { | 21 | class FillsInfershape : public testing::Test { |
| 22 | - protected: | 22 | +protected: |
| 23 | - static void SetUpTestCase() { | 23 | + static void SetUpTestCase() { std::cout << "fills Proto Test SetUp" << std::endl; } |
| 24 | - std::cout << "fills Proto Test SetUp" << std::endl; | ||
| 25 | - } | ||
| 26 | 24 | ||
| 27 | - static void TearDownTestCase() { | 25 | + static void TearDownTestCase() { std::cout << "fills Proto Test TearDown" << std::endl; } |
| 28 | - std::cout << "fills Proto Test TearDown" << std::endl; | ||
| 29 | - } | ||
| 30 | }; | 26 | }; |
| 31 | 27 | ||
| 32 | TEST_F(FillsInfershape, fills_infershape_diff_test) | 28 | TEST_F(FillsInfershape, fills_infershape_diff_test) |
| 33 | { | 29 | { |
| 34 | - gert::InfershapeContextPara infershapeContextPara("Fills", | 30 | + gert::InfershapeContextPara infershapeContextPara( |
| 35 | - {{{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},}, | 31 | + "Fills", |
| 36 | - {{{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},}, | 32 | + { |
| 37 | - {gert::InfershapeContextPara::OpAttr("value", Ops::Math::AnyValue::CreateFrom<float>(1.5))}); | 33 | + {{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND}, |
| 38 | - std::vector<std::vector<int64_t>> expectOutputShape = {{3, 4},}; | 34 | + }, |
| 35 | + { | ||
| 36 | + {{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 37 | + }, | ||
| 38 | + {gert::InfershapeContextPara::OpAttr("value", Ops::Math::AnyValue::CreateFrom<float>(1.5))}); | ||
| 39 | + std::vector<std::vector<int64_t>> expectOutputShape = { | ||
| 40 | + {3, 4}, | ||
| 41 | + }; | ||
| 39 | ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape); | 42 | ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape); |
| 40 | -} | 43 | +} |
| @@ -40,4 +40,4 @@ REG_OP(IdentityN) | |||
| 40 | DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE, DT_STRING})) | 40 | DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE, DT_STRING})) |
| 41 | .OP_END_FACTORY_REG(IdentityN) | 41 | .OP_END_FACTORY_REG(IdentityN) |
| 42 | } // namespace ge | 42 | } // namespace ge |
| 43 | -#endif // SHAPE_N_PROTO_H_ | 43 | +#endif // IDENTITY_N_PROTO_H_ |