Relay Op(fast_exp) can't be built

I encountered something wrong with the relay pass FastMath() and topi.fast_exp.

I made a testing relay program with exp and build it with

with relay.build_config(opt_level=4):
    graph, lib, params = relay.build(mod, target, params=params)

to enable and build Op(fast_exp), but I got an error:

all_impls = get_valid_implementations(op, attrs, inputs, out_type, target)
  File "/home/selo/tvm/python/tvm/relay/backend/compile_engine.py", line 122, in get_valid_implementations
    assert fstrategy is not None, "%s doesn't have FTVMStrategy registered" % op.name
AssertionError: fast_exp doesn't have FTVMStrategy registered

It seems that there’s a gap between the relay Op and topi implementation, so I inserted two lines:

register_broadcast_schedule("fast_exp")
register_shape_func("fast_exp", False, elemwise_shape_func)

in python/tvm/relay/op/_tensor.py

and turns out it worked.

Is this the intended way to use Op(fast_exp)?

Thanks.

Yes, it’s probably an oversight that there is no registration of fast_exp schedule. Your solution looks good. Could you send a PR to fix this?

Thank you. Can you also register for fast_tanh?

Also, a better usage for using fastmath pass is follows

Sure, I had opened a PR #5131. I hope it helps. Thanks.

Thank you for your suggestion.