Expand description
CPU backend, kernels, provider selection, and CPU resource pools.
§Examples
use tenferro_cpu::{add, CpuBackend};
use tenferro_tensor::{Tensor, TensorBackend, TensorElementwise};
let mut backend = CpuBackend::new();
let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
let b = Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0])?;
let c = backend.add(&a, &b)?;
assert_eq!(c.as_slice::<f64>().unwrap(), &[4.0, 6.0]);
let direct = add(&a, &b)?;
assert_eq!(direct.shape(), &[2]);Re-exports§
pub use affinity::available_parallelism;pub use affinity::process_cpu_affinity_count;pub use backend::CpuBackend;pub use backend::CpuBackendKind;pub use context::CpuContext;
Modules§
Structs§
- Buffer
Pool Stats - Snapshot of typed host buffers retained by a [
BufferPool].
Functions§
- abs
- Compute elementwise absolute values.
- add
- Add two CPU tensors elementwise.
- broadcast_
in_ dim - clamp
- Clamp CPU tensor values elementwise between lower and upper bounds.
- compare
- Compare two CPU tensors elementwise.
- conj
- Conjugate a real or complex CPU tensor elementwise.
- convert
- Convert a tensor to another dtype using checked dtype conversion.
- div
- Divide two CPU tensors elementwise.
- dynamic_
slice - dynamic_
update_ slice - Return
operandwithupdatewritten at dynamicstarts. - embed_
diagonal - extract_
diagonal - gather
- maximum
- Compute elementwise maximum values.
- minimum
- Compute elementwise minimum values.
- mul
- Multiply two CPU tensors elementwise.
- neg
- Negate a CPU tensor elementwise.
- pad
- reduce_
max - reduce_
min - reduce_
prod - reduce_
sum - reshape
- scatter
- select
- Select values from two tensors using a boolean predicate tensor.
- sign
- Compute elementwise signs.
- transpose
- tril
- triu