For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
pad_constant
def pad_constant[rank: Int, dtype: DType, padding_type: DType](output: Pointer[Scalar[dtype], _safe=False], output_shape: IndexList[rank], input: Pointer[Scalar[dtype], _safe=False], input_shape: IndexList[rank], paddings: Pointer[Scalar[padding_type], _safe=False], 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 (
Pointer[Scalar[dtype], _safe=False]): The output buffer. - βoutput_shape (
IndexList[rank]): The output shape. - βinput (
Pointer[Scalar[dtype], _safe=False]): The input buffer. - βinput_shape (
IndexList[rank]): The input shape. - βpaddings (
Pointer[Scalar[padding_type], _safe=False]): Ordered (before, after) padding sizes for each axis. - βconstant (
Scalar[dtype]): The constant to pad output with. - βctx (
DeviceContext): Device context for participating GPU.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!