/
vuron
/
adept
Обзор
Документация
Войти
/
vuron
/
adept
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
python/cpp_bindings/fileinput_py.cpp
27 строк
899 B
kolkir
Refactor python folder structure
01 мар 2025, 22:16
01 мар 2025, 22:16
ef25f05
Код
Авторство
О чём код?
#include <pybind11/pybind11.h> #include <pybind11/stl.h> #include <adept/serialize/fileinput.hpp> #include <adept/types_dispatch.hpp> namespace py = pybind11; using namespace adept; void bind_fileinput(py::module& m) { py::class_<InputSerializer>(m, "InputSerializer"); py::class_<FileInput, InputSerializer>(m, "FileInput") .def(py::init<std::string>()) .def("read", [](InputSerializer& self, const std::string& name, dtype_t dtype) -> py::object { py::object result; DISPATCH_TYPE(dtype, [&]() { scalar_t value; self.read(name, value); result = py::cast(value); }); return result; }) .def("read", py::overload_cast<const std::string&, Tensor&>(&FileInput::read)) .def("read", py::overload_cast<const std::string&, Variable&>(&FileInput::read)); }