Commit 11d05867 authored by Philipp  Trunschke's avatar Philipp Trunschke
Browse files

bugfix[pybind11] add keep_alive to Tensor.__call__ and TensorNetwork.__call__

parent 89623758
Pipeline #1433 failed with stages
in 17 minutes and 6 seconds
......@@ -14,6 +14,8 @@ class TestTensorArithmetic(unittest.TestCase):
A = xe.Tensor.random([10,10])
B = xe.TensorNetwork()
i,j,k = xe.indices(3)
C = xe.TensorNetwork(xe.Tensor.ones([10]))
B(i,j,k) << A(i,j) * C(k)
B(i,j,k) << A(i,j) * xe.TensorNetwork(xe.Tensor.ones([10]))(k)
B(i,j,k) << A(i,j) * xe.Tensor.ones([10])(k)
xe.Tensor(B)
......
......@@ -201,7 +201,7 @@ arg("dim")
idx.push_back(*(_args[i].cast<Index *>()));
}
return new xerus::internal::IndexedTensor<Tensor>(std::move(_this(idx)));
}, return_value_policy::take_ownership )
}, keep_alive<0,1>(), return_value_policy::take_ownership )
.def("__str__", &Tensor::to_string)
.def(self * value_t())
.def(value_t() * self)
......
......@@ -29,7 +29,7 @@ void expose_tensorNetwork(module& m) {
idx.push_back(*(_args[i].cast<Index *>()));
}
return new xerus::internal::IndexedTensor<TensorNetwork>(std::move(_this(idx)));
}, return_value_policy::take_ownership )
}, keep_alive<0, 1>(), return_value_policy::take_ownership )
.def(self * value_t())
.def(value_t() * self)
.def(self / value_t())
......
Markdown is supported
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