| Title: | Write stableHLO programs |
|---|---|
| Description: | The package offers a low level interface to create stableHLO programs. These programs can be compiled and run on different hardware backends (CPU, GPU, ...) using the 'pjrt' package. |
| Authors: | Daniel Falbel [aut] (ORCID: <https://orcid.org/0009-0006-0143-2392>), Sebastian Fischer [aut, cre] (ORCID: <https://orcid.org/0000-0002-9609-3197>), Nikolai German [aut] (ORCID: <https://orcid.org/0009-0001-7394-8367>) |
| Maintainer: | Sebastian Fischer <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-06-03 11:50:03 UTC |
| Source: | https://github.com/r-xla/stablehlo |
Get the last function created (either via hlo_func or local_func),
which is not returned yet.
.current_func().current_func()
A Func object.
Get the current module created via hlo_module or local_module.
.current_module().current_module()
A Module object.
An attribute holding a boolean value.
BoolAttr(name, value)BoolAttr(name, value)
name |
( |
value |
( |
BoolAttr
This represents a constant value.
Constant(data, type)Constant(data, type)
data |
(any) |
type |
( |
Constant
Helper function to create a ConstantAttr from R values.
constant_attr(name, value, dtype = NULL, shape = NULL, simplify_dense = TRUE)constant_attr(name, value, dtype = NULL, shape = NULL, simplify_dense = TRUE)
name |
( |
value |
(any) |
dtype |
( |
shape |
( |
simplify_dense |
( |
(ConstantAttr)
An attribute holding a constant value.
ConstantAttr(name, value, simplify_dense = TRUE)ConstantAttr(name, value, simplify_dense = TRUE)
name |
( |
value |
( |
simplify_dense |
( |
(ConstantAttr)
A backend configuration as a list of typed attributes for custom operations.
Each element must be a BoolAttr, StringAttr, or ScalarAttr for now.
All attribute names must be unique.
CustomOpBackendConfig(items = list())CustomOpBackendConfig(items = list())
items |
( |
CustomOpBackendConfig
Represents the dot dimension numbers.
DotDimensionNumbers(contracting_dims, batching_dims = NULL)DotDimensionNumbers(contracting_dims, batching_dims = NULL)
contracting_dims |
( |
batching_dims |
( |
Error when input shapes don't match (except at given dimensions)
error_concatenate_shapes( dimensions, shapes, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_concatenate_shapes( dimensions, shapes, call = sys.call(-1)[1L], class = character(), signal = TRUE )
dimensions |
( |
shapes |
( |
call |
( |
class |
( |
signal |
( |
Error when a dimension size doesn't match the expected size at a given index
error_dim_size_mismatch( arg1, arg2, dim1, dim2, shape1, shape2, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_dim_size_mismatch( arg1, arg2, dim1, dim2, shape1, shape2, call = sys.call(-1)[1L], class = character(), signal = TRUE )
arg1 |
( |
arg2 |
( |
dim1 |
( |
dim2 |
( |
shape1 |
( |
shape2 |
( |
call |
( |
class |
( |
signal |
( |
Error when dimension indices are not unique
error_dimension_uniqueness( arg, dimensions, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_dimension_uniqueness( arg, dimensions, call = sys.call(-1)[1L], class = character(), signal = TRUE )
arg |
( |
dimensions |
( |
call |
( |
class |
( |
signal |
( |
Error when an index is found in a forbidden set
error_index_in_set( arg1, arg2, index, set, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_index_in_set( arg1, arg2, index, set, call = sys.call(-1)[1L], class = character(), signal = TRUE )
arg1 |
( |
arg2 |
( |
index |
( |
set |
( |
call |
( |
class |
( |
signal |
( |
Error when an index is outside the valid range [lower, upper)
error_index_out_of_bounds( arg, index, lower, upper, call = sys.call(-1), class = character(), signal = TRUE )error_index_out_of_bounds( arg, index, lower, upper, call = sys.call(-1), class = character(), signal = TRUE )
arg |
( |
index |
( |
lower |
( |
upper |
( |
call |
( |
class |
( |
signal |
( |
Error when indices are not sorted in ascending order
error_indices_not_sorted( arg, indices, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_indices_not_sorted( arg, indices, call = sys.call(-1)[1L], class = character(), signal = TRUE )
arg |
( |
indices |
( |
call |
( |
class |
( |
signal |
( |
Error when permutation values are invalid (not a valid permutation of indices)
error_permute_index( arg, permutation, expected, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_permute_index( arg, permutation, expected, call = sys.call(-1)[1L], class = character(), signal = TRUE )
arg |
( |
permutation |
( |
expected |
( |
call |
( |
class |
( |
signal |
( |
Base error class for all stablehlo errors
error_stablehlo( call = sys.call(-1)[1L], ..., class = character(), signal = TRUE )error_stablehlo( call = sys.call(-1)[1L], ..., class = character(), signal = TRUE )
call |
( |
... |
Additional fields to store in the condition |
class |
( |
signal |
( |
Error when types at the same index in two lists don't match
error_unequal_types( arg1, arg2, index, expected, actual1, actual2, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_unequal_types( arg1, arg2, index, expected, actual1, actual2, call = sys.call(-1)[1L], class = character(), signal = TRUE )
arg1 |
( |
arg2 |
( |
index |
( |
expected |
( |
actual1 |
Type from the first argument (any object with a cli_format method) |
actual2 |
Type from the second argument (any object with a cli_format method) |
call |
( |
class |
( |
signal |
( |
Error when an element in a list has an unexpected type
error_unexpected_list_type( arg, index, expected, actual, call = sys.call(-1)[1L], class = character(), signal = TRUE )error_unexpected_list_type( arg, index, expected, actual, call = sys.call(-1)[1L], class = character(), signal = TRUE )
arg |
( |
index |
( |
expected |
( |
actual |
( |
call |
( |
class |
( |
signal |
( |
Formats a double array using scientific notation with 16 digits precision,
similar to formatC(x, digits = 16, format = "e").
This is used to embed floating point constants into stableHLO programs.
format_double(x, precision = 64)format_double(x, precision = 64)
x |
( |
precision |
( |
character()
format_double(1.23, 32) format_double(1.23, 64)format_double(1.23, 32) format_double(1.23, 64)
This represents a function. Note: Func uses reference semantics - modifications to a Func object modify the original.
Func( id = FuncId(), inputs = FuncInputs(), outputs = FuncOutputs(), body = FuncBody() )Func( id = FuncId(), inputs = FuncInputs(), outputs = FuncOutputs(), body = FuncBody() )
id |
( |
inputs |
( |
outputs |
( |
body |
( |
A Func object.
This represents the id of a function.
FuncId(id = "main")FuncId(id = "main")
id |
The id of the function. |
This represents an input of a Func.
FuncInput(id, type, alias = NULL)FuncInput(id, type, alias = NULL)
id |
( |
type |
( |
alias |
( |
(FuncInput)
List of FuncInputs.
FuncInputs(items = list())FuncInputs(items = list())
items |
( |
(FuncInputs)
This represents an output of a Func.
FuncOutput(type)FuncOutput(type)
type |
( |
(FuncOutput)
List of FuncOutputs.
FuncOutputs(items = list())FuncOutputs(items = list())
items |
( |
(FuncOutputs)
This represents a variable within a function.
FuncValue(value_id, value_type, func)FuncValue(value_id, value_type, func)
value_id |
The name of the variable. |
value_type |
The type of the variable. |
func |
The function the variable belongs to. |
Represents the gather dimension numbers.
GatherDimensionNumbers( offset_dims, collapsed_slice_dims, operand_batching_dims = integer(), start_indices_batching_dims = integer(), start_index_map, index_vector_dim )GatherDimensionNumbers( offset_dims, collapsed_slice_dims, operand_batching_dims = integer(), start_indices_batching_dims = integer(), start_index_map, index_vector_dim )
offset_dims |
( |
collapsed_slice_dims |
( |
operand_batching_dims |
( |
start_indices_batching_dims |
( |
start_index_map |
( |
index_vector_dim |
( |
See https://openxla.org/stablehlo/spec#cholesky for details.
hlo_cholesky(operand, lower)hlo_cholesky(operand, lower)
operand, lower
|
The values of the other half of the matrix are not guaranteed and backend dependent.
Creates a new function without any arguments that captures the provided variables.
hlo_closure(...)hlo_closure(...)
... |
( |
(list() of FuncValue)
func <- local_func() x <- hlo_input("x", "f32", shape = c(2, 2)) y <- hlo_input("y", "f32", shape = c(2, 2)) f <- hlo_closure(x, y) print(f)func <- local_func() x <- hlo_input("x", "f32", shape = c(2, 2)) y <- hlo_input("y", "f32", shape = c(2, 2)) f <- hlo_closure(x, y) print(f)
Create either a "scalar" (hlo_scalar) or tensor (hlo_tensor) constant.
Strictly speaking, stableHLO "scalars" are simply tensors with 0 dimensions.
To create an empty constant (at least one dimension is 0), use hlo_empty.
hlo_scalar(value, ..., dtype = NULL, func = NULL) hlo_tensor(value, ..., dtype = NULL, shape = NULL, func = NULL) hlo_empty(dtype, shape, func = NULL) infer_types_constant(value)hlo_scalar(value, ..., dtype = NULL, func = NULL) hlo_tensor(value, ..., dtype = NULL, shape = NULL, func = NULL) hlo_empty(dtype, shape, func = NULL) infer_types_constant(value)
value |
(any) |
... |
(any) |
dtype |
( |
func |
( |
shape |
( |
hlo_scalar(1L, dtype = "i32", func = Func()) hlo_scalar(1, dtype = "f32", func = Func()) hlo_scalar(TRUE, func = Func()) hlo_tensor(array(c(1, 2, 3, 4), dim = c(1, 4)), dtype = "f32", func = Func()) hlo_empty(dtype = "f32", shape = c(0, 3), func = Func())hlo_scalar(1L, dtype = "i32", func = Func()) hlo_scalar(1, dtype = "f32", func = Func()) hlo_scalar(TRUE, func = Func()) hlo_tensor(array(c(1, 2, 3, 4), dim = c(1, 4)), dtype = "f32", func = Func()) hlo_empty(dtype = "f32", shape = c(0, 3), func = Func())
Create a custom call operation that invokes an external function via the FFI (Foreign Function Interface) API.
Note that the attributes called_computations and output_operand_aliases are not
implemented yet.
hlo_custom_call( ..., call_target_name, api_version = 4L, has_side_effect, backend_config = NULL, output_types = NULL, operand_layouts = NULL, result_layouts = NULL )hlo_custom_call( ..., call_target_name, api_version = 4L, has_side_effect, backend_config = NULL, output_types = NULL, operand_layouts = NULL, result_layouts = NULL )
... |
( |
call_target_name |
( |
api_version |
( |
has_side_effect |
( |
backend_config |
( |
output_types |
( |
operand_layouts |
( |
result_layouts |
( |
(FuncValue | list() | NULL)
The output value(s), or NULL for side-effect only calls.
Both functions create a new Func with the given id which is afterwards accessible via .current_func().
Functions receiving a Func as an argument (such as hlo_input, hlo_add, ...) usually use
.current_func() by default.
You can also directly create a function using Func(), which will not be accessible this way.
Differences between the two functions:
local_func removes the function when exiting the current scope, whereas hlo_func does not.
hlo_func discards the previously built function(s), whereas local_func does not:
after a function created by local_func is either cleaned up automatically (by exiting the scope)
or the function is finalized via hlo_return, the previously built function is restored,
i.e., accessible via .current_func(). To build nested functions (e.g. to create a closure
that is passed to another op), use local_func instead of hlo_func.
hlo_func(id = "main") local_func(id = "main", envir = parent.frame())hlo_func(id = "main") local_func(id = "main", envir = parent.frame())
id |
( |
envir |
( |
A Func object.
Create a input to a function
hlo_input(name, dtype, shape = integer(), func = .current_func(), alias = NULL)hlo_input(name, dtype, shape = integer(), func = .current_func(), alias = NULL)
name |
( |
dtype |
( |
shape |
( |
func |
( |
alias |
( |
func <- hlo_func() x <- hlo_input("x", "f32", shape = c(2, 2)) print(x) # You can combine multiple inputs as follows: c( hlo_input("x", "f32", shape = c(2, 2)), hlo_input("y", "f32", shape = c(2, 2)) )func <- hlo_func() x <- hlo_input("x", "f32", shape = c(2, 2)) print(x) # You can combine multiple inputs as follows: c( hlo_input("x", "f32", shape = c(2, 2)), hlo_input("y", "f32", shape = c(2, 2)) )
Both functions create a new Module which is afterwards accessible via .current_module().
Functions created with hlo_func or local_func will automatically register into the
current module.
The module is finalized when a function named "main" is returned via hlo_return.
Differences between the two functions:
local_module removes the module when exiting the current scope, whereas hlo_module does not.
hlo_module discards the previously built module(s), whereas local_module does not.
hlo_module() local_module(envir = parent.frame())hlo_module() local_module(envir = parent.frame())
envir |
( |
A Module object.
Wraps an integer vector marking it as containing 0-based index values.
index_vec(x)index_vec(x)
x |
( |
An integer vector with additional class "IndexVector".
See https://openxla.org/stablehlo/spec#abs for details.
infer_types_abs(operand) hlo_abs(operand)infer_types_abs(operand) hlo_abs(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloacos_chloacosop for details.
infer_types_acos(operand) hlo_acos(operand)infer_types_acos(operand) hlo_acos(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloacosh_chloacoshop for details.
infer_types_acosh(operand) hlo_acosh(operand)infer_types_acosh(operand) hlo_acosh(operand)
operand |
See https://openxla.org/stablehlo/spec#add for details.
infer_types_add(lhs, rhs) hlo_add(lhs, rhs)infer_types_add(lhs, rhs) hlo_add(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#after_all for details.
infer_types_after_all(...) hlo_after_all(...)infer_types_after_all(...) hlo_after_all(...)
... |
See https://openxla.org/stablehlo/spec#and for details.
infer_types_and(lhs, rhs) hlo_and(lhs, rhs)infer_types_and(lhs, rhs) hlo_and(lhs, rhs)
lhs, rhs
|
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloasin_chloasinop for details.
infer_types_asin(operand) hlo_asin(operand)infer_types_asin(operand) hlo_asin(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloasinh_chloasinhop for details.
infer_types_asinh(operand) hlo_asinh(operand)infer_types_asinh(operand) hlo_asinh(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloatan_chloatanop for details.
infer_types_atan(operand) hlo_atan(operand)infer_types_atan(operand) hlo_atan(operand)
operand |
See https://openxla.org/stablehlo/spec#atan2 for details.
infer_types_atan2(lhs, rhs) hlo_atan2(lhs, rhs)infer_types_atan2(lhs, rhs) hlo_atan2(lhs, rhs)
lhs, rhs
|
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloatanh_chloatanhop for details.
infer_types_atanh(operand) hlo_atanh(operand)infer_types_atanh(operand) hlo_atanh(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlobessel_i1e_chlobessel_i1eop for details.
infer_types_bessel_i1e(operand) hlo_bessel_i1e(operand)infer_types_bessel_i1e(operand) hlo_bessel_i1e(operand)
operand |
See https://openxla.org/stablehlo/spec#bitcast_convert for details.
infer_types_bitcast_convert(operand, dtype) hlo_bitcast_convert(operand, dtype)infer_types_bitcast_convert(operand, dtype) hlo_bitcast_convert(operand, dtype)
operand, dtype
|
See https://openxla.org/stablehlo/spec#broadcast_in_dim for details.
infer_types_broadcast_in_dim(operand, broadcast_dimensions, shape) hlo_broadcast_in_dim(operand, broadcast_dimensions, shape)infer_types_broadcast_in_dim(operand, broadcast_dimensions, shape) hlo_broadcast_in_dim(operand, broadcast_dimensions, shape)
operand, broadcast_dimensions, shape
|
Calls a named function from within the current function being built.
The callee must already be finalized via hlo_return.
infer_types_call(callee, ...) hlo_call(callee, ..., simplify = TRUE)infer_types_call(callee, ...) hlo_call(callee, ..., simplify = TRUE)
callee |
|
... |
( |
simplify |
( |
FuncValue or list() of FuncValues.
See https://openxla.org/stablehlo/spec#case for details.
infer_types_case(index, ...) hlo_case(index, ...)infer_types_case(index, ...) hlo_case(index, ...)
index, ...
|
See https://openxla.org/stablehlo/spec#cbrt for details.
infer_types_cbrt(operand) hlo_cbrt(operand)infer_types_cbrt(operand) hlo_cbrt(operand)
operand |
See https://openxla.org/stablehlo/spec#ceil for details.
infer_types_ceil(operand) hlo_ceil(operand)infer_types_ceil(operand) hlo_ceil(operand)
operand |
See https://openxla.org/stablehlo/spec#clamp for details.
infer_types_clamp(min, operand, max) hlo_clamp(min, operand, max)infer_types_clamp(min, operand, max) hlo_clamp(min, operand, max)
min, operand, max
|
See https://openxla.org/stablehlo/spec#compare for details.
infer_types_compare(lhs, rhs, comparison_direction, compare_type) hlo_compare(lhs, rhs, comparison_direction, compare_type)infer_types_compare(lhs, rhs, comparison_direction, compare_type) hlo_compare(lhs, rhs, comparison_direction, compare_type)
lhs, rhs, comparison_direction, compare_type
|
See https://openxla.org/stablehlo/spec#concatenate for details.
infer_types_concatenate(..., dimension) hlo_concatenate(..., dimension)infer_types_concatenate(..., dimension) hlo_concatenate(..., dimension)
..., dimension
|
See https://openxla.org/stablehlo/spec#convert for details.
infer_types_convert(operand, dtype) hlo_convert(operand, dtype)infer_types_convert(operand, dtype) hlo_convert(operand, dtype)
operand, dtype
|
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlocosh_chlocoshop for details.
infer_types_cosh(operand) hlo_cosh(operand)infer_types_cosh(operand) hlo_cosh(operand)
operand |
See https://openxla.org/stablehlo/spec#cosine for details.
infer_types_cosine(operand) hlo_cosine(operand)infer_types_cosine(operand) hlo_cosine(operand)
operand |
See https://openxla.org/stablehlo/spec#count_leading_zeros for details.
infer_types_count_leading_zeros(operand) hlo_count_leading_zeros(operand)infer_types_count_leading_zeros(operand) hlo_count_leading_zeros(operand)
operand |
Infer the output types for a custom call operation.
infer_types_custom_call( ..., call_target_name, api_version, has_side_effect, backend_config, output_types, operand_layouts, result_layouts )infer_types_custom_call( ..., call_target_name, api_version, has_side_effect, backend_config, output_types, operand_layouts, result_layouts )
... |
Input values. |
call_target_name |
( |
api_version |
( |
has_side_effect |
( |
backend_config |
( |
output_types |
( |
operand_layouts, result_layouts
|
Layouts (not used for type inference). |
(ValueTypes)
The output types (empty for side-effect only calls).
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlodigamma_chlodigammaop for details.
infer_types_digamma(operand) hlo_digamma(operand)infer_types_digamma(operand) hlo_digamma(operand)
operand |
See https://openxla.org/stablehlo/spec#divide for details.
infer_types_divide(lhs, rhs) hlo_divide(lhs, rhs)infer_types_divide(lhs, rhs) hlo_divide(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#dot_general for details.
infer_types_dot_general(lhs, rhs, dot_dimension_numbers) hlo_dot_general(lhs, rhs, contracting_dims, batching_dims = NULL)infer_types_dot_general(lhs, rhs, dot_dimension_numbers) hlo_dot_general(lhs, rhs, contracting_dims, batching_dims = NULL)
lhs, rhs, contracting_dims, batching_dims
|
|
dot_dimension_numbers |
( |
See https://openxla.org/stablehlo/spec#dynamic_slice for details.
infer_types_dynamic_slice(operand, ..., slice_sizes) hlo_dynamic_slice(operand, ..., slice_sizes)infer_types_dynamic_slice(operand, ..., slice_sizes) hlo_dynamic_slice(operand, ..., slice_sizes)
operand, ..., slice_sizes
|
See https://openxla.org/stablehlo/spec#dynamic_update_slice for details.
infer_types_dynamic_update_slice(operand, update, ...) hlo_dynamic_update_slice(operand, update, ...)infer_types_dynamic_update_slice(operand, update, ...) hlo_dynamic_update_slice(operand, update, ...)
operand, update, ...
|
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloerf_chloerfop for details.
infer_types_erf(operand) hlo_erf(operand)infer_types_erf(operand) hlo_erf(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloerf_inv_chloerf_invop for details.
infer_types_erf_inv(operand) hlo_erf_inv(operand)infer_types_erf_inv(operand) hlo_erf_inv(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chloerfc_chloerfcop for details.
infer_types_erfc(operand) hlo_erfc(operand)infer_types_erfc(operand) hlo_erfc(operand)
operand |
See https://openxla.org/stablehlo/spec#exponential for details.
infer_types_exponential(operand) hlo_exponential(operand)infer_types_exponential(operand) hlo_exponential(operand)
operand |
See https://openxla.org/stablehlo/spec#exponential_minus_one for details.
infer_types_exponential_minus_one(operand) hlo_exponential_minus_one(operand)infer_types_exponential_minus_one(operand) hlo_exponential_minus_one(operand)
operand |
Infer the types for float binary operations.
infer_types_float_biv(lhs, rhs)infer_types_float_biv(lhs, rhs)
lhs |
( |
rhs |
( |
(ValueType)
The inferred type.
Infer the types for float unary operations.
infer_types_float_uni(operand)infer_types_float_uni(operand)
operand |
( |
(ValueType)
The inferred type.
See https://openxla.org/stablehlo/spec#floor for details.
infer_types_floor(operand) hlo_floor(operand)infer_types_floor(operand) hlo_floor(operand)
operand |
See https://openxla.org/stablehlo/spec#gather for details.
infer_types_gather( operand, start_indices, gather_dimension_numbers, slice_sizes, indices_are_sorted ) hlo_gather( operand, start_indices, gather_dimension_numbers, slice_sizes, indices_are_sorted = FALSE )infer_types_gather( operand, start_indices, gather_dimension_numbers, slice_sizes, indices_are_sorted ) hlo_gather( operand, start_indices, gather_dimension_numbers, slice_sizes, indices_are_sorted = FALSE )
operand, start_indices
|
|
gather_dimension_numbers |
( |
slice_sizes |
( |
indices_are_sorted |
( |
Infer the types for binary operations.
infer_types_generic_biv(lhs, rhs)infer_types_generic_biv(lhs, rhs)
lhs |
( |
rhs |
( |
(ValueType)
The inferred type.
Infer the types for unary operations.
infer_types_generic_uni(operand)infer_types_generic_uni(operand)
operand |
( |
(ValueType)
The inferred type.
See https://openxla.org/stablehlo/spec#if for details.
infer_types_if(pred, true_branch, false_branch) hlo_if(pred, true_branch, false_branch, simplify = TRUE)infer_types_if(pred, true_branch, false_branch) hlo_if(pred, true_branch, false_branch, simplify = TRUE)
pred, true_branch, false_branch
|
|
simplify |
( |
Infer the types for integer unary operations.
infer_types_integer_uni(operand)infer_types_integer_uni(operand)
operand |
( |
(ValueType)
The inferred type.
Infer the types for integerish (bool or int) binary operations.
infer_types_integerish_biv(lhs, rhs)infer_types_integerish_biv(lhs, rhs)
lhs |
( |
rhs |
( |
(ValueType)
The inferred type.
Infer the types for integerish (bool or int) unary operations.
infer_types_integerish_uni(operand)infer_types_integerish_uni(operand)
operand |
( |
(ValueType)
The inferred type.
See https://openxla.org/stablehlo/spec#iota for details.
infer_types_iota(iota_dimension, dtype, shape) hlo_iota(iota_dimension, dtype, shape, func = NULL)infer_types_iota(iota_dimension, dtype, shape) hlo_iota(iota_dimension, dtype, shape, func = NULL)
iota_dimension |
( |
dtype |
( |
shape |
( |
func |
( |
See https://openxla.org/stablehlo/spec#is_finite for details.
infer_types_is_finite(operand) hlo_is_finite(operand)infer_types_is_finite(operand) hlo_is_finite(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlois_inf_chlois_infop for details.
infer_types_is_inf(operand) hlo_is_inf(operand)infer_types_is_inf(operand) hlo_is_inf(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlois_neg_inf_chlois_neg_infop for details.
infer_types_is_neg_inf(operand) hlo_is_neg_inf(operand)infer_types_is_neg_inf(operand) hlo_is_neg_inf(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlois_pos_inf_chlois_pos_infop for details.
infer_types_is_pos_inf(operand) hlo_is_pos_inf(operand)infer_types_is_pos_inf(operand) hlo_is_pos_inf(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlolgamma_chlolgammaop for details.
infer_types_lgamma(operand) hlo_lgamma(operand)infer_types_lgamma(operand) hlo_lgamma(operand)
operand |
See https://openxla.org/stablehlo/spec#log for details.
infer_types_log(operand) hlo_log(operand)infer_types_log(operand) hlo_log(operand)
operand |
See https://openxla.org/stablehlo/spec#log_plus_one for details.
infer_types_log_plus_one(operand) hlo_log_plus_one(operand)infer_types_log_plus_one(operand) hlo_log_plus_one(operand)
operand |
See https://openxla.org/stablehlo/spec#logistic for details.
infer_types_logistic(operand) hlo_logistic(operand)infer_types_logistic(operand) hlo_logistic(operand)
operand |
See https://openxla.org/stablehlo/spec#maximum for details.
infer_types_maximum(lhs, rhs) hlo_maximum(lhs, rhs)infer_types_maximum(lhs, rhs) hlo_maximum(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#minimum for details.
infer_types_minimum(lhs, rhs) hlo_minimum(lhs, rhs)infer_types_minimum(lhs, rhs) hlo_minimum(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#multiply for details.
infer_types_multiply(lhs, rhs) hlo_multiply(lhs, rhs)infer_types_multiply(lhs, rhs) hlo_multiply(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#negate for details.
infer_types_negate(operand) hlo_negate(operand)infer_types_negate(operand) hlo_negate(operand)
operand |
See https://openxla.org/stablehlo/spec#not for details.
infer_types_not(operand) hlo_not(operand)infer_types_not(operand) hlo_not(operand)
operand |
Infer the types for numeric binary operations.
infer_types_numeric_biv(lhs, rhs)infer_types_numeric_biv(lhs, rhs)
lhs |
( |
rhs |
( |
(ValueType)
The inferred type.
Infer the types for numeric unary operations.
infer_types_numeric_uni(operand)infer_types_numeric_uni(operand)
operand |
( |
(ValueType)
The inferred type.
See https://openxla.org/stablehlo/spec#or for details.
infer_types_or(lhs, rhs) hlo_or(lhs, rhs)infer_types_or(lhs, rhs) hlo_or(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#pad for details.
infer_types_pad( operand, padding_value, edge_padding_low, edge_padding_high, interior_padding ) hlo_pad( operand, padding_value, edge_padding_low, edge_padding_high, interior_padding )infer_types_pad( operand, padding_value, edge_padding_low, edge_padding_high, interior_padding ) hlo_pad( operand, padding_value, edge_padding_low, edge_padding_high, interior_padding )
operand, padding_value, edge_padding_low, edge_padding_high, interior_padding
|
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlopolygamma_chlopolygammaop for details.
infer_types_polygamma(n, x) hlo_polygamma(n, x)infer_types_polygamma(n, x) hlo_polygamma(n, x)
n, x
|
See https://openxla.org/stablehlo/spec#popcnt for details.
infer_types_popcnt(operand) hlo_popcnt(operand)infer_types_popcnt(operand) hlo_popcnt(operand)
operand |
See https://openxla.org/stablehlo/spec#power for details.
infer_types_power(lhs, rhs) hlo_power(lhs, rhs)infer_types_power(lhs, rhs) hlo_power(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#reduce for details.
infer_types_reduce(inputs, init_values, body, dimensions) hlo_reduce(inputs, init_values, dimensions, body)infer_types_reduce(inputs, init_values, body, dimensions) hlo_reduce(inputs, init_values, dimensions, body)
inputs, init_values, dimensions, body
|
See https://openxla.org/stablehlo/spec#reduce_window for details.
infer_types_reduce_window( ..., body, window_dimensions, window_strides, base_dilations, window_dilations, padding ) hlo_reduce_window( inputs, init_values, window_dimensions, window_strides, base_dilations, window_dilations, padding, body )infer_types_reduce_window( ..., body, window_dimensions, window_strides, base_dilations, window_dilations, padding ) hlo_reduce_window( inputs, init_values, window_dimensions, window_strides, base_dilations, window_dilations, padding, body )
... |
(Inputs, Init values) |
body |
( |
window_dimensions |
( |
window_strides |
( |
base_dilations |
( |
window_dilations |
( |
padding |
( |
inputs |
( |
init_values |
( |
See https://openxla.org/stablehlo/spec#remainder for details.
infer_types_remainder(lhs, rhs) hlo_remainder(lhs, rhs)infer_types_remainder(lhs, rhs) hlo_remainder(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#reshape for details.
infer_types_reshape(operand, shape) hlo_reshape(operand, shape)infer_types_reshape(operand, shape) hlo_reshape(operand, shape)
operand, shape
|
Specifies the return values of a Func and finalize it.
infer_types_return(...) hlo_return(..., func = .current_func())infer_types_return(...) hlo_return(..., func = .current_func())
... |
( |
func |
( |
(Func)
See https://openxla.org/stablehlo/spec#reverse for details.
infer_types_reverse(operand, dimensions) hlo_reverse(operand, dimensions)infer_types_reverse(operand, dimensions) hlo_reverse(operand, dimensions)
operand, dimensions
|
See https://openxla.org/stablehlo/spec#rng_bit_generator for details.
infer_types_rng_bit_generator(initial_state, rng_algorithm, dtype, shape) hlo_rng_bit_generator( initial_state, rng_algorithm = c("DEFAULT", "THREE_FRY", "PHILOX"), dtype, shape )infer_types_rng_bit_generator(initial_state, rng_algorithm, dtype, shape) hlo_rng_bit_generator( initial_state, rng_algorithm = c("DEFAULT", "THREE_FRY", "PHILOX"), dtype, shape )
initial_state, rng_algorithm, dtype, shape
|
See https://openxla.org/stablehlo/spec#round_nearest_afz for details.
infer_types_round_nearest_afz(operand) hlo_round_nearest_afz(operand)infer_types_round_nearest_afz(operand) hlo_round_nearest_afz(operand)
operand |
See https://openxla.org/stablehlo/spec#round_nearest_even for details.
infer_types_round_nearest_even(operand) hlo_round_nearest_even(operand)infer_types_round_nearest_even(operand) hlo_round_nearest_even(operand)
operand |
See https://openxla.org/stablehlo/spec#rsqrt for details.
infer_types_rsqrt(operand) hlo_rsqrt(operand)infer_types_rsqrt(operand) hlo_rsqrt(operand)
operand |
See https://openxla.org/stablehlo/spec#scatter for details.
infer_types_scatter( inputs, scatter_indices, updates, scatter_dimension_numbers, indices_are_sorted, unique_indices, update_computation ) hlo_scatter( inputs, scatter_indices, updates, scatter_dimension_numbers, indices_are_sorted = FALSE, unique_indices = FALSE, update_computation )infer_types_scatter( inputs, scatter_indices, updates, scatter_dimension_numbers, indices_are_sorted, unique_indices, update_computation ) hlo_scatter( inputs, scatter_indices, updates, scatter_dimension_numbers, indices_are_sorted = FALSE, unique_indices = FALSE, update_computation )
inputs, scatter_indices, updates
|
|
scatter_dimension_numbers |
( |
indices_are_sorted |
( |
unique_indices |
( |
update_computation |
( |
See https://openxla.org/stablehlo/spec#select for details.
infer_types_select(pred, on_true, on_false) hlo_select(pred, on_true, on_false)infer_types_select(pred, on_true, on_false) hlo_select(pred, on_true, on_false)
pred, on_true, on_false
|
See https://openxla.org/stablehlo/spec#shift_left for details.
infer_types_shift_left(lhs, rhs) hlo_shift_left(lhs, rhs)infer_types_shift_left(lhs, rhs) hlo_shift_left(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#shift_right_arithmetic for details.
infer_types_shift_right_arithmetic(lhs, rhs) hlo_shift_right_arithmetic(lhs, rhs)infer_types_shift_right_arithmetic(lhs, rhs) hlo_shift_right_arithmetic(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#shift_right_logical for details.
infer_types_shift_right_logical(lhs, rhs) hlo_shift_right_logical(lhs, rhs)infer_types_shift_right_logical(lhs, rhs) hlo_shift_right_logical(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#sign for details.
infer_types_sign(operand) hlo_sign(operand)infer_types_sign(operand) hlo_sign(operand)
operand |
See https://openxla.org/stablehlo/spec#sine for details.
infer_types_sine(operand) hlo_sine(operand)infer_types_sine(operand) hlo_sine(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlosinh_chlosinhop for details.
infer_types_sinh(operand) hlo_sinh(operand)infer_types_sinh(operand) hlo_sinh(operand)
operand |
See https://openxla.org/stablehlo/spec#slice for details.
infer_types_slice(operand, start_indices, limit_indices, strides) hlo_slice(operand, start_indices, limit_indices, strides)infer_types_slice(operand, start_indices, limit_indices, strides) hlo_slice(operand, start_indices, limit_indices, strides)
operand, start_indices, limit_indices, strides
|
See https://openxla.org/stablehlo/spec#sort for details.
infer_types_sort(..., dimension, is_stable, comparator) hlo_sort(..., dimension, is_stable, comparator)infer_types_sort(..., dimension, is_stable, comparator) hlo_sort(..., dimension, is_stable, comparator)
..., dimension, is_stable, comparator
|
See https://openxla.org/stablehlo/spec#sqrt for details.
infer_types_sqrt(operand) hlo_sqrt(operand)infer_types_sqrt(operand) hlo_sqrt(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlosquare_chlosquareop for details.
infer_types_square(operand) hlo_square(operand)infer_types_square(operand) hlo_square(operand)
operand |
See https://openxla.org/stablehlo/spec#subtract for details.
infer_types_subtract(lhs, rhs) hlo_subtract(lhs, rhs)infer_types_subtract(lhs, rhs) hlo_subtract(lhs, rhs)
lhs, rhs
|
See https://openxla.org/stablehlo/spec#tan for details.
infer_types_tan(operand) hlo_tan(operand)infer_types_tan(operand) hlo_tan(operand)
operand |
See https://openxla.org/stablehlo/spec#tanh for details.
infer_types_tanh(operand) hlo_tanh(operand)infer_types_tanh(operand) hlo_tanh(operand)
operand |
This op is from the CHLO dialect, a higher-level companion to stableHLO that is lowered to stableHLO during compilation. See https://openxla.org/stablehlo/generated/chlo#chlotop_k_chlotop_kop for details.
infer_types_top_k(operand, k) hlo_top_k(operand, k)infer_types_top_k(operand, k) hlo_top_k(operand, k)
operand |
( |
k |
( |
A list() of two FuncValues: the top-k values (same dtype as
operand) and their indices into the last dimension (dtype i32). Ties
are broken by lower index first.
See https://openxla.org/stablehlo/spec#transpose for details.
infer_types_transpose(operand, permutation) hlo_transpose(operand, permutation)infer_types_transpose(operand, permutation) hlo_transpose(operand, permutation)
operand, permutation
|
See https://openxla.org/stablehlo/spec#triangular_solve for details.
infer_types_triangular_solve( a, b, left_side, lower, unit_diagonal, transpose_a ) hlo_triangular_solve(a, b, left_side, lower, unit_diagonal, transpose_a)infer_types_triangular_solve( a, b, left_side, lower, unit_diagonal, transpose_a ) hlo_triangular_solve(a, b, left_side, lower, unit_diagonal, transpose_a)
a, b
|
|
left_side |
( |
lower |
( |
unit_diagonal |
( |
transpose_a |
( |
See https://openxla.org/stablehlo/spec#while for details.
infer_types_while(..., cond, body) hlo_while(..., cond, body, simplify = TRUE)infer_types_while(..., cond, body) hlo_while(..., cond, body, simplify = TRUE)
..., cond, body
|
|
simplify |
( |
See https://openxla.org/stablehlo/spec#xor for details.
infer_types_xor(lhs, rhs) hlo_xor(lhs, rhs)infer_types_xor(lhs, rhs) hlo_xor(lhs, rhs)
lhs, rhs
|
A StableHLO module containing one or more Func objects.
Modules allow defining multiple named functions, where functions can
call each other using hlo_call.
Note: Module uses reference semantics like Func.
Module(funcs = list())Module(funcs = list())
funcs |
( |
A Module object.
This represents a StableHLO operation.
Op(name, inputs, outputs, signature)Op(name, inputs, outputs, signature)
name |
( |
inputs |
( |
outputs |
( |
signature |
( |
(Op)
Base class for operation input attributes.
OpInputAttr(name, value, dtype)OpInputAttr(name, value, dtype)
name |
( |
value |
(any) |
dtype |
( |
(OpInputAttr)
List of OpInputAttrs.
OpInputAttrs(items = list())OpInputAttrs(items = list())
items |
( |
(OpInputAttrs)
This represents a function that can be used as input to an operation.
OpInputFunc(inputs, body)OpInputFunc(inputs, body)
inputs |
( |
body |
( |
(OpInputFunc)
List of OpInputFuncs.
OpInputFuncs(items = list())OpInputFuncs(items = list())
items |
( |
(OpInputFuncs)
This represents all the inputs to an operation, including values, functions, and attributes.
OpInputs( values, funcs = OpInputFuncs(), attrs = OpInputAttrs(), custom_attrs = list() )OpInputs( values, funcs = OpInputFuncs(), attrs = OpInputAttrs(), custom_attrs = list() )
values |
( |
funcs |
( |
attrs |
( |
custom_attrs |
( |
(OpInputs)
This represents a value that can be used as input to an operation.
OpInputValue(id)OpInputValue(id)
id |
( |
(OpInputValue)
List of OpInputValues.
OpInputValues(items = list())OpInputValues(items = list())
items |
( |
(OpInputValues)
This represents the name of an operation, containing a mnemonic and a dialect.
OpName(mnemonic, dialect = "stablehlo")OpName(mnemonic, dialect = "stablehlo")
mnemonic |
( |
dialect |
( |
(OpName)
This represents the signature of an operation, defining its input and output types.
OpSignature(input_types, output_types)OpSignature(input_types, output_types)
input_types |
( |
output_types |
( |
(OpSignature)
Convert R value to Constant.
r_to_constant(value, dtype = NULL, shape, ...)r_to_constant(value, dtype = NULL, shape, ...)
value |
(any) |
dtype |
( |
shape |
( |
... |
(any) Additional arguments. |
This function generates a string representation of an object.
In this package, this is primarily used to convert a Func
to its stableHLO string representation.
repr(x, ...)repr(x, ...)
x |
The object to generate a string representation of. |
... |
Additional arguments passed to the method. |
character(1)
An attribute holding a scalar value with an associated dtype.
ScalarAttr(name, value, dtype)ScalarAttr(name, value, dtype)
name |
( |
value |
( |
dtype |
( |
ScalarAttr
Represents the scatter dimension numbers.
ScatterDimensionNumbers( update_window_dims, inserted_window_dims, input_batching_dims = integer(), scatter_indices_batching_dims = integer(), scatter_dims_to_operand_dims, index_vector_dim )ScatterDimensionNumbers( update_window_dims, inserted_window_dims, input_batching_dims = integer(), scatter_indices_batching_dims = integer(), scatter_dims_to_operand_dims, index_vector_dim )
update_window_dims |
( |
inserted_window_dims |
( |
input_batching_dims |
( |
scatter_indices_batching_dims |
( |
scatter_dims_to_operand_dims |
( |
index_vector_dim |
( |
Represents the shape of a tensor.
Shape(dims = integer())Shape(dims = integer())
dims |
( |
Shape
An attribute holding a string value.
StringAttr(name, value)StringAttr(name, value)
name |
( |
value |
( |
StringAttr
Represents a tensor type with a specific data type and shape.
TensorType(dtype, shape)TensorType(dtype, shape)
dtype |
|
shape |
( |
TensorType
Converts all index_vec fields in a condition object from 0-based to 1-based.
to_one_based(x, ...)to_one_based(x, ...)
x |
Condition object with index_vec fields. |
... |
Additional arguments (not used). |
Condition object with index_vec fields incremented by 1.
This represents the name of a ValueType.
ValueId(id = NULL)ValueId(id = NULL)
id |
( |
(ValueId)
This represents the type of a value.
ValueType(type, shape = NULL)ValueType(type, shape = NULL)
type |
The type of the value (TensorType or TokenType). |
shape |
The shape of the value (only used when type is character). |
List of ValueTypes.
ValueTypes(items = list())ValueTypes(items = list())
items |
( |
ValueTypes