diff --git a/README.md b/README.md index 1cfdd7b..dfb7b19 100644 --- a/README.md +++ b/README.md @@ -6,24 +6,16 @@ - [C++ 23](https://ru.wikipedia.org/wiki/C%2B%2B23) - [OpenCL](https://ru.wikipedia.org/wiki/OpenCL) +- [pybind11](https://github.com/pybind/pybind11) - **Всё!** :wink: ## О проекте: - Движок для создания нейронных сетей -- Поддерка вычислений [на CPU](./math/tensor/cpu) или [на GPU](./math/tensor/cpu) - - Полиморные пространства имён CPU и GPU соответственно - - [Алгоритмы с массовым параллелизмом на GPU](./kernels) для ускорения - - Классические алгоритмы на CPU для проверки -- [Класс Tensor](./math/tensor/tensor.hpp) для работы с тензорами N-ой размерности и [классы Scalar, Vector, Matrix и Tensor3](./math/tensor/tensor.hpp) с размерно-специфичной логикой -- [Классы ScalarMath, VectorMath, MatrixMath, Tensor3Math](./math/tensor/math.hpp) с базовыми математическими функциями - -## Запуск: - -- **Windows:** - ``` - make run - ``` +- Поддерка вычислений на CPU или на GPU + - [Алгоритмы с массовым параллелизмом на GPU](./src/tensor/opencl/kernels) для ускорения + - Классические алгоритмы на CPU для проверки вычислений +- [Класс Tensor](./src/tensor/tensor.hpp) для работы с тензорами произвольной размерности ## Forward & Back propogation - это путешествие в Мордор и обратно! diff --git a/src/run.py b/src/run.py index aff44c5..feb309e 100644 --- a/src/run.py +++ b/src/run.py @@ -1,5 +1,6 @@ from tensor.tensor import * -a = Matrix([2, 3], 2) -b = Matrix([3, 2], 3) -(a @ b).print() +a = iMatrix([2, 3], 2) + +a *= 3.0 +print(a) diff --git a/src/tensor/Makefile b/src/tensor/Makefile index 05fed62..d21c499 100644 --- a/src/tensor/Makefile +++ b/src/tensor/Makefile @@ -10,18 +10,20 @@ ifeq ($(DETECTED_OS),Windows) TARGET = main.exe MKDIR = powershell -Command "mkdir" SHARED_LIB_EXT = pyd + SP = \\ else TARGET = main MKDIR = mkdir -p SHARED_LIB_EXT = so + SP = / endif BUILD_DIR = build COMMON_SRC = tensor.cpp PYTHON_PATH = $(shell python -c "from sysconfig import get_paths; print(get_paths()['data'])") -PYTHON_INCLUDE = $(PYTHON_PATH)\include -PYTHON_LIBS = $(PYTHON_PATH)\libs +PYTHON_INCLUDE = $(shell python -c "import sysconfig; print(sysconfig.get_config_var('CONFINCLUDEPY'))") +PYTHON_LIBS = $(PYTHON_PATH)$(SP)libs PYBIND_INCLUDE = $(shell python -c "import pybind11; print(pybind11.get_include())") .DEFAULT_GOAL := $(TARGET) @@ -33,7 +35,8 @@ $(TARGET): $(COMMON_SRC) main.cpp | $(BUILD_DIR) $(CXX) $(CXXFLAGS) -o $@ $^ module: $(COMMON_SRC) pybind.cpp | $(BUILD_DIR) - $(CXX) $(CXXFLAGS) -shared -fPIC -o tensor.$(SHARED_LIB_EXT) $^ -I"$(PYTHON_INCLUDE)" -L"$(PYTHON_LIBS)" -lpython313 -I"$(PYBIND_INCLUDE)" + $(CXX) $(CXXFLAGS) -shared -fPIC -o tensor.$(SHARED_LIB_EXT) $^ -I"$(PYTHON_INCLUDE)" -L"$(PYTHON_LIBS)" -lpython3.13 -I"$(PYBIND_INCLUDE)" + PYTHONPATH=. pybind11-stubgen tensor -o . clean: rm -rf $(BUILD_DIR) $(TARGET) *.$(SHARED_LIB_EXT) diff --git a/src/tensor/pybind.cpp b/src/tensor/pybind.cpp index cfd8f05..c86d06d 100644 --- a/src/tensor/pybind.cpp +++ b/src/tensor/pybind.cpp @@ -20,24 +20,6 @@ void register_tensor(py::module &m, const std::string &name) { .def("get_size", &Tensor::getSize) .def("get_axes", &Tensor::getAxes) - .def("__getitem__", - [](const Tensor &t, size_t i) -> T { - if (i >= t.getSize()) - throw py::index_error(); - return t[i]; - }) - .def("__setitem__", - [](Tensor &t, size_t i, T value) { - if (i >= t.getSize()) - throw py::index_error(); - t[i] = value; - }) - - // .def("__call__", - // [](Tensor &t, py::args args) -> T & { - // - // }) - .def(py::self + py::self) .def(py::self - py::self) .def(py::self * py::self) @@ -49,19 +31,58 @@ void register_tensor(py::module &m, const std::string &name) { .def(py::self - T()) .def(py::self * T()) .def(py::self / T()) - .def(T() + py::self) - .def(T() - py::self) - .def(T() * py::self) - .def(py::self += T()) .def(py::self -= T()) .def(py::self *= T()) .def(py::self /= T()) + .def(T() + py::self) + .def(T() - py::self) + .def(T() * py::self) .def("__pos__", [](const Tensor &t) { return +t; }) .def("__neg__", [](const Tensor &t) { return -t; }) - .def("print", &Tensor::print); + .def("__repr__", &Tensor::toString); + + if constexpr (Dim != 0) + tensor + .def( + "__getitem__", + [](Tensor &t, size_t index) -> T & { + if (index >= t.getSize()) + throw py::value_error("Index out of range"); + return t[index]; + }, + py::return_value_policy::reference) + .def( + "__getitem__", + [](Tensor &t, const py::tuple &indices) -> T & { + if (indices.size() != Dim) + throw py::value_error("Expected " + std::to_string(Dim) + + " indices, got " + + std::to_string(indices.size())); + return [&](std::index_sequence) -> T & { + return t(py::cast(indices[I])...); + }(std::make_index_sequence{}); + }, + py::return_value_policy::reference) + + .def("__setitem__", + [](Tensor &t, size_t index, const T &value) { + if (index >= t.getSize()) + throw py::value_error("Index out of range"); + t[index] = value; + }) + .def("__setitem__", + [](Tensor &t, const py::tuple &indices, const T &value) { + if (indices.size() != Dim) + throw py::value_error("Expected " + std::to_string(Dim) + + " indices, got " + + std::to_string(indices.size())); + [&](std::index_sequence) { + t(py::cast(indices[I])...) = value; + }(std::make_index_sequence{}); + }); if constexpr (Dim == 1 || Dim == 2) tensor.def("__matmul__", &Tensor::operator%); @@ -83,20 +104,9 @@ PYBIND11_MODULE(tensor, m) { register_tensor(m, "Vector"); register_tensor(m, "Matrix"); register_tensor(m, "Tensor3"); - register_tensor(m, "Tensor4"); - register_tensor(m, "Tensor5"); - - register_tensor(m, "dScalar"); - register_tensor(m, "dVector"); - register_tensor(m, "dMatrix"); - register_tensor(m, "dTensor3"); - register_tensor(m, "dTensor4"); - register_tensor(m, "dTensor5"); register_tensor(m, "iScalar"); register_tensor(m, "iVector"); register_tensor(m, "iMatrix"); register_tensor(m, "iTensor3"); - register_tensor(m, "iTensor4"); - register_tensor(m, "iTensor5"); -} \ No newline at end of file +} diff --git a/src/tensor/tensor.hpp b/src/tensor/tensor.hpp index e50cc0f..db167ac 100644 --- a/src/tensor/tensor.hpp +++ b/src/tensor/tensor.hpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include #include @@ -270,48 +270,49 @@ public: } } - void print() const { + std::string toString() const { + std::ostringstream oss; if constexpr (Dim == 0) { - std::cout << "Scalar<" << typeid(T).name() << ">: " << data_[0] - << std::endl; + oss << "Scalar<" << typeid(T).name() << ">: " << data_[0]; } else if constexpr (Dim == 1) { - std::cout << "Vector<" << typeid(T).name() << ">(" << shape_[0] << "): ["; + oss << "Vector<" << typeid(T).name() << ">(" << shape_[0] << "): ["; for (size_t i = 0; i < data_.size(); ++i) { - std::cout << data_[i]; + oss << data_[i]; if (i < data_.size() - 1) - std::cout << ", "; + oss << ", "; } - std::cout << "]" << std::endl; + oss << "]"; } else if constexpr (Dim == 2) { - std::cout << "Matrix<" << typeid(T).name() << ">(" << shape_[axes_[0]] - << "x" << shape_[axes_[1]] << "):" << std::endl; + oss << "Matrix<" << typeid(T).name() << ">(" << shape_[axes_[0]] << "x" + << shape_[axes_[1]] << "):"; for (size_t i = 0; i < shape_[axes_[0]]; ++i) { - std::cout << " ["; + oss << "\n ["; for (size_t j = 0; j < shape_[axes_[1]]; ++j) { - std::cout << (*this)(i, j); + oss << (*this)(i, j); if (j < shape_[axes_[1]] - 1) - std::cout << ", "; + oss << ", "; } - std::cout << "]" << std::endl; + oss << "]"; } } else { - std::cout << "Tensor" << Dim << "D<" << typeid(T).name() << ">" << "["; + oss << "Tensor" << Dim << "D<" << typeid(T).name() << ">" << "["; for (size_t i = 0; i < Dim; ++i) { - std::cout << shape_[axes_[i]]; + oss << shape_[axes_[i]]; if (i < Dim - 1) - std::cout << "x"; + oss << "x"; } - std::cout << "]: ["; + oss << "]: ["; size_t show = std::min(data_.size(), size_t(10)); for (size_t i = 0; i < show; ++i) { - std::cout << data_[i]; + oss << data_[i]; if (i < show - 1) - std::cout << ", "; + oss << ", "; } if (data_.size() > 10) - std::cout << ", ..."; - std::cout << "]" << std::endl; + oss << ", ..."; + oss << "]"; } + return oss.str(); } }; @@ -335,4 +336,4 @@ public: return Tensor({static_cast(args)...}, T(0), T(1)); } -}; \ No newline at end of file +}; diff --git a/src/tensor/tensor.pyi b/src/tensor/tensor.pyi new file mode 100644 index 0000000..8062336 --- /dev/null +++ b/src/tensor/tensor.pyi @@ -0,0 +1,703 @@ +""" +Tensor math library +""" +from __future__ import annotations +import collections.abc +import typing +__all__: list[str] = ['Matrix', 'Scalar', 'Tensor3', 'Vector', 'iMatrix', 'iScalar', 'iTensor3', 'iVector'] +class Matrix: + @typing.overload + def __add__(self, arg0: Matrix) -> Matrix: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + @typing.overload + def __getitem__(self, arg0: typing.SupportsInt) -> float: + ... + @typing.overload + def __getitem__(self, arg0: tuple) -> float: + ... + @typing.overload + def __iadd__(self, arg0: Matrix) -> Matrix: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + @typing.overload + def __imul__(self, arg0: Matrix) -> Matrix: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"], arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"], arg1: collections.abc.Sequence[typing.SupportsFloat]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"], arg1: typing.SupportsFloat, arg2: typing.SupportsFloat) -> None: + ... + @typing.overload + def __isub__(self, arg0: Matrix) -> Matrix: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + def __itruediv__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + def __matmul__(self, arg0: Matrix) -> Matrix: + ... + @typing.overload + def __mul__(self, arg0: Matrix) -> Matrix: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + def __neg__(self) -> Matrix: + ... + def __pos__(self) -> Matrix: + ... + def __radd__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + def __rsub__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + @typing.overload + def __setitem__(self, arg0: typing.SupportsInt, arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __setitem__(self, arg0: tuple, arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __sub__(self, arg0: Matrix) -> Matrix: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + def __truediv__(self, arg0: typing.SupportsFloat) -> Matrix: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(2)"]: + ... + def get_data(self) -> list[float]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(2)"]: + ... + def get_size(self) -> int: + ... + def t(self) -> Matrix: + ... + @typing.overload + def transpose(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"]) -> Matrix: + ... + @typing.overload + def transpose(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> Matrix: + ... +class Scalar: + @typing.overload + def __add__(self, arg0: Scalar) -> Scalar: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + @typing.overload + def __iadd__(self, arg0: Scalar) -> Scalar: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + @typing.overload + def __imul__(self, arg0: Scalar) -> Scalar: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"], arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"], arg1: collections.abc.Sequence[typing.SupportsFloat]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"], arg1: typing.SupportsFloat, arg2: typing.SupportsFloat) -> None: + ... + @typing.overload + def __isub__(self, arg0: Scalar) -> Scalar: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + def __itruediv__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + @typing.overload + def __mul__(self, arg0: Scalar) -> Scalar: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + def __neg__(self) -> Scalar: + ... + def __pos__(self) -> Scalar: + ... + def __radd__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + def __rsub__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + @typing.overload + def __sub__(self, arg0: Scalar) -> Scalar: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + def __truediv__(self, arg0: typing.SupportsFloat) -> Scalar: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(0)"]: + ... + def get_data(self) -> list[float]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(0)"]: + ... + def get_size(self) -> int: + ... +class Tensor3: + @typing.overload + def __add__(self, arg0: Tensor3) -> Tensor3: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + @typing.overload + def __getitem__(self, arg0: typing.SupportsInt) -> float: + ... + @typing.overload + def __getitem__(self, arg0: tuple) -> float: + ... + @typing.overload + def __iadd__(self, arg0: Tensor3) -> Tensor3: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + @typing.overload + def __imul__(self, arg0: Tensor3) -> Tensor3: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"], arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"], arg1: collections.abc.Sequence[typing.SupportsFloat]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"], arg1: typing.SupportsFloat, arg2: typing.SupportsFloat) -> None: + ... + @typing.overload + def __isub__(self, arg0: Tensor3) -> Tensor3: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + def __itruediv__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + @typing.overload + def __mul__(self, arg0: Tensor3) -> Tensor3: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + def __neg__(self) -> Tensor3: + ... + def __pos__(self) -> Tensor3: + ... + def __radd__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + def __rsub__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + @typing.overload + def __setitem__(self, arg0: typing.SupportsInt, arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __setitem__(self, arg0: tuple, arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __sub__(self, arg0: Tensor3) -> Tensor3: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + def __truediv__(self, arg0: typing.SupportsFloat) -> Tensor3: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(3)"]: + ... + def get_data(self) -> list[float]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(3)"]: + ... + def get_size(self) -> int: + ... + def t(self) -> Tensor3: + ... + @typing.overload + def transpose(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"]) -> Tensor3: + ... + @typing.overload + def transpose(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> Tensor3: + ... +class Vector: + @typing.overload + def __add__(self, arg0: Vector) -> Vector: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsFloat) -> Vector: + ... + @typing.overload + def __getitem__(self, arg0: typing.SupportsInt) -> float: + ... + @typing.overload + def __getitem__(self, arg0: tuple) -> float: + ... + @typing.overload + def __iadd__(self, arg0: Vector) -> Vector: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsFloat) -> Vector: + ... + @typing.overload + def __imul__(self, arg0: Vector) -> Vector: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsFloat) -> Vector: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"], arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"], arg1: collections.abc.Sequence[typing.SupportsFloat]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"], arg1: typing.SupportsFloat, arg2: typing.SupportsFloat) -> None: + ... + @typing.overload + def __isub__(self, arg0: Vector) -> Vector: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsFloat) -> Vector: + ... + def __itruediv__(self, arg0: typing.SupportsFloat) -> Vector: + ... + def __matmul__(self, arg0: Vector) -> Scalar: + ... + @typing.overload + def __mul__(self, arg0: Vector) -> Vector: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsFloat) -> Vector: + ... + def __neg__(self) -> Vector: + ... + def __pos__(self) -> Vector: + ... + def __radd__(self, arg0: typing.SupportsFloat) -> Vector: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsFloat) -> Vector: + ... + def __rsub__(self, arg0: typing.SupportsFloat) -> Vector: + ... + @typing.overload + def __setitem__(self, arg0: typing.SupportsInt, arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __setitem__(self, arg0: tuple, arg1: typing.SupportsFloat) -> None: + ... + @typing.overload + def __sub__(self, arg0: Vector) -> Vector: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsFloat) -> Vector: + ... + def __truediv__(self, arg0: typing.SupportsFloat) -> Vector: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(1)"]: + ... + def get_data(self) -> list[float]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(1)"]: + ... + def get_size(self) -> int: + ... +class iMatrix: + @typing.overload + def __add__(self, arg0: iMatrix) -> iMatrix: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + @typing.overload + def __getitem__(self, arg0: typing.SupportsInt) -> int: + ... + @typing.overload + def __getitem__(self, arg0: tuple) -> int: + ... + @typing.overload + def __iadd__(self, arg0: iMatrix) -> iMatrix: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + @typing.overload + def __imul__(self, arg0: iMatrix) -> iMatrix: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"], arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"], arg1: collections.abc.Sequence[typing.SupportsInt]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"], arg1: typing.SupportsInt, arg2: typing.SupportsInt) -> None: + ... + @typing.overload + def __isub__(self, arg0: iMatrix) -> iMatrix: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + def __itruediv__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + def __matmul__(self, arg0: iMatrix) -> iMatrix: + ... + @typing.overload + def __mul__(self, arg0: iMatrix) -> iMatrix: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + def __neg__(self) -> iMatrix: + ... + def __pos__(self) -> iMatrix: + ... + def __radd__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + def __rsub__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + @typing.overload + def __setitem__(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __setitem__(self, arg0: tuple, arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __sub__(self, arg0: iMatrix) -> iMatrix: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + def __truediv__(self, arg0: typing.SupportsInt) -> iMatrix: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(2)"]: + ... + def get_data(self) -> list[int]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(2)"]: + ... + def get_size(self) -> int: + ... + def t(self) -> iMatrix: + ... + @typing.overload + def transpose(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(2)"]) -> iMatrix: + ... + @typing.overload + def transpose(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> iMatrix: + ... +class iScalar: + @typing.overload + def __add__(self, arg0: iScalar) -> iScalar: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsInt) -> iScalar: + ... + @typing.overload + def __iadd__(self, arg0: iScalar) -> iScalar: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsInt) -> iScalar: + ... + @typing.overload + def __imul__(self, arg0: iScalar) -> iScalar: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsInt) -> iScalar: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"], arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"], arg1: collections.abc.Sequence[typing.SupportsInt]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(0)"], arg1: typing.SupportsInt, arg2: typing.SupportsInt) -> None: + ... + @typing.overload + def __isub__(self, arg0: iScalar) -> iScalar: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsInt) -> iScalar: + ... + def __itruediv__(self, arg0: typing.SupportsInt) -> iScalar: + ... + @typing.overload + def __mul__(self, arg0: iScalar) -> iScalar: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsInt) -> iScalar: + ... + def __neg__(self) -> iScalar: + ... + def __pos__(self) -> iScalar: + ... + def __radd__(self, arg0: typing.SupportsInt) -> iScalar: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsInt) -> iScalar: + ... + def __rsub__(self, arg0: typing.SupportsInt) -> iScalar: + ... + @typing.overload + def __sub__(self, arg0: iScalar) -> iScalar: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsInt) -> iScalar: + ... + def __truediv__(self, arg0: typing.SupportsInt) -> iScalar: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(0)"]: + ... + def get_data(self) -> list[int]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(0)"]: + ... + def get_size(self) -> int: + ... +class iTensor3: + @typing.overload + def __add__(self, arg0: iTensor3) -> iTensor3: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + @typing.overload + def __getitem__(self, arg0: typing.SupportsInt) -> int: + ... + @typing.overload + def __getitem__(self, arg0: tuple) -> int: + ... + @typing.overload + def __iadd__(self, arg0: iTensor3) -> iTensor3: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + @typing.overload + def __imul__(self, arg0: iTensor3) -> iTensor3: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"], arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"], arg1: collections.abc.Sequence[typing.SupportsInt]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"], arg1: typing.SupportsInt, arg2: typing.SupportsInt) -> None: + ... + @typing.overload + def __isub__(self, arg0: iTensor3) -> iTensor3: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + def __itruediv__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + @typing.overload + def __mul__(self, arg0: iTensor3) -> iTensor3: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + def __neg__(self) -> iTensor3: + ... + def __pos__(self) -> iTensor3: + ... + def __radd__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + def __rsub__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + @typing.overload + def __setitem__(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __setitem__(self, arg0: tuple, arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __sub__(self, arg0: iTensor3) -> iTensor3: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + def __truediv__(self, arg0: typing.SupportsInt) -> iTensor3: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(3)"]: + ... + def get_data(self) -> list[int]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(3)"]: + ... + def get_size(self) -> int: + ... + def t(self) -> iTensor3: + ... + @typing.overload + def transpose(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(3)"]) -> iTensor3: + ... + @typing.overload + def transpose(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> iTensor3: + ... +class iVector: + @typing.overload + def __add__(self, arg0: iVector) -> iVector: + ... + @typing.overload + def __add__(self, arg0: typing.SupportsInt) -> iVector: + ... + @typing.overload + def __getitem__(self, arg0: typing.SupportsInt) -> int: + ... + @typing.overload + def __getitem__(self, arg0: tuple) -> int: + ... + @typing.overload + def __iadd__(self, arg0: iVector) -> iVector: + ... + @typing.overload + def __iadd__(self, arg0: typing.SupportsInt) -> iVector: + ... + @typing.overload + def __imul__(self, arg0: iVector) -> iVector: + ... + @typing.overload + def __imul__(self, arg0: typing.SupportsInt) -> iVector: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"], arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"], arg1: collections.abc.Sequence[typing.SupportsInt]) -> None: + ... + @typing.overload + def __init__(self, arg0: typing.Annotated[collections.abc.Sequence[typing.SupportsInt], "FixedSize(1)"], arg1: typing.SupportsInt, arg2: typing.SupportsInt) -> None: + ... + @typing.overload + def __isub__(self, arg0: iVector) -> iVector: + ... + @typing.overload + def __isub__(self, arg0: typing.SupportsInt) -> iVector: + ... + def __itruediv__(self, arg0: typing.SupportsInt) -> iVector: + ... + def __matmul__(self, arg0: iVector) -> iScalar: + ... + @typing.overload + def __mul__(self, arg0: iVector) -> iVector: + ... + @typing.overload + def __mul__(self, arg0: typing.SupportsInt) -> iVector: + ... + def __neg__(self) -> iVector: + ... + def __pos__(self) -> iVector: + ... + def __radd__(self, arg0: typing.SupportsInt) -> iVector: + ... + def __repr__(self) -> str: + ... + def __rmul__(self, arg0: typing.SupportsInt) -> iVector: + ... + def __rsub__(self, arg0: typing.SupportsInt) -> iVector: + ... + @typing.overload + def __setitem__(self, arg0: typing.SupportsInt, arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __setitem__(self, arg0: tuple, arg1: typing.SupportsInt) -> None: + ... + @typing.overload + def __sub__(self, arg0: iVector) -> iVector: + ... + @typing.overload + def __sub__(self, arg0: typing.SupportsInt) -> iVector: + ... + def __truediv__(self, arg0: typing.SupportsInt) -> iVector: + ... + def get_axes(self) -> typing.Annotated[list[int], "FixedSize(1)"]: + ... + def get_data(self) -> list[int]: + ... + def get_shape(self) -> typing.Annotated[list[int], "FixedSize(1)"]: + ... + def get_size(self) -> int: + ...