pub struct KernelBuilder {
pub scope: Scope,
/* private fields */
}Expand description
Prepare a kernel to create a KernelDefinition.
Fields§
§scope: ScopeCube scope.
Implementations§
Source§impl KernelBuilder
impl KernelBuilder
Sourcepub fn scalar(&mut self, storage: StorageType) -> Id
pub fn scalar(&mut self, storage: StorageType) -> Id
Register a scalar and return the element to be used for kernel expansion.
Sourcepub fn buffer(&mut self, value_ty: Type) -> Value
pub fn buffer(&mut self, value_ty: Type) -> Value
Register a buffer and return the element to be used for kernel expansion.
Sourcepub fn tensor(&mut self, value_ty: Type) -> Value
pub fn tensor(&mut self, value_ty: Type) -> Value
Register a tensor and return the element to be used for kernel expansion.
Sourcepub fn tensor_map(&mut self) -> Value
pub fn tensor_map(&mut self) -> Value
Register a tensor map and return the element to be used for kernel expansion.
Sourcepub fn inplace(&mut self, position: Id) -> Value
pub fn inplace(&mut self, position: Id) -> Value
Register an output that uses the same resource as the input as the given position.
pub fn runtime_properties(&mut self, properties: TargetProperties)
pub fn device_properties(&mut self, properties: &DeviceProperties)
Sourcepub fn build(self, settings: KernelSettings) -> KernelDefinition
pub fn build(self, settings: KernelSettings) -> KernelDefinition
Build the kernel definition.
pub fn new() -> Self
Methods from Deref<Target = Scope>§
Sourcepub fn device_properties(&self, properties: &DeviceProperties)
pub fn device_properties(&self, properties: &DeviceProperties)
Set the device properties.
pub fn state(&self) -> Ref<'_, GlobalStateInner>
pub fn state_mut(&self) -> RefMut<'_, GlobalStateInner>
Sourcepub fn create_value(&self, ty: Type) -> Value
pub fn create_value(&self, ty: Type) -> Value
Create a new immutable value of type specified by ty.
Sourcepub fn create_local_mut(&self, value_ty: impl Into<Type>) -> Value
pub fn create_local_mut(&self, value_ty: impl Into<Type>) -> Value
Create a new mutable local variable of type specified by value_ty.
Create a shared variable of the given item type.
Sourcepub fn create_function(&self, explicit_params: Vec<Value>, scope: Scope) -> u32
pub fn create_function(&self, explicit_params: Vec<Value>, scope: Scope) -> u32
Create a new function.
Sourcepub fn register<T>(&self, instruction: T)where
T: Into<Instruction>,
pub fn register<T>(&self, instruction: T)where
T: Into<Instruction>,
Register an Instruction into the scope.
Sourcepub fn create_kernel_ref<'a, T>(&self, value: T) -> &'a mut Twhere
T: 'a,
pub fn create_kernel_ref<'a, T>(&self, value: T) -> &'a mut Twhere
T: 'a,
Add a value to the global arena so we can create a kernel-wide reference to it. The reference is the same as the type for simplicity, but is only valid for the duration of the root scope. Ensure the reference lifetime is shortened to the lifetime of the underlying variable being referenced.
Sourcepub fn resolve_type<T>(&self) -> Option<StorageType>where
T: 'static,
pub fn resolve_type<T>(&self) -> Option<StorageType>where
T: 'static,
Resolve the element type of the given generic type.
Sourcepub fn resolve_size<T>(&self) -> Option<usize>where
T: 'static,
pub fn resolve_size<T>(&self) -> Option<usize>where
T: 'static,
Resolve the comptime size of the given generic size.
Sourcepub fn register_type<T>(&self, elem: StorageType)where
T: 'static,
pub fn register_type<T>(&self, elem: StorageType)where
T: 'static,
Register the element type for the given generic type.
Sourcepub fn register_size<T>(&self, size: usize)where
T: 'static,
pub fn register_size<T>(&self, size: usize)where
T: 'static,
Register the comptime size for the given generic size.
pub fn push_error(&self, msg: impl Into<String>)
Sourcepub fn pop_errors(&self) -> Vec<String>
pub fn pop_errors(&self) -> Vec<String>
Returns all validation errors.
Sourcepub fn process<'a>(
&self,
processors: impl IntoIterator<Item = &'a dyn Processor>,
) -> ScopeProcessing
pub fn process<'a>( &self, processors: impl IntoIterator<Item = &'a dyn Processor>, ) -> ScopeProcessing
Returns the operations to be declared and executed.
Notes:
New operations can be created within the same scope without having name conflicts.
pub fn new_local_index(&self) -> u32
Sourcepub fn tensor_map(&self, id: u32) -> Value
pub fn tensor_map(&self, id: u32) -> Value
Obtain the index-th tensor map
pub fn update_source(&self, source: CubeFnSource)
pub fn register_all(&self, instructions: impl IntoIterator<Item = Instruction>)
pub fn take_instructions(&self) -> Vec<Instruction>
pub fn update_span(&self, line: u32, col: u32)
pub fn update_value_name( &self, value: Value, name: impl Into<Cow<'static, str>>, )
pub fn extract_field(&self, aggregate: Value, ty: Type, field: usize) -> Value
Trait Implementations§
Source§impl Default for KernelBuilder
impl Default for KernelBuilder
Auto Trait Implementations§
impl !Freeze for KernelBuilder
impl !RefUnwindSafe for KernelBuilder
impl !Send for KernelBuilder
impl !Sync for KernelBuilder
impl !UnwindSafe for KernelBuilder
impl Unpin for KernelBuilder
impl UnsafeUnpin for KernelBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more