Struct cubecl_core::ir::Scope
source · pub struct Scope {
pub depth: u8,
pub operations: Vec<Operation>,
pub layout_ref: Option<Variable>,
/* private fields */
}
Expand description
The scope is the main operation and variable container that simplify the process of reading inputs, creating local variables and adding new operations.
Notes:
This type isn’t responsible for creating shader bindings and figuring out which variable can be written to.
Fields§
§depth: u8
§operations: Vec<Operation>
§layout_ref: Option<Variable>
Implementations§
source§impl Scope
impl Scope
sourcepub fn root() -> Self
pub fn root() -> Self
Create a scope that is at the root of a kernel definition.
A local scope can be created with the child method.
sourcepub fn zero<I: Into<Item>>(&mut self, item: I) -> Variable
pub fn zero<I: Into<Item>>(&mut self, item: I) -> Variable
Create a variable initialized at zero.
sourcepub fn create_with_value<E, I>(&mut self, value: E, item: I) -> Variable
pub fn create_with_value<E, I>(&mut self, value: E, item: I) -> Variable
Create a variable initialized at some value.
sourcepub fn create_matrix(&mut self, matrix: Matrix) -> Variable
pub fn create_matrix(&mut self, matrix: Matrix) -> Variable
Create a matrix variable
sourcepub fn create_slice(&mut self, item: Item) -> Variable
pub fn create_slice(&mut self, item: Item) -> Variable
Create a slice variable
sourcepub fn create_local<I: Into<Item>>(&mut self, item: I) -> Variable
pub fn create_local<I: Into<Item>>(&mut self, item: I) -> Variable
Create a local variable of the given item type.
sourcepub fn create_local_undeclared(&mut self, item: Item) -> Variable
pub fn create_local_undeclared(&mut self, item: Item) -> Variable
Create a new local variable, but doesn’t perform the declaration.
Useful for for loops and other algorithms that require the control over initialization.
sourcepub fn read_array<I: Into<Item>>(
&mut self,
index: u16,
item: I,
position: Variable,
) -> Variable
pub fn read_array<I: Into<Item>>( &mut self, index: u16, item: I, position: Variable, ) -> Variable
Reads an input array to a local variable.
The index refers to the argument position of the array in the compute shader.
sourcepub fn index_offset_with_output_layout(
&mut self,
proc: IndexOffsetGlobalWithLayout,
)
pub fn index_offset_with_output_layout( &mut self, proc: IndexOffsetGlobalWithLayout, )
Add the procedure into the scope.
sourcepub fn read_scalar(&mut self, index: u16, elem: Elem) -> Variable
pub fn read_scalar(&mut self, index: u16, elem: Elem) -> Variable
Reads an input scalar to a local variable.
The index refers to the scalar position for the same element type.
sourcepub fn last_local_index(&self) -> Option<&Variable>
pub fn last_local_index(&self) -> Option<&Variable>
Retrieve the last local variable that was created.
sourcepub fn vectorize(&mut self, vectorization: Vectorization)
pub fn vectorize(&mut self, vectorization: Vectorization)
Vectorize the scope using the vectorization type.
Notes:
Scopes created during compilation (after the tracing is done) should not be vectorized.
sourcepub fn write_global(
&mut self,
input: Variable,
output: Variable,
position: Variable,
)
pub fn write_global( &mut self, input: Variable, output: Variable, position: Variable, )
Writes a variable to given output.
Notes:
This should only be used when doing compilation.
sourcepub fn write_global_custom(&mut self, output: Variable)
pub fn write_global_custom(&mut self, output: Variable)
Writes a variable to given output.
Notes:
This should only be used when doing compilation.
pub fn read_globals(&self) -> Vec<(u16, ReadingStrategy)>
sourcepub fn register<T: Into<Operation>>(&mut self, operation: T)
pub fn register<T: Into<Operation>>(&mut self, operation: T)
Register an operation into the scope.
sourcepub fn process(&mut self) -> ScopeProcessing
pub fn process(&mut self) -> ScopeProcessing
Returns the variables and operations to be declared and executed.
Notes:
New operations and variables can be created within the same scope without having name conflicts.
Create a shared variable of the given item type.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Scope
impl<'de> Deserialize<'de> for Scope
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Scope
impl PartialEq for Scope
impl StructuralPartialEq for Scope
Auto Trait Implementations§
impl Freeze for Scope
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnwindSafe for Scope
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)