Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pycodegen
pystencils_autodiff
Commits
8b80a78e
Commit
8b80a78e
authored
Dec 16, 2019
by
Stephan Seitz
Browse files
Add additional assertion: with_cuda needs to be bool
parent
c2cd47b7
Pipeline
#20535
failed with stage
in 6 minutes and 7 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/pystencils_autodiff/backends/_torch_native.py
View file @
8b80a78e
...
...
@@ -84,8 +84,9 @@ def create_autograd_function(autodiff_obj, use_cuda):
assert
all
(
f
.
shape
==
grad_outputs
[
i
].
shape
for
i
,
f
in
enumerate
(
grad_fields
))
assert
all
(
f
.
strides
==
tuple
(
grad_outputs
[
i
].
stride
(
j
)
for
j
in
range
(
grad_outputs
[
i
].
ndim
))
for
i
,
f
in
enumerate
(
grad_fields
))
assert
all
(
a
.
is_cuda
==
use_cuda
for
a
in
grad_outputs
),
"Some of the tensors where on the wrong device. "
f
"Op was compiled for CUDA:
{
str
(
use_cuda
)
}
"
assert
use_cuda
in
(
True
,
False
),
"use_cuda needs to be True or False"
assert
all
(
a
.
is_cuda
==
use_cuda
for
a
in
grad_outputs
),
(
"Some of the tensors where on the wrong device. "
f
"Op was compiled for CUDA:
{
str
(
use_cuda
)
}
"
)
for
field
in
autodiff_obj
.
backward_output_fields
:
backward_output_tensors
=
OrderedDict
({
f
.
name
:
torch
.
zeros
(
field
.
shape
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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