[RELAY] Add new operator to RELAY

This maybe a silly question

I’m looking at how to add new operator to Relay, but got this problem. https://tvm.apache.org/docs/dev/how_to/relay_add_op.html

In part 4, it doesn’t write where to put those computational codes, I want to know where i should put these codes, and where relay ops inplement their computation process.

Many Thanks

The computes for the operators are normally selected using the relay strategy as mentioned in part 5 of that doc. For more info on how the relay op strategy works, you can read this page

The computes themselves normally go into topi directory. If it is a generic compute and schedule, they can be added to an appropriate file in the generic directory, or if it’s specific to some target, you can add it into the target specific directory as well.

If I’ve misunderstood your question in any way, do let me know and I can try to answer it properly :slight_smile:

1 Like

I don’t know if I truly understand the meaning. If I say something wrong, please point it out.

If I want to make a new operator, the computation part usually directly use the topi interface, so if I want to implement a new computation, I need to write something in TOPI files, and then link them to the part5 files.

As for the others, I can just follow the guide to finish the implement of a new op.

Thanks @sanirudh

Yes that’s correct. If the compute for the new operator is already in topi files, you can just call that, and if not, then you can implement it somewhere in topi. Part 5 can then help link your relay operator to the actual compute and schedule for that operator.

Sorry to bother, but could you please see another question I met?

This is the registry problem(Part 5).

Many thanks @sanirudh