I’ve discovered a very strange phenomenon. I don’t know whether to consider it a mul operator or a pow operator because it causes bugs:
eg: +++++++++++++++++++++++++++++++++++ %551 = qnn.quantize(%550, 0.00390625f /* span=model/tf_detect/Sigmoid_7:0:0 /, -128 / span=model/tf_detect/Sigmoid_7:0:0 /, out_dtype=“int8”) / span=model/tf_detect/Sigmoid_7:0:0 */;
%552 = qnn.mul(%551, %551, 0.00390625f /* span=model/tf_detect/pow_2;model/tf_detect/mul_16/y:0:0 /, -128 / span=model/tf_detect/pow_2;model/tf_detect/mul_16/y:0:0 /, 0.00390625f / span=model/tf_detect/pow_2;model/tf_detect/mul_16/y:0:0 /, -128 / span=model/tf_detect/pow_2;model/tf_detect/mul_16/y:0:0 /, 0.00386995f / span=model/tf_detect/pow_2;model/tf_detect/mul_16/y:0:0 /, -128 / span=model/tf_detect/pow_2;model/tf_detect/mul_16/y:0:0 /) / span=model/tf_detect/pow_2;model/tf_detect/mul_16/y:0:0 */;
%553 = qnn.mul(%552, %v_param_121, 0.00386995f /* span=model/tf_detect/mul_18:0:0 /, -128 / span=model/tf_detect/mul_18:0:0 /, 5.85098f / span=model/tf_detect/mul_18:0:0 /, -128 / span=model/tf_detect/mul_18:0:0 /, 2.88114f / span=model/tf_detect/mul_18:0:0 /, -128 / span=model/tf_detect/mul_18:0:0 /) / span=model/tf_detect/mul_18:0:0 */; +++++++++++++++++++++++++++++++++++++++
This is when importing. The %552 operator is a mul operator, but it implements a quadratic operation. According to the subsequent optimization of MergeComposite, it will be created as a function with only input variables
eg: %561 = fn (%FunctionVar_26_02: Tensor[(1, 6400, 3, 2), int8] /* ty=Tensor[(1, 6400, 3, 2), int8] /, PartitionedFromPattern=“qnn.mul_”, Composite=“ethos-u.mul”) → Tensor[(1, 6400, 3, 2), int8]…
This will cause some bugs in the subsequent relaytotir. For instance, mod = LegalizeEthosU()(mod) will not rewrite this, because normally the mul operator should have two variables, but this one only has one variable. I don’t know how to fix this bug. Should I directly change this mul to pow? But I still hope it’s a mul so that my hardware backend can support it. If you are familiar with relay, please help me.Thank you!