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
3b2eb160
Commit
3b2eb160
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Update test_native_tensorflow_compilation
parent
bce14b17
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_native_tensorflow_compilation.py
+13
-7
13 additions, 7 deletions
tests/test_native_tensorflow_compilation.py
with
13 additions
and
7 deletions
tests/test_native_tensorflow_compilation.py
+
13
−
7
View file @
3b2eb160
...
@@ -18,6 +18,7 @@ import pytest
...
@@ -18,6 +18,7 @@ import pytest
import
sympy
import
sympy
import
pystencils
import
pystencils
from
pystencils.cpu.cpujit
import
get_compiler_config
from
pystencils.include
import
get_pystencils_include_path
from
pystencils.include
import
get_pystencils_include_path
from
pystencils_autodiff
import
create_backward_assignments
from
pystencils_autodiff
import
create_backward_assignments
from
pystencils_autodiff._file_io
import
write_file
from
pystencils_autodiff._file_io
import
write_file
...
@@ -111,17 +112,23 @@ def test_native_tensorflow_compilation_gpu():
...
@@ -111,17 +112,23 @@ def test_native_tensorflow_compilation_gpu():
backward_ast
=
pystencils
.
create_kernel
(
backward_assignments
,
target
)
backward_ast
=
pystencils
.
create_kernel
(
backward_assignments
,
target
)
backward_ast
.
function_name
=
'
backward
'
backward_ast
.
function_name
=
'
backward
'
module
=
TensorflowModule
(
module_name
,
[
forward_ast
,
backward_ast
])
module
=
TensorflowModule
(
module_name
,
[
forward_ast
,
backward_ast
])
print
(
module
)
print
(
str
(
module
)
)
temp_file
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'
.cu
'
if
target
==
'
gpu
'
else
'
.cpp
'
)
temp_file
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'
.cu
'
if
target
==
'
gpu
'
else
'
.cpp
'
)
print
(
temp_file
.
name
)
print
(
temp_file
.
name
)
write_file
(
temp_file
.
name
,
str
(
module
))
write_file
(
temp_file
.
name
,
str
(
module
))
if
'
tensorflow_host_compiler
'
not
in
get_compiler_config
():
get_compiler_config
()[
'
tensorflow_host_compiler
'
]
=
get_compiler_config
()[
'
command
'
]
# on my machine g++-6 and clang-7 are working
# on my machine g++-6 and clang-7 are working
# '-ccbin',
# 'g++-6',
command
=
[
'
nvcc
'
,
command
=
[
'
nvcc
'
,
temp_file
.
name
,
temp_file
.
name
,
'
-lcudart
'
,
'
-lcudart
'
,
'
--expt-relaxed-constexpr
'
,
'
--expt-relaxed-constexpr
'
,
'
-ccbin
'
,
get_compiler_config
()[
'
tensorflow_host_compiler
'
],
'
-lcudart
'
,
'
-lcudart
'
,
'
-std=c++14
'
,
'
-std=c++14
'
,
'
-x
'
,
'
-x
'
,
...
@@ -130,18 +137,17 @@ def test_native_tensorflow_compilation_gpu():
...
@@ -130,18 +137,17 @@ def test_native_tensorflow_compilation_gpu():
'
-fPIC
'
,
'
-fPIC
'
,
'
-c
'
,
'
-c
'
,
'
-o
'
,
'
-o
'
,
'
foo_gpu.o
'
]
+
link_flags
+
compile_flags
+
extra_flags
'
foo_gpu.o
'
]
+
compile_flags
+
extra_flags
print
(
command
)
subprocess
.
check_call
(
command
)
subprocess
.
check_call
(
command
)
# command = ['clang-7', '-shared', temp_file.name, '--cuda-path=/usr/include', '-std=c++14',
# command = ['clang-7', '-shared', temp_file.name, '--cuda-path=/usr/include', '-std=c++14',
# '-fPIC', '-lcudart', '-o', 'foo.so'] + compile_flags + link_flags + extra_flags
# '-fPIC', '-lcudart', '-o', 'foo.so'] + compile_flags + link_flags + extra_flags
command
=
[
'
c++
'
,
'
-std=c++14
'
,
'
-fPIC
'
,
'
-lcudart
'
,
'
foo_gpu.o
'
,
command
=
[
'
c++
'
,
'
-fPIC
'
,
'
-lcudart
'
,
'
foo_gpu.o
'
,
'
-shared
'
,
'
-o
'
,
'
foo.so
'
]
+
compile_flags
+
link_flags
+
extra
_flags
'
-shared
'
,
'
-o
'
,
'
foo.so
'
]
+
link
_flags
print
(
command
)
subprocess
.
check_call
(
command
)
subprocess
.
check_call
(
command
)
lib
=
tf
.
load_op_library
(
join
(
os
.
getcwd
(),
'
foo.so
'
))
lib
=
tf
.
load_op_library
(
join
(
os
.
getcwd
(),
'
foo.so
'
))
print
(
dir
(
lib
))
assert
'
call_forward
'
in
dir
(
lib
)
assert
'
call_forward
'
in
dir
(
lib
)
assert
'
call_backward
'
in
dir
(
lib
)
assert
'
call_backward
'
in
dir
(
lib
)
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