1#![cfg_attr(not(feature = "std"), no_std)]
2#![warn(missing_docs)]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![cfg_attr(
7 not(backend_enabled),
8 allow(
9 unused_imports,
10 unused_variables,
11 unused_mut,
12 unused_macros,
13 unused_assignments,
14 dead_code,
15 irrefutable_let_patterns,
16 unreachable_code
17 )
18)]
19
20#[macro_use]
41mod macros;
42
43pub mod backend;
45pub mod device;
47#[cfg(feature = "group")]
48mod group;
49mod ops;
50pub mod tensor;
52
53#[doc(hidden)]
55#[cfg(feature = "remote-server")]
56pub mod remote_server;
57
58pub use backend::*;
59pub use device::*;
60pub use tensor::*;
61
62extern crate alloc;
63
64#[cfg(not(backend_enabled))]
68#[doc(hidden)]
69#[derive(Clone, Debug, PartialEq, Eq)]
70pub struct NoBackend {
71 never: core::convert::Infallible,
72}
73
74#[cfg(not(backend_enabled))]
75impl NoBackend {
76 pub(crate) fn unreachable(&self) -> ! {
77 match self.never {}
78 }
79}
80
81pub mod backends {
83 #[cfg(feature = "autodiff")]
84 pub use burn_autodiff as autodiff;
85 #[cfg(feature = "autodiff")]
86 pub use burn_autodiff::Autodiff; #[cfg(cube_backend)]
92 pub use burn_cubecl::Cube;
93
94 #[cfg(feature = "flex")]
95 pub use burn_flex as flex;
96 #[cfg(feature = "flex")]
97 pub use burn_flex::Flex;
98
99 #[cfg(feature = "remote")]
100 pub use burn_remote::RemoteBackend as Remote;
101
102 #[cfg(feature = "capture")]
104 pub mod capture {
105 pub use burn_capture::{
106 CaptureBackend, CaptureError, CaptureScope, CaptureTensor, CapturedGraph,
107 CompletedCaptureScope, IntoCaptureOutputs, TensorId,
108 };
109 }
110 #[cfg(feature = "capture")]
111 pub use burn_capture::CaptureBackend as Capture;
112
113 #[cfg(feature = "group")]
114 pub use burn_group::GroupBackend as Group;
115 #[cfg(feature = "group")]
116 pub use burn_group::{GroupError, Sharding, ShardingError};
117}
118
119pub mod devices {
123 #[cfg(feature = "wgpu")]
125 pub mod wgpu {
126 #[cfg(not(target_family = "wasm"))]
127 pub use burn_cubecl::cubecl::wgpu::try_init_setup;
128 pub use burn_cubecl::cubecl::wgpu::{
129 AutoGraphicsApi, MemoryConfiguration, RuntimeOptions, WgpuBackend, WgpuDevice,
130 WgpuInitError, WgpuSetup, try_init_device, try_init_setup_async, wgpu,
131 };
132 }
133
134 #[cfg(feature = "cpu")]
135 pub use burn_cubecl::cubecl::cpu::CpuDevice;
136 #[cfg(feature = "cuda")]
137 pub use burn_cubecl::cubecl::cuda::CudaDevice;
138 #[cfg(feature = "rocm")]
139 pub use burn_cubecl::cubecl::hip::AmdDevice as RocmDevice;
140 #[cfg(feature = "wgpu")]
141 pub use burn_cubecl::cubecl::wgpu::{
142 AutoCompiler, AutoGraphicsApi, WgpuBackend, WgpuDevice, WgpuDeviceKind, init_setup_async,
143 };
144
145 #[cfg(cube_backend)]
149 pub use burn_cubecl::CubeDevice;
150 #[cfg(cube_backend)]
151 pub use burn_cubecl::cubecl::RuntimeId;
152 #[cfg(feature = "flex")]
153 pub use burn_flex::FlexDevice;
154
155 #[cfg(feature = "remote")]
156 pub use burn_remote::RemoteDevice;
157
158 #[cfg(feature = "group")]
159 pub use burn_group::GroupDevice;
160}
161
162#[doc(hidden)]
164#[cfg(feature = "remote")]
165pub use burn_remote as __remote;