Skip to contents

Pads a tensor with a given value at the edges and optionally between elements.

Usage

nv_pad(
  operand,
  padding_value,
  edge_padding_low,
  edge_padding_high,
  interior_padding = NULL
)

Arguments

operand

(tensorish)
Operand.

padding_value

(tensorish)
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() | NULL)
Amount of padding to add between elements in each dimension. If NULL (default), no interior padding is applied.

Value

tensorish
Has the same data type as operand.

See also

nvl_pad() for the underlying primitive.

Examples

jit_eval({
  x <- nv_tensor(c(1, 2, 3))
  nv_pad(x, nv_scalar(0), edge_padding_low = 2L, edge_padding_high = 1L)
})
#> AnvilTensor
#>  0
#>  0
#>  1
#>  2
#>  3
#>  0
#> [ CPUf32{6} ]