Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pystencils_autodiff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
pycodegen
pystencils_autodiff
Commits
bb88ec51
Commit
bb88ec51
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Instantiate function class
parent
374d0fd5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencils_autodiff/backends/_torch_native.py
+2
-3
2 additions, 3 deletions
src/pystencils_autodiff/backends/_torch_native.py
tests/backends/test_torch_native_compilation.py
+2
-2
2 additions, 2 deletions
tests/backends/test_torch_native_compilation.py
with
4 additions
and
5 deletions
src/pystencils_autodiff/backends/_torch_native.py
+
2
−
3
View file @
bb88ec51
...
...
@@ -139,8 +139,7 @@ def create_autograd_function(autodiff_obj, inputfield_to_tensor_dict, forward_lo
os
.
mkdir
(
cache_dir
)
# TODO: create function and stuff
compiled_operation
=
generate_torch
(
cache_dir
,
autodiff_obj
,
is_cuda
,
dtype
)
compiled_operation
=
generate_torch
(
cache_dir
,
autodiff_obj
,
is_cuda
,
dtype
)
field_to_tensor_dict
=
inputfield_to_tensor_dict
# Allocate output tensor for forward and backward pass
for
field
in
chain
(
autodiff_obj
.
forward_output_fields
,
autodiff_obj
.
backward_output_fields
):
...
...
@@ -164,7 +163,7 @@ def create_autograd_function(autodiff_obj, inputfield_to_tensor_dict, forward_lo
cls
.
saved
=
None
cls
.
forward
=
forward
cls
.
backward
=
backward
return
cls
return
cls
()
else
:
op
=
pystencils_autodiff
.
backends
.
_pytorch
.
create_autograd_function
(
autodiff_obj
,
inputfield_to_tensor_dict
,
...
...
This diff is collapsed.
Click to expand it.
tests/backends/test_torch_native_compilation.py
+
2
−
2
View file @
bb88ec51
...
...
@@ -168,7 +168,7 @@ def test_execute_torch():
y_tensor
=
pystencils_autodiff
.
torch_tensor_from_field
(
y
,
1
,
cuda
=
False
)
op_cpp
=
create_autograd_function
(
autodiff
,
{
x
:
x_tensor
,
y
:
y_tensor
})
foo
=
op_cpp
.
forward
(
x_tensor
)
foo
=
op_cpp
.
forward
()
print
(
foo
)
assert
op_cpp
is
not
None
...
...
@@ -189,7 +189,7 @@ def test_execute_torch_gpu():
op_cuda
=
create_autograd_function
(
autodiff
,
{
x
:
x_tensor
,
y
:
y_tensor
})
assert
op_cuda
is
not
None
rtn
=
op_cuda
.
forward
(
y_tensor
,
x_tensor
)
rtn
=
op_cuda
.
forward
()
print
(
y_tensor
)
print
(
rtn
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment