libtma 0.3.13-dev.9013
QE C++ library
Loading...
Searching...
No Matches
nanobind.hpp File Reference

Plain-data packers for libtma results in nanobind (Python) bindings. More...

#include <libqe/bind/nanobind.hpp>
#include <libtma/accumulation.hpp>
#include <nanobind/stl/string.h>
#include <nanobind/stl/variant.h>
#include <nanobind/stl/vector.h>
#include <string>
#include <variant>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  qe
 
namespace  qe::bind
 
namespace  qe::bind::py
 

Functions

inline ::nanobind::dict qe::bind::py::to_dict (const qe::UnitNetworks &r)
 {networks (1-D), row_networks (2-D)}
 
inline ::nanobind::dict qe::bind::py::to_dict (const qe::TensorNetworks &r)
 
qe::WeightModel qe::bind::py::weight_model_from_variant (const std::variant< bool, std::string > &w)
 
void qe::bind::py::def_connection_matrix (::nanobind::module_ &m)
 
void qe::bind::py::def_accumulate_stanza (::nanobind::module_ &m)
 
void qe::bind::py::def_row_connections (::nanobind::module_ &m)
 
void qe::bind::py::def_rolling_window_sum (::nanobind::module_ &m)
 
void qe::bind::py::def_flat_index (::nanobind::module_ &m)
 
void qe::bind::py::def_accumulate_unit (::nanobind::module_ &m)
 
void qe::bind::py::def_accumulate_unit_with_rows (::nanobind::module_ &m)
 
void qe::bind::py::def_apply_tensor_unit (::nanobind::module_ &m)
 
void qe::bind::py::def_aggregate_row_connections (::nanobind::module_ &m)
 
void qe::bind::py::def_finalize_row_connections (::nanobind::module_ &m)
 
void qe::bind::py::def_finalize_self_connections (::nanobind::module_ &m)
 
void qe::bind::py::def_aggregate_self_connections (::nanobind::module_ &m)
 
inline ::nanobind::dict qe::bind::py::to_dict (const qe::UnitAccumulation &r)
 
void qe::bind::py::def_weight_rows (::nanobind::module_ &m)
 
void qe::bind::py::def_accumulate_unit_networks (::nanobind::module_ &m)
 
void qe::bind::py::def_libtma (::nanobind::module_ &m)
 All of libtma's functions.
 

Detailed Description

Plain-data packers for libtma results in nanobind (Python) bindings.

Results cross the boundary as dicts of numpy arrays, not registered nanobind classes, so extension modules built by different products (qe-tma, qe-ena, ...) can be loaded together without type-registration clashes. Python-side result classes (tma.libtma.UnitNetworks, TensorNetworks) wrap the dicts to keep attribute access.

It also holds the bindings themselves, one registration function per libtma function (def_<name>, plus def_libtma for all of them), so every module that exposes them – qe-tma's tma._libtma, qe-ena's ena._libena – shares one definition (signature, defaults, docstring) and picks the ones it needs.

Requires nanobind; never included by libtma.hpp. Array conversion comes from libqe/bind/nanobind.hpp.