[Tutorial Fix] TVM 2019 FCRC Code

Hi I just started to learn TVM and noted that some code in FCRC [TVM For Fun and Profit Tutorial, ISCA 2019, June 22nd 2019, Phoenix] workshop are too old to run with lastest tvm (0.8_dev) So I put the fix here for any starter learners.

(1) relay.Module not exist

instead use:

mod = tvm.IRModule({})

(2) get params from IRModule changed (in inline_parameters)

Should use expr[‘main’] instead of expr

param_map = dict((p.name_hint, p) for p in expr["main"].params)        
params = dict((param_map[k], relay.const(params[k])) for k in params)

(3) relay.ir_pass is moved to relay.analysis

relay.Function(relay.analysis.free_vars(new_body), new_body)        

(4) relay.create_executor(‘vm’, mod) does not contain ‘main’ variable

good example should be(add a valid main func in IRModule):

ix = relay.var('x', shape=(10, 1))
z = x + x
mod = tvm.IRModule({})
fname = relay.GlobalVar('main')
mod[fname] = relay.Function([x], z)
1 Like

Yeah TVM has gone through quite a bit of refactoring (mainly unified IR refactor) since FCRC 2019. Thank you so much for the fix!

Actually I came to FCRC to understand Relay and TIR, I would be very appreciated if you can help me with the questions in my other post [TIR/Relay] why tvm.tir api generates relay IR