Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
xerus
xerus
Commits
ebb92da9
Commit
ebb92da9
authored
Jun 23, 2020
by
Philipp Trunschke
Browse files
bugfixes (neg,truediv of Tensor) in pybind11
parent
f934f6c1
Pipeline
#2108
failed with stages
in 4 minutes and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/xerus/python/indexedTensor.cpp
View file @
ebb92da9
...
...
@@ -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
);
})
;
...
...
src/xerus/python/tensor.cpp
View file @
ebb92da9
...
...
@@ -193,7 +193,7 @@ arg("dim")
.
def
(
"__str__"
,
&
Tensor
::
to_string
)
/* .def(-self) */
.
def
(
"__neg__"
,
+
[](
TT
Tensor
&
_self
)
{
+
[](
Tensor
&
_self
)
{
return
(
-
1
)
*
_self
;
})
.
def
(
self
+
self
)
...
...
@@ -206,7 +206,7 @@ arg("dim")
.
def
(
self
/
value_t
())
/* .def(self /= self) */
.
def
(
"__itruediv__"
,
+
[](
TT
Tensor
&
_self
,
const
value_t
_other
)
{
+
[](
Tensor
&
_self
,
const
value_t
_other
)
{
return
(
_self
*=
(
1
/
_other
));
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment