Skip to contents

Pads an array with a given padding value.

Usage

prim_pad(
  operand,
  padding_value,
  edge_padding_low,
  edge_padding_high,
  interior_padding
)

Arguments

operand

(arrayish)
Arrayish value of any data type.

padding_value

(arrayish)
Scalar value to use for padding. Must have the same dtype as operand.

edge_padding_low

(integer())
Amount of padding to add at the start of each dimension.

edge_padding_high

(integer())
Amount of padding to add at the end of each dimension.

interior_padding

(integer())
Amount of padding to add between elements in each dimension.

Value

arrayish
Has the same data type as operand. For the output shape see the underlying stablehlo documentation (stablehlo::hlo_pad()). It is ambiguous if the input is ambiguous.

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to stablehlo::hlo_pad().

Examples

x <- nv_array(c(1, 2, 3))
prim_pad(x, nv_scalar(0),
  edge_padding_low = 2L, edge_padding_high = 1L, interior_padding = 0L
)
#> AnvlArray
#>  0
#>  0
#>  1
#>  2
#>  3
#>  0
#> [ CPUf32{6} ]