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
7c04a372
Commit
7c04a372
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Use compile_env to get right environment for msvc
parent
6c0f5cda
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#17978
failed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencils_autodiff/tensorflow_jit.py
+6
-2
6 additions, 2 deletions
src/pystencils_autodiff/tensorflow_jit.py
tests/test_native_tensorflow_compilation.py
+3
-1
3 additions, 1 deletion
tests/test_native_tensorflow_compilation.py
with
9 additions
and
3 deletions
src/pystencils_autodiff/tensorflow_jit.py
+
6
−
2
View file @
7c04a372
...
@@ -29,6 +29,7 @@ if get_compiler_config()['os'] != 'windows':
...
@@ -29,6 +29,7 @@ if get_compiler_config()['os'] != 'windows':
_include_flags
=
[
'
-I
'
+
sysconfig
.
get_paths
()[
'
include
'
],
'
-I
'
+
get_pystencils_include_path
()]
_include_flags
=
[
'
-I
'
+
sysconfig
.
get_paths
()[
'
include
'
],
'
-I
'
+
get_pystencils_include_path
()]
_do_not_link_flag
=
"
-c
"
_do_not_link_flag
=
"
-c
"
_position_independent_flag
=
"
-fPIC
"
_position_independent_flag
=
"
-fPIC
"
_compile_environment
=
os
.
environ
.
copy
()
else
:
else
:
_do_not_link_flag
=
"
/c
"
_do_not_link_flag
=
"
/c
"
_output_flag
=
'
/OUT:
'
_output_flag
=
'
/OUT:
'
...
@@ -36,6 +37,9 @@ else:
...
@@ -36,6 +37,9 @@ else:
_include_flags
=
[
'
/I
'
+
sysconfig
.
get_paths
()[
'
include
'
],
'
/I
'
+
get_pystencils_include_path
()]
_include_flags
=
[
'
/I
'
+
sysconfig
.
get_paths
()[
'
include
'
],
'
/I
'
+
get_pystencils_include_path
()]
_position_independent_flag
=
"
/DTHIS_FLAG_DOES_NOTHING
"
_position_independent_flag
=
"
/DTHIS_FLAG_DOES_NOTHING
"
get_compiler_config
()[
'
command
'
]
=
'
cl.exe
'
get_compiler_config
()[
'
command
'
]
=
'
cl.exe
'
config_env
=
get_compiler_config
()[
'
env
'
]
if
'
env
'
in
get_compiler_config
()
else
{}
_compile_environment
=
os
.
environ
.
copy
()
_compile_environment
.
update
(
config_env
)
try
:
try
:
...
@@ -75,7 +79,7 @@ def link(object_files, destination_file=None, overwrite_destination_file=True, a
...
@@ -75,7 +79,7 @@ def link(object_files, destination_file=None, overwrite_destination_file=True, a
_output_flag
,
_output_flag
,
destination_file
]
# /out: for msvc???
destination_file
]
# /out: for msvc???
subprocess
.
check_call
(
command
)
subprocess
.
check_call
(
command
,
env
=
_compile_environment
)
return
destination_file
return
destination_file
...
@@ -147,7 +151,7 @@ def compile_file(file, use_nvcc=False, nvcc='nvcc', overwrite_destination_file=T
...
@@ -147,7 +151,7 @@ def compile_file(file, use_nvcc=False, nvcc='nvcc', overwrite_destination_file=T
destination_file
]
destination_file
]
if
not
exists
(
destination_file
)
or
overwrite_destination_file
:
if
not
exists
(
destination_file
)
or
overwrite_destination_file
:
subprocess
.
check_call
(
command
)
subprocess
.
check_call
(
command
,
env
=
_compile_environment
)
return
destination_file
return
destination_file
...
...
This diff is collapsed.
Click to expand it.
tests/test_native_tensorflow_compilation.py
+
3
−
1
View file @
7c04a372
...
@@ -23,6 +23,8 @@ from pystencils_autodiff.backends.astnodes import TensorflowModule
...
@@ -23,6 +23,8 @@ from pystencils_autodiff.backends.astnodes import TensorflowModule
import
pystencils
import
pystencils
from
pystencils.cpu.cpujit
import
get_compiler_config
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.tensorflow_jit
import
_compile_env
def
test_detect_cpu_vs_cpu
():
def
test_detect_cpu_vs_cpu
():
...
@@ -78,7 +80,7 @@ def test_native_tensorflow_compilation_cpu():
...
@@ -78,7 +80,7 @@ def test_native_tensorflow_compilation_cpu():
command
=
[
'
c++
'
,
'
-fPIC
'
,
temp_file
.
name
,
'
-O2
'
,
'
-shared
'
,
command
=
[
'
c++
'
,
'
-fPIC
'
,
temp_file
.
name
,
'
-O2
'
,
'
-shared
'
,
'
-o
'
,
'
foo.so
'
]
+
compile_flags
+
link_flags
+
extra_flags
'
-o
'
,
'
foo.so
'
]
+
compile_flags
+
link_flags
+
extra_flags
print
(
command
)
print
(
command
)
subprocess
.
check_call
(
command
)
subprocess
.
check_call
(
command
,
env
=
_compile_env
)
lib
=
tf
.
load_op_library
(
join
(
os
.
getcwd
(),
'
foo.so
'
))
lib
=
tf
.
load_op_library
(
join
(
os
.
getcwd
(),
'
foo.so
'
))
assert
'
call_forward
'
in
dir
(
lib
)
assert
'
call_forward
'
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