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
3bcda22b
Commit
3bcda22b
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Enable additional_compile_flags, additional_link_flags for tensorflow_jit
parent
0cccbe5e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#17930
failed
5 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils_autodiff/tensorflow_jit.py
+9
-5
9 additions, 5 deletions
src/pystencils_autodiff/tensorflow_jit.py
with
9 additions
and
5 deletions
src/pystencils_autodiff/tensorflow_jit.py
+
9
−
5
View file @
3bcda22b
...
...
@@ -42,7 +42,7 @@ except ImportError:
pass
def
link_and_load
(
object_files
,
destination_file
=
None
,
overwrite_destination_file
=
True
):
def
link_and_load
(
object_files
,
destination_file
=
None
,
overwrite_destination_file
=
True
,
additional_link_flags
=
[]
):
"""
Compiles given :param:`source_file` to a Tensorflow shared Library.
.. warning::
...
...
@@ -64,6 +64,7 @@ def link_and_load(object_files, destination_file=None, overwrite_destination_fil
*
object_files
,
*
_tf_link_flags
,
*
_include_flags
,
*
additional_link_flags
,
_shared_object_flag
,
_output_flag
,
destination_file
]
# /out: for msvc???
...
...
@@ -97,7 +98,7 @@ if pystencils.gpucuda.cudajit.USE_FAST_MATH:
_nvcc_flags
.
append
(
'
-use_fast_math
'
)
def
compile_file
(
file
,
use_nvcc
=
False
,
nvcc
=
'
nvcc
'
,
overwrite_destination_file
=
True
):
def
compile_file
(
file
,
use_nvcc
=
False
,
nvcc
=
'
nvcc
'
,
overwrite_destination_file
=
True
,
additional_compile_flags
=
[]
):
if
'
tensorflow_host_compiler
'
not
in
get_compiler_config
():
get_compiler_config
()[
'
tensorflow_host_compiler
'
]
=
get_compiler_config
()[
'
command
'
]
write_file
(
pystencils
.
cpu
.
cpujit
.
get_configuration_file_path
(),
json
.
dumps
(
pystencils
.
cpu
.
cpujit
.
_config
))
...
...
@@ -119,6 +120,7 @@ def compile_file(file, use_nvcc=False, nvcc='nvcc', overwrite_destination_file=T
_do_not_link_flag
,
*
_tf_compile_flags
,
*
_include_flags
,
*
additional_compile_flags
,
_output_flag
,
destination_file
]
else
:
...
...
@@ -128,6 +130,7 @@ def compile_file(file, use_nvcc=False, nvcc='nvcc', overwrite_destination_file=T
_do_not_link_flag
,
*
_tf_compile_flags
,
*
_include_flags
,
*
additional_compile_flags
,
_output_flag
,
destination_file
]
...
...
@@ -136,7 +139,7 @@ def compile_file(file, use_nvcc=False, nvcc='nvcc', overwrite_destination_file=T
return
destination_file
def
compile_sources_and_load
(
host_sources
,
cuda_sources
=
[]):
def
compile_sources_and_load
(
host_sources
,
cuda_sources
=
[]
,
additional_compile_flags
=
[],
additional_link_flags
=
[]
):
object_files
=
[]
...
...
@@ -152,11 +155,12 @@ def compile_sources_and_load(host_sources, cuda_sources=[]):
file_name
=
join
(
pystencils
.
cache
.
cache_dir
,
f
'
{
abs
(
hash
(
source_code
))
:
x
}{
file_extension
}
'
)
write_file
(
file_name
,
source_code
)
compile_file
(
file_name
,
use_nvcc
=
is_cuda
,
overwrite_destination_file
=
False
)
compile_file
(
file_name
,
use_nvcc
=
is_cuda
,
overwrite_destination_file
=
False
,
additional_compile_flags
=
additional_compile_flags
)
object_files
.
append
(
file_name
+
'
.o
'
)
print
(
'
Linking Tensorflow module...
'
)
module
=
link_and_load
(
object_files
,
overwrite_destination_file
=
False
)
module
=
link_and_load
(
object_files
,
overwrite_destination_file
=
False
,
additional_link_flags
=
additional_link_flags
)
if
module
:
print
(
'
Loaded Tensorflow module.
'
)
return
module
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