First tensor python module

This commit is contained in:
2025-11-09 20:11:50 +04:00
parent d3ac52b8df
commit 41f5634ce9
6 changed files with 787 additions and 77 deletions

View File

@@ -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 - это путешествие в Мордор и обратно!

View File

@@ -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)

View File

@@ -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)

View File

@@ -20,24 +20,6 @@ void register_tensor(py::module &m, const std::string &name) {
.def("get_size", &Tensor<T, Dim>::getSize)
.def("get_axes", &Tensor<T, Dim>::getAxes)
.def("__getitem__",
[](const Tensor<T, Dim> &t, size_t i) -> T {
if (i >= t.getSize())
throw py::index_error();
return t[i];
})
.def("__setitem__",
[](Tensor<T, Dim> &t, size_t i, T value) {
if (i >= t.getSize())
throw py::index_error();
t[i] = value;
})
// .def("__call__",
// [](Tensor<T, Dim> &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, Dim> &t) { return +t; })
.def("__neg__", [](const Tensor<T, Dim> &t) { return -t; })
.def("print", &Tensor<T, Dim>::print);
.def("__repr__", &Tensor<T, Dim>::toString);
if constexpr (Dim != 0)
tensor
.def(
"__getitem__",
[](Tensor<T, Dim> &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, Dim> &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 [&]<size_t... I>(std::index_sequence<I...>) -> T & {
return t(py::cast<size_t>(indices[I])...);
}(std::make_index_sequence<Dim>{});
},
py::return_value_policy::reference)
.def("__setitem__",
[](Tensor<T, Dim> &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, Dim> &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()));
[&]<size_t... I>(std::index_sequence<I...>) {
t(py::cast<size_t>(indices[I])...) = value;
}(std::make_index_sequence<Dim>{});
});
if constexpr (Dim == 1 || Dim == 2)
tensor.def("__matmul__", &Tensor<T, Dim>::operator%);
@@ -83,20 +104,9 @@ PYBIND11_MODULE(tensor, m) {
register_tensor<float, 1>(m, "Vector");
register_tensor<float, 2>(m, "Matrix");
register_tensor<float, 3>(m, "Tensor3");
register_tensor<float, 4>(m, "Tensor4");
register_tensor<float, 5>(m, "Tensor5");
register_tensor<double, 0>(m, "dScalar");
register_tensor<double, 1>(m, "dVector");
register_tensor<double, 2>(m, "dMatrix");
register_tensor<double, 3>(m, "dTensor3");
register_tensor<double, 4>(m, "dTensor4");
register_tensor<double, 5>(m, "dTensor5");
register_tensor<int, 0>(m, "iScalar");
register_tensor<int, 1>(m, "iVector");
register_tensor<int, 2>(m, "iMatrix");
register_tensor<int, 3>(m, "iTensor3");
register_tensor<int, 4>(m, "iTensor4");
register_tensor<int, 5>(m, "iTensor5");
}
}

View File

@@ -1,6 +1,6 @@
#include <array>
#include <iostream>
#include <random>
#include <sstream>
#include <stdexcept>
#include <type_traits>
#include <vector>
@@ -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<T, sizeof...(Args)>({static_cast<size_t>(args)...}, T(0),
T(1));
}
};
};

703
src/tensor/tensor.pyi Normal file
View File

@@ -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:
...