Skip to main content

cubecl_tile/tile/kind/procedural/
constant.rs

1use cubecl::prelude::*;
2
3use super::{Reads, Recipe, RecipeCoords, RecipeExpand};
4
5/// A procedural field holding one value, which may be a runtime scalar.
6#[derive(CubeType, Clone)]
7pub struct Constant<T: Numeric> {
8    pub value: T,
9}
10
11#[cube]
12impl<T: Numeric> Recipe<T> for Constant<T> {
13    fn evaluate(&self, _coordinates: &RecipeCoords) -> T {
14        self.value
15    }
16}
17
18impl<T: Numeric> Reads for ConstantExpand<T> {
19    fn reads(&self, _scope: &Scope, _axis: crate::Axis) -> bool {
20        false
21    }
22}