Skip to contents

Adds two arrays element-wise.

Usage

prim_add(lhs, rhs)

Arguments

lhs, rhs

(arrayish)
Two inputs of the same data type and shape. Can be any data type. R values assume the other operand's data type when it is in their data type category, and their default data type when neither operand has one.

Value

(arrayish)
Has the inputs' shape and data type.

Implemented Rules

  • stablehlo

  • quickr

  • reverse

StableHLO

Lowers to hlo_add(), specified under add.

See also

Examples

# two R values: both take an R double's default data type
prim_add(1, 2)
#> AnvlArray
#>  3
#> [ CPUf32{} ] 

# the R value is built at the array's data type instead
prim_add(1, nv_scalar(2, "f64"))
#> AnvlArray
#>  3
#> [ CPUf64{} ]