honghuichao commented on issue #12707:
URL: https://github.com/apache/tvm/issues/12707#issuecomment-1238864157
@mbrookhart
1. for first problem:I add some code, segement fault is disappear. but I
don't know if it's reasonable.
if (call_node == quantize_node_) {
/*if
(tvm::relay::transform::InferTypeLocal(out).as<TupleTypeNode>()) {
Array<Expr> outs;
for (size_t i = 0; i < Downcast<Tuple>(out)->fields.size(); i++) {
auto tmp = Downcast<Tuple>(out)->fields[i];
auto quantize_info = vals[1].as<TupleAffineTypeNode>()->types[i];
auto new_out = qnn::MakeDequantize(tmp,
quantize_info.as<TensorAffineTypeNode>()->scale,
quantize_info.as<TensorAffineTypeNode>()->zero_point,
quantize_info.as<TensorAffineTypeNode>()->axis);
outs.push_back(new_out);
}
out = Tuple(outs);*/
//} else {
out = qnn::MakeDequantize(out,
vals[1].as<TensorAffineTypeNode>()->scale,
vals[1].as<TensorAffineTypeNode>()->zero_point,
vals[1].as<TensorAffineTypeNode>()->axis);
//}
}
}
2.for second problem: I write a simple demo.
import tvm
mod = tvm.parser.parse_expr(
'''
fn (%x1: Tensor[(1, 3, 224, 224), float32] /* ty=Tensor[(1, 3, 224, 224),
float32] */, %x2: Tensor[(1, 3, 224, 224), float32] /* ty=Tensor[(1, 3, 224,
224), float32] */) -> Tensor[(1, 6, 224, 224), float32] {
%0 = power(2f, 1f /* ty=float32 */);
%1 = divide(1f, %0);
%2 = qnn.quantize(%x1, %1, 0, out_dtype="int8");
%3 = clip(%2, a_min=-127f, a_max=127f);
%4 = power(2f, 1f /* ty=float32 */);
%5 = divide(1f, %4);
%6 = qnn.quantize(%x2, %5, 0, out_dtype="int8");
%7 = clip(%6, a_min=-127f, a_max=127f);
%8 = qnn.dequantize(%3, %1, 0);
%9 = qnn.dequantize(%7, %5, 0);
%10 = (%8, %9) /* ty=(Tensor[(1, 3, 224, 224), float32], Tensor[(1, 3,
224, 224), float32]) */;
%11 = power(2f, 1f /* ty=float32 */);
%12 = concatenate(%10, axis=1) /* ty=Tensor[(1, 6, 224, 224), float32] */;
%13 = divide(1f, %11);
%14 = qnn.quantize(%12, %13, 0, out_dtype="int8");
%15 = clip(%14, a_min=-127f, a_max=127f);
qnn.dequantize(%15, %13, 0)
} /* ty=fn (Tensor[(1, 3, 224, 224), float32], Tensor[(1, 3, 224, 224),
float32]) -> Tensor[(1, 6, 224, 224), float32] */
'''
)
mod = tvm.IRModule.from_expr(mod)
mod = relay.transform.InferType()(mod)
mod = tvm.relay.transform.FakeQuantizationToInteger(False, True)(mod)
I think in this network, concat op will transform into qnn.concat.but, I run
" mod = tvm.relay.transform.FakeQuantizationToInteger(False, True)(mod)"
the result is :
fn (%x1: Tensor[(1, 3, 224, 224), float32] /* ty=Tensor[(1, 3, 224, 224),
float32] */, %x2: Tensor[(1, 3, 224, 224), float32] /* ty=Tensor[(1, 3, 224,
224), float32] */) -> Tensor[(1, 6, 224, 224), float32] {
%0 = power(2f, 1f /* ty=float32 */);
%1 = divide(1f, %0);
%2 = qnn.quantize(%x1, %1, 0, out_dtype="int8");
%3 = clip(%2, a_min=-127f, a_max=127f);
%4 = power(2f, 1f /* ty=float32 */);
%5 = divide(1f, %4);
%6 = qnn.quantize(%x2, %5, 0, out_dtype="int8");
%7 = clip(%6, a_min=-127f, a_max=127f);
%8 = qnn.dequantize(%3, %1, 0);
%9 = qnn.dequantize(%7, %5, 0);
%10 = (%8, %9) /* ty=(Tensor[(1, 3, 224, 224), float32], Tensor[(1, 3,
224, 224), float32]) */;
%11 = power(2f, 1f /* ty=float32 */);
%12 = concatenate(%10, axis=1) /* ty=Tensor[(1, 6, 224, 224), float32] */;
%13 = divide(1f, %11);
%14 = qnn.quantize(%12, %13, 0, out_dtype="int8");
%15 = clip(%14, a_min=-127f, a_max=127f);
qnn.dequantize(%15, %13, 0)
} /* ty=
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]