/
vuron
/
adept
Обзор
Документация
Войти
/
vuron
/
adept
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
python/cpp_bindings/linear_py.cpp
25 строк
791 B
kolkir
Fix tensor filling and module registration
06 мар 2025, 09:54
06 мар 2025, 09:54
cea0aaa
Код
Авторство
О чём код?
#include <pybind11/pybind11.h> #include <pybind11/stl.h> #include <adept/nn/linear.hpp> #include <sstream> namespace py = pybind11; using namespace adept; void bind_linear(py::module& m) { py::class_<LinearImpl, Module, std::shared_ptr<LinearImpl>>(m, "Linear") .def(py::init<index_t, index_t, device_t, dtype_t>(), py::arg("in_features"), py::arg("out_features"), py::arg("device") = device_t::CPU, py::arg("dtype") = dtype_t::Float32) .def("parameters", &LinearImpl::parameters) .def("forward", &LinearImpl::forward) .def("__call__", [](LinearImpl& self, Variable& input) { return self.forward(input); }) .def("__repr__", [](const Linear& v) { std::stringstream buf; buf << v; return buf.str(); }); }