Skip to main content

ruxla_kernels/
lib.rs

1//! The semantics of ruxla's operations: elementwise and array computations
2//! on typed slices, following XLA's CPU behavior where StableHLO leaves it to
3//! the implementation.
4//!
5//! The native backend and the IR interpreter both call these functions, so
6//! they agree by construction; XLA is the independent reference.
7//!
8//! # Examples
9//!
10//! ```
11//! use ruxla_kernels::{BinaryOp, Ops, cast};
12//!
13//! // Integer division by zero gives -1, as in XLA, instead of panicking.
14//! assert_eq!(i32::binary(BinaryOp::Div, 7, 0), -1);
15//! // Float to integer conversions saturate, and NaN becomes 0.
16//! assert_eq!(cast::<f32, i32>(f32::NAN), 0);
17//! ```
18
19pub mod array;
20mod buffer;
21mod complex;
22mod dtype;
23pub mod elementwise;
24pub mod fft;
25pub mod linalg;
26mod ops;
27pub mod random;
28pub mod special;
29pub mod window;
30
31pub use buffer::{Buffer, BufferElement};
32pub use complex::{Complex, c64, c128};
33pub use dtype::{DType, DTypeKind, Element, Value, cast};
34pub use half::{bf16, f16};
35pub use ops::{BinaryOp, CompareOp, Ops, TernaryOp, UnaryOp, compare, integer_pow};