pub trait ComputeFnVTable:
'static
+ Send
+ Sync {
// Required methods
fn invoke(
&self,
args: &InvocationArgs<'_>,
kernels: &[ArcRef<dyn Kernel>],
) -> VortexResult<Output>;
fn return_dtype(&self, args: &InvocationArgs<'_>) -> VortexResult<DType>;
fn return_len(&self, args: &InvocationArgs<'_>) -> VortexResult<usize>;
fn is_elementwise(&self) -> bool;
}
Expand description
VTable for the implementation of a compute function.
Required Methods§
Sourcefn invoke(
&self,
args: &InvocationArgs<'_>,
kernels: &[ArcRef<dyn Kernel>],
) -> VortexResult<Output>
fn invoke( &self, args: &InvocationArgs<'_>, kernels: &[ArcRef<dyn Kernel>], ) -> VortexResult<Output>
Invokes the compute function entry-point with the given input arguments and options.
The entry-point logic can short-circuit compute using statistics, update result array statistics, search for relevant compute kernels, and canonicalize the inputs in order to successfully compute a result.
Sourcefn return_dtype(&self, args: &InvocationArgs<'_>) -> VortexResult<DType>
fn return_dtype(&self, args: &InvocationArgs<'_>) -> VortexResult<DType>
Computes the return type of the function given the input arguments.
All kernel implementations will be validated to return the DType
as computed here.
Sourcefn return_len(&self, args: &InvocationArgs<'_>) -> VortexResult<usize>
fn return_len(&self, args: &InvocationArgs<'_>) -> VortexResult<usize>
Computes the return length of the function given the input arguments.
All kernel implementations will be validated to return the len as computed here. Scalars are considered to have length 1.
Sourcefn is_elementwise(&self) -> bool
fn is_elementwise(&self) -> bool
Returns whether the function operates elementwise, i.e. the output is the same shape as the input and no information is shared between elements.
Examples include add
, subtract
, and
, cast
, fill_null
etc.
Examples that are not elementwise include sum
, count
, min
, fill_forward
etc.
All input arrays to an elementwise function must have the same length.