Commit ebb92da9 authored by Philipp  Trunschke's avatar Philipp Trunschke
Browse files

bugfixes (neg,truediv of Tensor) in pybind11

parent f934f6c1
Pipeline #2108 failed with stages
in 4 minutes and 11 seconds
......@@ -54,15 +54,15 @@ void expose_indexedTensors(module& m) {
}, keep_alive<0, 1>(), keep_alive<0, 2>(), return_value_policy::take_ownership)
class_<internal::IndexedTensorReadOnly<TensorNetwork>>(m,"IndexedTensorNetworkReadOnly")
ADD_MOVE_AND_RESULT_PTR("__add__", +, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__add__", +, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__sub__", -, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__sub__", -, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<TensorNetwork>, value_t, IndexedTensorReadOnly<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__rmul__", *, IndexedTensorReadOnly<TensorNetwork>, value_t, IndexedTensorReadOnly<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__truediv__", /, IndexedTensorReadOnly<TensorNetwork>, value_t, IndexedTensorReadOnly<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__add__", +, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__add__", +, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__sub__", -, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__sub__", -, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<TensorNetwork>, value_t, IndexedTensorReadOnly<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__rmul__", *, IndexedTensorReadOnly<TensorNetwork>, value_t, IndexedTensorReadOnly<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__truediv__", /, IndexedTensorReadOnly<TensorNetwork>, value_t, IndexedTensorReadOnly<TensorNetwork>)
.def("frob_norm", static_cast<value_t (*)(const IndexedTensorReadOnly<TensorNetwork> &)>(&frob_norm<TensorNetwork>))
.def("__float__", [](const IndexedTensorReadOnly<TensorNetwork> &_self){ return value_t(_self); })
;
......@@ -80,14 +80,14 @@ void expose_indexedTensors(module& m) {
;
class_<internal::IndexedTensorReadOnly<Tensor>>(m,"IndexedTensorReadOnly")
ADD_MOVE_AND_RESULT_PTR("__add__", +, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__sub__", -, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<Tensor>, value_t, IndexedTensorReadOnly<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__rmul__", *, IndexedTensorReadOnly<Tensor>, value_t, IndexedTensorReadOnly<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__truediv__", /, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__truediv__", /, IndexedTensorReadOnly<Tensor>, value_t, IndexedTensorMoveable<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__add__", +, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__sub__", -, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<TensorNetwork>, IndexedTensorMoveable<TensorNetwork>)
ADD_MOVE_AND_RESULT_PTR("__mul__", *, IndexedTensorReadOnly<Tensor>, value_t, IndexedTensorReadOnly<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__rmul__", *, IndexedTensorReadOnly<Tensor>, value_t, IndexedTensorReadOnly<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__truediv__", /, IndexedTensorReadOnly<Tensor>, IndexedTensorReadOnly<Tensor>, IndexedTensorMoveable<Tensor>)
ADD_MOVE_AND_RESULT_PTR("__truediv__", /, IndexedTensorReadOnly<Tensor>, value_t, IndexedTensorMoveable<Tensor>)
.def("frob_norm", static_cast<value_t (*)(const IndexedTensorReadOnly<Tensor> &)>(&frob_norm<Tensor>))
.def("__float__", [](const IndexedTensorReadOnly<Tensor> &_self){ return value_t(_self); })
;
......
......@@ -193,7 +193,7 @@ arg("dim")
.def("__str__", &Tensor::to_string)
/* .def(-self) */
.def("__neg__",
+[](TTTensor& _self) {
+[](Tensor& _self) {
return (-1)*_self;
})
.def(self + self)
......@@ -206,7 +206,7 @@ arg("dim")
.def(self / value_t())
/* .def(self /= self) */
.def("__itruediv__",
+[](TTTensor& _self, const value_t _other) {
+[](Tensor& _self, const value_t _other) {
return (_self *= (1/_other));
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment