diff --git a/python_binding/data/pybind_Tensor.cpp b/python_binding/data/pybind_Tensor.cpp index 3c2120565e1637697e5258723b1b366a520fdf80..005175ab613594c48959073c4674e6d69b60b29f 100644 --- a/python_binding/data/pybind_Tensor.cpp +++ b/python_binding/data/pybind_Tensor.cpp @@ -73,6 +73,10 @@ void init_Tensor(py::module& m){ (m,"Tensor", py::multiple_inheritance(), py::buffer_protocol()); pyClassTensor.def(py::init<>()) + .def(py::self + py::self) + .def(py::self - py::self) + .def(py::self * py::self) + .def(py::self / py::self) .def("set_datatype", &Tensor::setDataType, py::arg("datatype"), py::arg("copyCast") = true) .def("set_backend", &Tensor::setBackend, py::arg("name"), py::arg("device") = 0, py::arg("copyFrom") = true) .def("dims", (const std::vector<DimSize_t>& (Tensor::*)()const) &Tensor::dims) @@ -89,6 +93,9 @@ void init_Tensor(py::module& m){ .def("__str__", [](Tensor& b) { return b.toString(); }) + .def("__repr__", [](Tensor& b) { + return "Tensor(dtype = " + std::string(EnumStrings<DataType>::data[static_cast<int>(b.dataType())]) + ",\n" + b.toString() + ")"; + }) .def("__len__", [](Tensor& b) -> size_t{ return b.size(); })