Mojo function
pad_constant
pad_constant[output_layout: Layout, input_layout: Layout, dtype: DType, paddings_type: DType, constant_type: DType](output: LayoutTensor[dtype, output_layout, origin, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment], input: LayoutTensor[dtype, input_layout, origin, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment], paddings: UnsafePointer[Scalar[paddings_type]], constant: Scalar[constant_type])
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 constant
Args:
- output (LayoutTensor): The output buffer.
- input (LayoutTensor): The input buffer.
- paddings (UnsafePointer): Ordered (before, after) padding sizes for each axis.
- constant (Scalar): The constant to pad output with.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
