Skip to contents

Create a input to a function

Usage

hlo_input(name, dtype, shape = integer(), func = .current_func(), alias = NULL)

Arguments

name

(character(1))
The name of the parameter.

dtype

(ValueType)
The element type of the parameter. Can contain digits, letters and underscores. If it starts with a digit, it can only contain digits. Otherwise it must start with a letter.

shape

(integer())
The shape of the parameter. Use integer() for scalars.

func

(Func)
The function id of the parameter. Per default, uses the last function created with hlo_func.

alias

(integer(1) or NULL)
If integer, marks this input as alias with the given output index (0-based).

Examples

func <- hlo_func()
x <- hlo_input("x", "f32", shape = c(2, 2))
print(x)
#> Variable %x in:
#> func.func @main (%x: tensor<2x2xf32>) ->  {
#> 
#> }

# You can combine multiple inputs as follows:
c(
  hlo_input("x", "f32", shape = c(2, 2)),
  hlo_input("y", "f32", shape = c(2, 2))
)
#> [[1]]
#> Variable %x in:
#> func.func @main (%x: tensor<2x2xf32>, %x: tensor<2x2xf32>, %y: tensor<2x2xf32>) ->  {
#> 
#> }
#> 
#> [[2]]
#> Variable %y in:
#> func.func @main (%x: tensor<2x2xf32>, %x: tensor<2x2xf32>, %y: tensor<2x2xf32>) ->  {
#> 
#> }
#>