What's the difference between build() and create_executor() in tvm.relay.build_module?

I noticed that there are two functions used in the tutorials to generate code:

How are these two functions different? Are they related?

One observation: only relay.build_module.create_executor() lets you specify the Module argument. This is important for me because I want to write a recursive function in Relay.

My understanding is that build() is kind of the old style grandfathered in for compatibility with NNVM-style scripts. create_executor() is the more modern style CC @jroesch.

1 Like

I believe @eqy is correct except for possibly the choice of host_target, which seems to be absent from create_executor(), but hopefully @jroesch can clarify that.

create_executor() supports multiple backends. Right now these are the reference interpreter (“debug”) and the graph runtime (“graph”), which is what build() uses (create_executor() just wraps build() when using “graph”). In the future it will also support other backends like the dynamic runtime. I hope that helps.

Also if you want to run recursive functions, you will probably have to use the “debug” interpreter or wait for the dynamic runtime. As far as I know, the “graph” runtime only supports static graphs, but I could be wrong.

@eqy @joshpoll Thanks for your replies! Yes, I did use the “debug” runtime to run a small recursive function.

1 Like

both build and create_executor are useful and will continue to be used.

In particular, create_executor serves as a shortcut for build + runtime.create. If the user want to create something that get deployed to a separate machine, then we still need to call build runtime.create separately

4 Likes

hi,I am new to TVM and I want to ask a q:

when using realy.build a lib and we can use time_evaluator to calculate the time cost; how to calculate the time when using create_executor?

I think

> start = time.time()
> tvm_output = intrp.evaluate()(tvm.nd.array(x.astype(dtype)), **params).asnumpy()
> end = time.time()
> print("Execute over! used time is : {} ".format(end-start))

is not a good method.

are there some progress in dynamic runtime?