Getting params in the codegen

@comaniac How can we get the params to codegen ?

Hi sorry for the late reply. You may use the following to pass the parameters:

with transform.PassContext(opt_level=3, config={'my_param': 16}):, ...)

And you can use the following to get the parameter in your codegen:

transform::PassContext pass_ctx = PassContext::Current();
Optional<Integer> val = pass_ctx->GetConfig("my_param", Integer(0));

Thanks @comaniac for your suggestion.

Tried with the below code and seeing the following error:

with tvm.transform.PassContext(opt_level=3, config = {'my_param': 16}) : 
     json, lib, param =, target=target, params=params)

File “/workspace/temp/tvm_master/src/ir/”, line 103 AttributeError: Invalid config option ‘my_param’ candidates are: relay.fallback_device_type ,tir.add_lower_pass ,tir.disable_vectorize ,tir.disable_assert ,tir.LoopPartition ,tir.UnrollLoop ,tir.instrument_bound_checkers ,tir.InjectDoubleBuffer ,tir.noalias ,tir.detect_global_barrier

After registering TVM_REGISTER_PASS_CONFIG_OPTION(“my_param”, Integer) i was able to run successfully.
Is this registration expected?

Ah sorry I missed that part. Yes this is expected.