pub enum FastDivmod {
Fast {
divisor: u32,
multiplier: u32,
shift_right: u32,
},
PowerOfTwo {
shift: u32,
mask: u32,
},
Fallback {
divisor: u32,
},
}
Expand description
Create a fast-divmod object if supported, or a regular fallback if not. This precalculates certain values on the host, in exchange for making division and modulo operations on the GPU much faster. Only supports u32 right now to allow for a simpler algorithm. It’s mostly used for indices regardless.
Implementation based on ONNX: https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/core/providers/cuda/shared_inc/fast_divmod.h
Variants§
Implementations§
Source§impl FastDivmod
impl FastDivmod
pub fn new_Fast(divisor: u32, multiplier: u32, shift_right: u32) -> Self
pub fn __expand_new_Fast( _: &mut Scope, divisor: <u32 as CubeType>::ExpandType, multiplier: <u32 as CubeType>::ExpandType, shift_right: <u32 as CubeType>::ExpandType, ) -> FastDivmodExpand
pub fn new_PowerOfTwo(shift: u32, mask: u32) -> Self
pub fn __expand_new_PowerOfTwo( _: &mut Scope, shift: <u32 as CubeType>::ExpandType, mask: <u32 as CubeType>::ExpandType, ) -> FastDivmodExpand
pub fn new_Fallback(divisor: u32) -> Self
pub fn __expand_new_Fallback( _: &mut Scope, divisor: <u32 as CubeType>::ExpandType, ) -> FastDivmodExpand
Source§impl FastDivmod
impl FastDivmod
pub fn div(&self, dividend: u32) -> u32
pub fn modulo(&self, dividend: u32) -> u32
pub fn div_mod(&self, dividend: u32) -> (u32, u32)
pub fn __expand_div( scope: &mut Scope, this: <Self as CubeType>::ExpandType, dividend: <u32 as CubeType>::ExpandType, ) -> <u32 as CubeType>::ExpandType
pub fn __expand_modulo( scope: &mut Scope, this: <Self as CubeType>::ExpandType, dividend: <u32 as CubeType>::ExpandType, ) -> <u32 as CubeType>::ExpandType
pub fn __expand_div_mod( scope: &mut Scope, this: <Self as CubeType>::ExpandType, dividend: <u32 as CubeType>::ExpandType, ) -> <(u32, u32) as CubeType>::ExpandType
Trait Implementations§
Source§impl Clone for FastDivmod
impl Clone for FastDivmod
Source§fn clone(&self) -> FastDivmod
fn clone(&self) -> FastDivmod
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl CubeDebug for FastDivmod
impl CubeDebug for FastDivmod
Source§fn set_debug_name(&self, scope: &mut Scope, name: &'static str)
fn set_debug_name(&self, scope: &mut Scope, name: &'static str)
Set the debug name of this type’s expansion. Should do nothing for types that don’t appear
at runtime
Source§impl CubeType for FastDivmod
impl CubeType for FastDivmod
type ExpandType = FastDivmodExpand
Source§fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
Wrapper around the init method, necessary to type inference.
Source§impl LaunchArg for FastDivmod
impl LaunchArg for FastDivmod
Source§type RuntimeArg<'a, R: Runtime> = FastDivmodArgs<'a, R>
type RuntimeArg<'a, R: Runtime> = FastDivmodArgs<'a, R>
The runtime argument for the kernel.
fn compilation_arg<'a, R: Runtime>( runtime_arg: &Self::RuntimeArg<'a, R>, ) -> Self::CompilationArg
Source§impl LaunchArgExpand for FastDivmod
impl LaunchArgExpand for FastDivmod
Source§type CompilationArg = FastDivmodCompilationArg
type CompilationArg = FastDivmodCompilationArg
Compilation argument.
Source§fn expand(
arg: &Self::CompilationArg,
builder: &mut KernelBuilder,
) -> <Self as CubeType>::ExpandType
fn expand( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType
Register an input variable during compilation that fill the KernelBuilder.
Source§fn expand_output(
arg: &Self::CompilationArg,
builder: &mut KernelBuilder,
) -> <Self as CubeType>::ExpandType
fn expand_output( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType
Register an output variable during compilation that fill the KernelBuilder.
impl Copy for FastDivmod
Auto Trait Implementations§
impl Freeze for FastDivmod
impl RefUnwindSafe for FastDivmod
impl Send for FastDivmod
impl Sync for FastDivmod
impl Unpin for FastDivmod
impl UnwindSafe for FastDivmod
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