Skip to content

Commit

Permalink
[Relay][Quantization] Fix issue introduced in apache#3135
Browse files Browse the repository at this point in the history
  • Loading branch information
vinx13 committed Jul 8, 2019
1 parent 2a7aebe commit 138b0d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion python/tvm/relay/quantize/_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ def add_rewrite(ref_call, new_args, ctx):
if isinstance(rhs_expr, _expr.Constant):
# quantize rhs to WEIGHT field if it is Constant
rhs_expr = attach_simulated_quantize(rhs_expr, QAnnotateKind.WEIGHT)
assert lhs_kind == QAnnotateKind.ACTIVATION
expr = _forward_op(ref_call, [lhs_expr, rhs_expr])
return QAnnotateExpr(expr, QAnnotateKind.ACTIVATION)
else:
Expand Down
15 changes: 8 additions & 7 deletions src/relay/pass/quantize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,15 @@ Array<Expr> UnifyDTypeScale(const Array<Expr>& ref_args,
// unify the data type
CHECK_EQ(ref_args.size(), args.size());
DataType dtype;
if (nptrs[0]->dtype == cfg->dtype_activation) {
DataType dtype = cfg->dtype_activation;
ret.Set(1, Cast(ret[1], dtype));
} else if (nptrs[1]->dtype == cfg->dtype_input) {
DataType dtype = cfg->dtype_input;
ret.Set(0, Cast(ret[0], dtype));
if (ret.size() == 2 && nptrs[1]->dtype == cfg->dtype_input) {
dtype = cfg->dtype_input;
} else {
LOG(FATAL) << "should not touch here.";
dtype = cfg->dtype_activation;
}
for (size_t i = 0; i < ret.size(); ++i) {
if (nptrs[i]->dtype != dtype) {
ret.Set(i, Cast(ret[i], dtype));
}
}

// unify the dom_scale
Expand Down

0 comments on commit 138b0d5

Please sign in to comment.