pub struct ThresholdedReluRuntimeOp {
pub kernel: ThresholdedReluForward,
pub backward_kernel: ThresholdedReluBackward,
pub alpha: f32,
}Expand description
RuntimeOp wrapper for ThresholdedRelu that stores the alpha scalar.
Fields§
§kernel: ThresholdedReluForward§backward_kernel: ThresholdedReluBackward§alpha: f32Implementations§
Source§impl ThresholdedReluRuntimeOp
impl ThresholdedReluRuntimeOp
pub fn new(block_size: i32, alpha: f32) -> Self
pub fn forward_source(&self) -> &str
pub fn backward_source(&self) -> &str
pub fn kernel_name(&self) -> &str
Trait Implementations§
Source§impl RuntimeOp for ThresholdedReluRuntimeOp
impl RuntimeOp for ThresholdedReluRuntimeOp
Source§fn n_activation_inputs(&self) -> usize
fn n_activation_inputs(&self) -> usize
Number of activation tensors taken from predecessor DAG nodes.
Source§fn param_shapes(&self, _: &[&[usize]], _: &[usize]) -> Vec<Vec<usize>>
fn param_shapes(&self, _: &[&[usize]], _: &[usize]) -> Vec<Vec<usize>>
Shapes of additional parameter buffers (weights, biases) needed by this
op. Called at
LoadedModel::load() time to pre-allocate device buffers.
input_shapes / output_shape are concrete (batch dim resolved).Source§fn pack_args(
&self,
inputs: &[(RawPtr, &[usize])],
_: &[RawPtr],
output: RawPtr,
output_shape: &[usize],
_: i32,
visitor: &mut dyn ArgVisitor,
)
fn pack_args( &self, inputs: &[(RawPtr, &[usize])], _: &[RawPtr], output: RawPtr, output_shape: &[usize], _: i32, visitor: &mut dyn ArgVisitor, )
Pack all kernel arguments into
visitor in the correct order. Read moreSource§fn grid(&self, output_shape: &[usize]) -> [u32; 3]
fn grid(&self, output_shape: &[usize]) -> [u32; 3]
Number of CTAs to launch (x, y, z), given the concrete output shape.
Source§fn has_backward(&self) -> bool
fn has_backward(&self) -> bool
Returns true if this op has a backward (gradient) kernel.
Source§fn pack_backward_args(
&self,
inputs: &[(RawPtr, &[usize])],
_: &[RawPtr],
_: RawPtr,
output_shape: &[usize],
grad_output: RawPtr,
_: i32,
grad_inputs: &[RawPtr],
_: &[RawPtr],
visitor: &mut dyn ArgVisitor,
)
fn pack_backward_args( &self, inputs: &[(RawPtr, &[usize])], _: &[RawPtr], _: RawPtr, output_shape: &[usize], grad_output: RawPtr, _: i32, grad_inputs: &[RawPtr], _: &[RawPtr], visitor: &mut dyn ArgVisitor, )
Pack backward kernel arguments. Read more
Source§fn backward_block(&self) -> [u32; 3]
fn backward_block(&self) -> [u32; 3]
Threads-per-CTA for the backward kernel.
Source§fn backward_grid(&self, _: &[&[usize]], output_shape: &[usize]) -> [u32; 3]
fn backward_grid(&self, _: &[&[usize]], output_shape: &[usize]) -> [u32; 3]
Number of CTAs for the backward kernel. Read more
Source§fn param_names(&self) -> &'static [&'static str]
fn param_names(&self) -> &'static [&'static str]
Names of parameter slots returned by [
param_shapes], in the same order.
Used as the suffix in the dotted key {node_name}.{slot_name}.
Return an empty slice for ops that have no named parameters.Source§fn forward_output_row_stride(&self, output_shape: &[usize]) -> usize
fn forward_output_row_stride(&self, output_shape: &[usize]) -> usize
Returns the required row stride (in elements) for the output buffer of
this op’s forward kernel. The default is the natural row-major stride
(
output_shape[-1]). Kernels using TMA must round up to satisfy the
16-byte alignment constraint (e.g. 4 elements for f32).Source§fn param_init_data(&self, _param_idx: usize) -> Option<Vec<u8>>
fn param_init_data(&self, _param_idx: usize) -> Option<Vec<u8>>
Returns raw (little-endian) bytes to pre-populate parameter slot
param_idx
immediately after device buffer allocation. Return None to leave the
slot zero-initialised (the default for trained parameters).
Byte count must equal param_shapes()[param_idx].iter().product() * dtype_bytes.Source§fn compute_concrete_output_shape(
&self,
_input_shapes: &[&[usize]],
resolved: &[usize],
) -> Vec<usize>
fn compute_concrete_output_shape( &self, _input_shapes: &[&[usize]], resolved: &[usize], ) -> Vec<usize>
Override to compute the true concrete output shape from concrete input shapes. Read more
Source§fn n_launches(&self) -> usize
fn n_launches(&self) -> usize
Number of sequential kernel launches this op requires. Read more
Source§fn pack_args_for_launch(
&self,
launch_idx: usize,
inputs: &[(*mut c_void, &[usize])],
params: &[*mut c_void],
output: *mut c_void,
output_shape: &[usize],
output_row_stride: i32,
visitor: &mut dyn ArgVisitor,
)
fn pack_args_for_launch( &self, launch_idx: usize, inputs: &[(*mut c_void, &[usize])], params: &[*mut c_void], output: *mut c_void, output_shape: &[usize], output_row_stride: i32, visitor: &mut dyn ArgVisitor, )
Pack kernel arguments for launch
i (0-indexed). Read moreSource§fn grid_for_launch(
&self,
launch_idx: usize,
input_shapes: &[&[usize]],
output_shape: &[usize],
) -> [u32; 3]
fn grid_for_launch( &self, launch_idx: usize, input_shapes: &[&[usize]], output_shape: &[usize], ) -> [u32; 3]
Grid for launch
i. Receives concrete input shapes so that per-chunk
grids can be computed without storing them in the op. Read moreSource§fn backward_grad_output_row_stride(&self, output_shape: &[usize]) -> usize
fn backward_grad_output_row_stride(&self, output_shape: &[usize]) -> usize
Returns the required row stride (in elements) for the grad_output buffer
passed to
pack_backward_args. The default is the natural row-major
stride (output_shape[-1]). Kernels using TMA must round up to satisfy
the 16-byte alignment constraint (e.g. 4 elements for f32).Source§fn n_backward_launches(&self) -> usize
fn n_backward_launches(&self) -> usize
Number of sequential kernel launches for the backward pass. Read more
Source§fn pack_backward_args_for_launch(
&self,
launch_idx: usize,
inputs: &[(*mut c_void, &[usize])],
params: &[*mut c_void],
output: *mut c_void,
output_shape: &[usize],
grad_output: *mut c_void,
grad_output_row_stride: i32,
grad_inputs: &[*mut c_void],
grad_params: &[*mut c_void],
visitor: &mut dyn ArgVisitor,
)
fn pack_backward_args_for_launch( &self, launch_idx: usize, inputs: &[(*mut c_void, &[usize])], params: &[*mut c_void], output: *mut c_void, output_shape: &[usize], grad_output: *mut c_void, grad_output_row_stride: i32, grad_inputs: &[*mut c_void], grad_params: &[*mut c_void], visitor: &mut dyn ArgVisitor, )
Pack backward kernel arguments for launch
i (0-indexed). Read moreAuto Trait Implementations§
impl Freeze for ThresholdedReluRuntimeOp
impl RefUnwindSafe for ThresholdedReluRuntimeOp
impl Send for ThresholdedReluRuntimeOp
impl Sync for ThresholdedReluRuntimeOp
impl Unpin for ThresholdedReluRuntimeOp
impl UnsafeUnpin for ThresholdedReluRuntimeOp
impl UnwindSafe for ThresholdedReluRuntimeOp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more