From 86f9038d9b58abe49ec72111e97a8c8933223f38 Mon Sep 17 00:00:00 2001 From: FusionBolt <59008347+FusionBolt@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:02:50 +0800 Subject: [PATCH] fix range of marker for matmul (#1057) --- src/Nncase.Passes/Rules/Neutral/AddRangeOfAndMarker.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Nncase.Passes/Rules/Neutral/AddRangeOfAndMarker.cs b/src/Nncase.Passes/Rules/Neutral/AddRangeOfAndMarker.cs index a53c2d3166..656a452263 100644 --- a/src/Nncase.Passes/Rules/Neutral/AddRangeOfAndMarker.cs +++ b/src/Nncase.Passes/Rules/Neutral/AddRangeOfAndMarker.cs @@ -125,8 +125,13 @@ public static bool CheckOp(Op op) { if (!pairs.ContainsKey(callParams[i])) { + // 动态shape的情况下会先统计range再分段,matmul转conv2d则是需要知道shape才能做 + // 动态shape情况下执行的顺序是range -> 分段 -> matmul转conv2d + // 这里必须要对matmul的rhs进行判断,如果matmul是动态的那么不会走量化,如果是静态的那么一定会转到conv2d + // 因此认为matmul的rhs为const的情况下一定能转成conv2d bool isWeights = ((call.Target is Conv2D || call.Target is Conv2DTranspose) && (i == 1)) - || (call.Target is LSTM && i > 0); + || (call.Target is LSTM && i > 0) + || (call.Target is MatMul && i == 1 && callParams[1] is TensorConst); if (!configExist && !useAutoMixQuant) {