For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
pad_constant
def pad_constant[dtype: DType, padding_type: DType](output: MutPointer[Scalar[dtype]], output_shape: Coord[*output_shape.element_types], input: ImmPointer[Scalar[dtype]], input_shape: Coord[*input_shape.element_types], paddings: ImmPointer[Scalar[padding_type]], constant: Scalar[dtype], ctx: DeviceContext)
Fill output with values from input, and edges padded with constant based on paddings.
Example:
var input_shape = (X, Y, Z)
var paddings = [x0, x1, y0, y1, z0, z1]
out[x, y, z] =
input[x - x0, y - y0, z - z0] if x ∈ [x0, x0 + X] &&
y ∈ [y0, y0 + Y] &&
z ∈ [z0, z0 + Z]
else constantArgs:
- output (
MutPointer[Scalar[dtype]]): The output buffer. - output_shape (
Coord[*output_shape.element_types]): The output shape. - input (
ImmPointer[Scalar[dtype]]): The input buffer. - input_shape (
Coord[*input_shape.element_types]): The input shape. - paddings (
ImmPointer[Scalar[padding_type]]): Ordered (before, after) padding sizes for each axis. - constant (
Scalar[dtype]): The constant to pad output with. - ctx (
DeviceContext): Device context for participating GPU.
def pad_constant[dtype: DType, padding_type: DType](output: MutPointer[Scalar[dtype]], output_shape: Coord[*output_shape.element_types], input: TileTensor[dtype, Engine=input.Engine, linear_idx_type=input.linear_idx_type], paddings: ImmPointer[Scalar[padding_type]], constant: Scalar[dtype], ctx: DeviceContext)
Fill output with values from input, and edges padded with constant based on paddings.
Args:
- output (
MutPointer[Scalar[dtype]]): The output buffer. - output_shape (
Coord[*output_shape.element_types]): The output shape. - input (
TileTensor[dtype, Engine=input.Engine, linear_idx_type=input.linear_idx_type]): The input tensor, copied with its own layout. - paddings (
ImmPointer[Scalar[padding_type]]): Ordered (before, after) padding sizes for each axis. - constant (
Scalar[dtype]): The constant to pad output with. - ctx (
DeviceContext): Device context for participating GPU.