1use pyo3::prelude::*;
18
19pub mod device;
21pub mod dtype;
22pub mod error;
23pub mod nn;
24pub mod optim;
25pub mod tensor;
26pub mod utils;
27
28pub mod autograd;
29pub mod data;
30pub mod distributed;
31pub use device::PyDevice;
35pub use dtype::PyDType;
36pub use error::TorshPyError;
37pub use tensor::PyTensor;
38
39#[pymodule]
41fn rstorch(m: &Bound<'_, PyModule>) -> PyResult<()> {
42 m.add_class::<PyTensor>()?;
44 m.add_class::<PyDevice>()?;
45 m.add_class::<PyDType>()?;
46
47 nn::register_nn_module(m.py(), m)?;
49 optim::register_optim_module(m.py(), m)?;
50
51 let data_module = PyModule::new(m.py(), "data")?;
52 data::register_data_module(m.py(), &data_module)?;
53 m.add_submodule(&data_module)?;
54
55 let autograd_module = PyModule::new(m.py(), "autograd")?;
56 autograd::register_autograd_module(m.py(), &autograd_module)?;
57 m.add_submodule(&autograd_module)?;
58
59 let distributed_module = PyModule::new(m.py(), "distributed")?;
60 distributed::register_distributed_module(m.py(), &distributed_module)?;
61 m.add_submodule(&distributed_module)?;
62
63 tensor::register_creation_functions(m)?;
69
70 device::register_device_constants(m)?;
72 dtype::register_dtype_constants(m)?;
73
74 error::register_error_types(m)?;
76
77 m.add("__version__", env!("CARGO_PKG_VERSION"))?;
79
80 Ok(())
81}
82
83#[pymodule]
85fn rstorch_python(m: &Bound<'_, PyModule>) -> PyResult<()> {
86 rstorch(m)
87}