Are external operations well-supported/tested in relay?


It would be good if the docs contain an example (similar to of how to use external operations when using the relay interface. Also, not sure if this is well tested?

For example, I registered an extern relay op via RELAY_REGISTER_OP(“snps.subgraph”), and called it as per:

data1 = relay.var("data1", shape=data_shape)
data2 = relay.var("data2", shape=data_shape)
body = snps_subgraph(data=data1)
body = relay.add(body, data2)

this seems to run as expected. However, if I put the add operation before the snps_subgraph, I get errors during the schedule_injective processing. As I am very new to this stuff, not sure what is going wrong, if I am missing something, or if this is simply not yet supported.


Did you set its fusion attribute?

You must make sure the schedule is correctly designed to handle the fusion pattern, if you incorrectly specify an operator as fusable the fusion algorithm will fail when scheduling the operation (what you are experiencing).

For example if you use a TVM external operation it should be marked opaque (i.e kOpaque) as it is not fusable.

If you have a reproducible error after correctly marking the operator, please send us a test case and we can introduce it as a regression.


Thanks for your help, indeed setting TOpPattern to kOpaque solved my issue.