Skip to main content
Log in

Mojo function

pad_constant

pad_constant[rank: Int, output_shape: DimList, input_shape: DimList, type: DType, paddings_type: DType, constant_type: DType](output: NDBuffer[type, rank, origin, output_shape], input: NDBuffer[type, rank, origin, input_shape], paddings: UnsafePointer[SIMD[paddings_type, 1]], constant: SIMD[constant_type, 1])

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 (NDBuffer[type, rank, origin, output_shape]): The output buffer.
  • input (NDBuffer[type, rank, origin, input_shape]): The input buffer.
  • paddings (UnsafePointer[SIMD[paddings_type, 1]]): Ordered (before, after) padding sizes for each axis.
  • constant (SIMD[constant_type, 1]): The constant to pad output with.

Was this page helpful?