#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![recursion_limit = "135"]
#[allow(unused_imports)]
#[macro_use]
extern crate derive_new;
pub use serde;
pub mod config;
#[cfg(feature = "std")]
pub mod data;
pub mod module;
pub mod store;
pub mod tensor;
pub use tensor::Tensor;
#[cfg(feature = "extension")]
pub mod backend;
extern crate alloc;
#[cfg(test)]
#[allow(missing_docs)]
pub fn test_device() -> burn_tensor::Device {
burn_tensor::Device::flex()
}
#[cfg(test)]
mod test_utils {
use crate as burn;
use crate::module::Module;
use crate::module::Param;
use burn_tensor::Device;
use burn_tensor::Tensor;
#[derive(Module, Debug)]
pub struct SimpleLinear {
pub weight: Param<Tensor<2>>,
pub bias: Option<Param<Tensor<1>>>,
}
impl SimpleLinear {
pub fn new(in_features: usize, out_features: usize, device: &Device) -> Self {
let weight = Tensor::random(
[out_features, in_features],
burn_tensor::Distribution::Default,
device,
);
let bias = Tensor::random([out_features], burn_tensor::Distribution::Default, device);
Self {
weight: Param::from_tensor(weight),
bias: Some(Param::from_tensor(bias)),
}
}
}
}
pub mod prelude {
pub use crate::{
config::Config,
module::Module,
tensor::{
Bool, Device, DeviceIndex, DeviceKind, ElementConversion, Float, Int, Shape, SliceArg,
Tensor, TensorData, cast::ToElement, s,
},
};
pub use burn_std::device::Device as DeviceOps;
}