| 119 | |
| 120 | template <typename plain_t> |
| 121 | void bind_plain_tensor(py::module &m, const std::string &name) { |
| 122 | using type = PlainTensor<plain_t>; |
| 123 | std::string class_name = "PlainTensor" + name; |
| 124 | |
| 125 | py::class_<type>(m, class_name.c_str(), py::module_local()) |
| 126 | .def(py::init<const vector<plain_t> &>()) |
| 127 | .def(py::init<const vector<vector<plain_t>> &>()) |
| 128 | .def(py::init<const vector<plain_t> &, const vector<size_t> &>()) |
| 129 | .def(py::init<const string &>()) |
| 130 | .def("at", &type::at) |
| 131 | .def("get_diagonal", &type::get_diagonal) |
| 132 | .def("horizontal_scan", &type::horizontal_scan) |
| 133 | .def("vertical_scan", &type::vertical_scan) |
| 134 | .def("data", &type::data) |
| 135 | .def("shape", &type::shape) |
| 136 | .def("strides", &type::strides) |
| 137 | .def("size", &type::size) |
| 138 | .def("batch", &type::batch) |
| 139 | .def("reshape", &type::reshape) |
| 140 | .def("reshape_", &type::reshape_inplace) |
| 141 | .def("__len__", &type::size) |
| 142 | .def("empty", &type::empty) |
| 143 | .def("replicate", &type::replicate) |
| 144 | .def("broadcast", &type::broadcast) |
| 145 | .def("broadcast_", &type::broadcast_inplace) |
| 146 | .def("transpose", &type::transpose) |
| 147 | .def("transpose_", &type::transpose_inplace) |
| 148 | .def("serialize", [](type &obj) { return py::bytes(obj.save()); }); |
| 149 | } |
| 150 | |
| 151 | void bind_bfv_vector(py::module &m) { |
| 152 | m.def("bfv_parameters", &create_bfv_parameters, |