Skip to contents

Broadcast scalar tensors to match the shape of non-scalar tensors. All non-scalar tensors must have the same shape.

Usage

nv_broadcast_scalars(...)

Arguments

...

(tensorish)
Tensors to broadcast. Scalars will be broadcast to the common non-scalar shape.

Value

(list() of tensorish)
List of broadcasted tensors.

Examples

jit_eval({
  x <- nv_tensor(c(1, 2, 3))
  # scalar 1 is broadcast to shape [3]
  nv_broadcast_scalars(x, 1)
})
#> [[1]]
#> AnvilTensor
#>  1
#>  2
#>  3
#> [ CPUf32{3} ] 
#> 
#> [[2]]
#> AnvilTensor
#>  1
#>  1
#>  1
#> [ CPUf32?{3} ] 
#>