As the comment says, there is a guide for adding op to TensorFlow . This guide describes adding a new op that is implemented in C ++. In general, you should do this in the following situations:
- The op operation cannot be implemented using existing TensorFlow operating tools (for example, it
l1_losscan be implemented using the existing element-wise and reduction as a Python function). - To improve performance (or memory consumption), a C ++ implementation is needed.
- The op operation can be implemented as part of the ops, but has a gradient that can be calculated more efficiently (or with better numerical stability) than the calculation of op-by-op gradients. (This is why it
tf.nn.l2_lossis implemented as a compiled op in C ++.)
source
share