There is a method in OpKernel
// Returns true iff this op kernel is considered "expensive". The
// runtime may use this flag to optimize graph execution for example
// to "inline" inexpensive kernels.
virtual bool IsExpensive() { return expensive_; }
It seems that by default all operations on the GPU are considered as inexpensive whilst CPU, SYSL are flagged as expensive.
It is a bit hard to figure out the definition and effect of expensive
. The is no information in the guide.
IsExpensive
should be false, true
? AsyncOp
(like RemoteFusedGraphExecuteOp
) is expensive, MPIAllgatherOp
seems to be defined as not expensive. Isn't this a contradiction?I am asking, because the IdentityOp
is explicitly marked as inexpensive. I wonder, if I should override this method in my custom ops as well, since each CPU version (even any custom code) is flagged as expensive.
The entire logic of XLA seems to be about wether an instruction is expensive or not. So it might be an important part to consider. Therefore, a coin-toss about true/false might be not the best way to decide the return value in my custom op.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With