已合并
update: 更新文件 matmul_custom.cpp #534
chenmingyu创建于 8月5日
update: 更新文件 matmul_custom.cpp #534
已合并
共 1 个文件变更+6-6
Mtutorials/ascendc_operator_development/04_matmul_basic/answer/04.03_answer/op_host/matmul_custom.cpp+6-6
| @@ -112,19 +112,19 @@ namespace ge { | |||
| 112 | 112 | ||
| 113 | static ge::graphStatus InferShape(gert::InferShapeContext* context) | 113 | static ge::graphStatus InferShape(gert::InferShapeContext* context) |
| 114 | { | 114 | { |
| 115 | - const gert::Shape* x1_shape = context->GetInputShape(0); | 115 | + const gert::Shape* a_shape = context->GetInputShape(0); // a: [M, K] |
| 116 | - gert::Shape* y_shape = context->GetOutputShape(0); | 116 | + const gert::Shape* b_shape = context->GetInputShape(1); // b: [K, N] |
| 117 | - *y_shape = *x1_shape; | 117 | + gert::Shape* y_shape = context->GetOutputShape(0); // c: [M, N] |
| 118 | + *y_shape = *a_shape; | ||
| 119 | + y_shape->SetDim(1, b_shape->GetDim(1)); // c 的 N 维取自 b | ||
| 118 | return GRAPH_SUCCESS; | 120 | return GRAPH_SUCCESS; |
| 119 | } | 121 | } |
| 120 | 122 | ||
| 121 | static ge::graphStatus InferDataType(gert::InferDataTypeContext *context) | 123 | static ge::graphStatus InferDataType(gert::InferDataTypeContext *context) |
| 122 | { | 124 | { |
| 123 | - const auto inputDataType = context->GetInputDataType(0); | 125 | + context->SetOutputDataType(0, ge::DT_FLOAT); // 输出固定 FP32 |
| 124 | - context->SetOutputDataType(0, inputDataType); | ||
| 125 | return ge::GRAPH_SUCCESS; | 126 | return ge::GRAPH_SUCCESS; |
| 126 | } | 127 | } |
| 127 | - | ||
| 128 | } // namespace ge | 128 | } // namespace ge |
| 129 | 129 | ||
| 130 | namespace ops { | 130 | namespace ops { |