Skip to main content

KernelBuilder

Struct KernelBuilder 

Source
pub struct KernelBuilder {
    pub scope: Scope,
    /* private fields */
}
Expand description

Prepare a kernel to create a KernelDefinition.

Fields§

§scope: Scope

Cube scope.

Implementations§

Source§

impl KernelBuilder

Source

pub fn scalar(&mut self, storage: StorageType) -> Id

Register a scalar and return the element to be used for kernel expansion.

Source

pub fn buffer(&mut self, value_ty: Type) -> Value

Register a buffer and return the element to be used for kernel expansion.

Source

pub fn tensor(&mut self, value_ty: Type) -> Value

Register a tensor and return the element to be used for kernel expansion.

Source

pub fn tensor_map(&mut self) -> Value

Register a tensor map and return the element to be used for kernel expansion.

Source

pub fn inplace(&mut self, position: Id) -> Value

Register an output that uses the same resource as the input as the given position.

Source

pub fn runtime_properties(&mut self, properties: TargetProperties)

Source

pub fn device_properties(&mut self, properties: &DeviceProperties)

Source

pub fn build(self, settings: KernelSettings) -> KernelDefinition

Build the kernel definition.

Source

pub fn new() -> Self

Methods from Deref<Target = Scope>§

Source

pub fn device_properties(&self, properties: &DeviceProperties)

Set the device properties.

Source

pub fn state(&self) -> Ref<'_, GlobalStateInner>

Source

pub fn state_mut(&self) -> RefMut<'_, GlobalStateInner>

Source

pub fn create_value(&self, ty: Type) -> Value

Create a new immutable value of type specified by ty.

Source

pub fn create_local_mut(&self, value_ty: impl Into<Type>) -> Value

Create a new mutable local variable of type specified by value_ty.

Source

pub fn create_shared( &self, value_ty: impl Into<Type>, alignment: Option<usize>, ) -> Value

Create a shared variable of the given item type.

Source

pub fn create_function(&self, explicit_params: Vec<Value>, scope: Scope) -> u32

Create a new function.

Source

pub fn register<T>(&self, instruction: T)
where T: Into<Instruction>,

Register an Instruction into the scope.

Source

pub fn create_kernel_ref<'a, T>(&self, value: T) -> &'a mut T
where 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.

Source

pub fn resolve_type<T>(&self) -> Option<StorageType>
where T: 'static,

Resolve the element type of the given generic type.

Source

pub fn resolve_size<T>(&self) -> Option<usize>
where T: 'static,

Resolve the comptime size of the given generic size.

Source

pub fn register_type<T>(&self, elem: StorageType)
where T: 'static,

Register the element type for the given generic type.

Source

pub fn register_size<T>(&self, size: usize)
where T: 'static,

Register the comptime size for the given generic size.

Source

pub fn child(&self) -> Scope

Create an empty child scope.

Source

pub fn push_error(&self, msg: impl Into<String>)

Source

pub fn pop_errors(&self) -> Vec<String>

Returns all validation errors.

Source

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.

Source

pub fn new_local_index(&self) -> u32

Source

pub fn global(&self, id: u32, value_ty: Type) -> Value

Obtain the index-th buffer

Source

pub fn tensor_map(&self, id: u32) -> Value

Obtain the index-th tensor map

Source

pub fn update_source(&self, source: CubeFnSource)

Source

pub fn register_all(&self, instructions: impl IntoIterator<Item = Instruction>)

Source

pub fn take_instructions(&self) -> Vec<Instruction>

Source

pub fn update_span(&self, line: u32, col: u32)

Source

pub fn update_value_name( &self, value: Value, name: impl Into<Cow<'static, str>>, )

Source

pub fn extract_field(&self, aggregate: Value, ty: Type, field: usize) -> Value

Trait Implementations§

Source§

impl Default for KernelBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for KernelBuilder

Source§

type Target = Scope

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.