#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[macro_use]
extern crate derive_new;
extern crate alloc;
pub mod backend;
pub use backend::*;
pub use burn_std::reader::*; pub use burn_std::{
AllocationProperty, BoolDType, BoolStore, Bytes, DType, DataError, DeviceHandle, Distribution,
DistributionSampler, DistributionSamplerKind, Element, ElementAdd, ElementConversion,
ElementEq, ElementOrdered, ElementRandom, FloatDType, IntDType, Scalar, SplitPolicy,
TensorData, Tolerance, bf16, distribution, element, f16, stream::StreamId,
};
pub mod shape {
pub use burn_std::shape::*;
}
pub use shape::*;
pub mod slice {
pub use burn_std::{s, slice::*};
}
pub use slice::*;
pub mod indexing {
pub use burn_std::indexing::*;
}
pub use indexing::*;
mod alias;
pub use alias::*;
pub mod quantization;
#[cfg(feature = "cubecl")]
pub mod cubecl;
#[cfg(feature = "cubecl-device")]
mod cube_device {
use crate::backend::DeviceOps;
use burn_std::{BoolStore, DType, DeviceSettings};
use cubecl::{Device, RuntimeId};
use cubecl::{
features::TypeUsage,
ir::{ElemType, UIntKind},
};
impl DeviceOps for Device {
fn defaults(&self) -> DeviceSettings {
let bool_store = match self.runtime() {
RuntimeId::Wgpu => {
let usage = self
.client()
.properties()
.type_usage(ElemType::UInt(UIntKind::U8));
if usage.is_superset(TypeUsage::Buffer | TypeUsage::Conversion) {
BoolStore::U8
} else {
BoolStore::U32
}
}
_ => BoolStore::U8,
};
DeviceSettings::new(
DType::F32,
DType::I32,
DType::Bool(bool_store),
Default::default(),
)
}
}
}
#[macro_export]
macro_rules! doc_tensor {
() => {
concat!(
"[`Tensor`](https://docs.rs/burn-tensor/",
env!("CARGO_PKG_VERSION"),
"/burn_tensor/struct.Tensor.html)"
)
};
($method:literal) => {
concat!(
"[`Tensor::",
$method,
"`](",
"https://docs.rs/burn-tensor/",
env!("CARGO_PKG_VERSION"),
"/burn_tensor/struct.Tensor.html#method.",
$method,
")"
)
};
}