pub trait CustomOp:
Any
+ Send
+ Sync {
// Required methods
fn name(&self) -> &str;
fn infer_output_shape(&self, input_shapes: &[&Shape]) -> Shape;
fn as_any(&self) -> &dyn Any;
// Provided methods
fn lower(&self) -> Option<(String, String, String, Arc<dyn RuntimeOp>)> { ... }
fn lower_backward_source(&self) -> String { ... }
}Expand description
Trait implemented by user-defined ops.
Required Methods§
Sourcefn infer_output_shape(&self, input_shapes: &[&Shape]) -> Shape
fn infer_output_shape(&self, input_shapes: &[&Shape]) -> Shape
Compute the output shape given the shapes of all input tensors in order.
Provided Methods§
Sourcefn lower(&self) -> Option<(String, String, String, Arc<dyn RuntimeOp>)>
fn lower(&self) -> Option<(String, String, String, Arc<dyn RuntimeOp>)>
Return kernel lowering info so TritonLowering can compile this op
without a project-specific middleware. Return None to keep the
existing middleware / error behaviour.
Tuple layout: (name, kernel_source, entry_point_name, runtime_op).
entry_point_name is the PTX symbol name, conventionally "{name}_entry_point".
Sourcefn lower_backward_source(&self) -> String
fn lower_backward_source(&self) -> String
Return the backward kernel source for this op (used in training mode). Return an empty string if this op has no backward pass.