Skip to content

Commit

Permalink
fix calibration pass to support multiple functions (apache#5768)
Browse files Browse the repository at this point in the history
Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
2 people authored and trevor-m committed Jun 18, 2020
1 parent ccfbced commit 2c174fe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions python/tvm/relay/quantize/_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ def _make_const(val):
const_params[nclip_min] = _make_const(- (valid_range - 1))
const_params[nclip_max] = _make_const((valid_range - 1))

func = mod['main']
_analysis.post_order_visit(func, visit_func)
func = _expr.bind(func, const_params)
return IRModule.from_expr(func)
main_func = mod['main']
_analysis.post_order_visit(main_func, visit_func)
main_func = _expr.bind(main_func, const_params)
func_dict = {}
for global_var, func in mod.functions.items():
if global_var.name_hint != 'main':
func_dict[global_var] = func
return IRModule.from_expr(main_func, func_dict)


# weight scale functions
Expand Down

0 comments on commit 2c174fe

Please sign in to comment.