From ec5026f3b22214612893cfd1acbd03b9521785d7 Mon Sep 17 00:00:00 2001 From: zhanyuan Date: Mon, 12 Oct 2020 20:37:37 +0800 Subject: [PATCH] Adapt matmul's input tensor shape of onnx model --- mindspore/lite/src/ops/matmul.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mindspore/lite/src/ops/matmul.cc b/mindspore/lite/src/ops/matmul.cc index 62b40f15ea..3d1c38045b 100644 --- a/mindspore/lite/src/ops/matmul.cc +++ b/mindspore/lite/src/ops/matmul.cc @@ -105,6 +105,12 @@ int MatMul::InferShape(std::vector inputs_, std::vector outp std::vector a_shape = input0->shape(); std::vector b_shape = input1->shape(); + + if (a_shape.size() == 4 && a_shape[2] == 1 && a_shape[3] == 1) { + a_shape.resize(2); + input0->set_shape(a_shape); + } + if (a_shape.size() < 2 || b_shape.size() < 2) { MS_LOG(ERROR) << "inputs shape is invalid"; return RET_INPUT_TENSOR_ERROR;