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
f6a7e705
Commit
f6a7e705
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Make hashing work for tensorflow_jit
parent
3bcda22b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils_autodiff/tensorflow_jit.py
+8
-2
8 additions, 2 deletions
src/pystencils_autodiff/tensorflow_jit.py
with
8 additions
and
2 deletions
src/pystencils_autodiff/tensorflow_jit.py
+
8
−
2
View file @
f6a7e705
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
"""
"""
"""
"""
import
hashlib
import
json
import
json
import
subprocess
import
subprocess
import
sysconfig
import
sysconfig
...
@@ -18,6 +19,9 @@ import pystencils
...
@@ -18,6 +19,9 @@ import pystencils
from
pystencils.cpu.cpujit
import
get_cache_config
,
get_compiler_config
,
get_pystencils_include_path
from
pystencils.cpu.cpujit
import
get_cache_config
,
get_compiler_config
,
get_pystencils_include_path
from
pystencils_autodiff._file_io
import
read_file
,
write_file
from
pystencils_autodiff._file_io
import
read_file
,
write_file
_hash
=
hashlib
.
md5
# TODO: msvc
# TODO: msvc
if
get_compiler_config
()[
'
os
'
]
!=
'
windows
'
:
if
get_compiler_config
()[
'
os
'
]
!=
'
windows
'
:
_shared_object_flag
=
'
-shared
'
_shared_object_flag
=
'
-shared
'
...
@@ -56,7 +60,8 @@ def link_and_load(object_files, destination_file=None, overwrite_destination_fil
...
@@ -56,7 +60,8 @@ def link_and_load(object_files, destination_file=None, overwrite_destination_fil
"""
"""
if
not
destination_file
:
if
not
destination_file
:
destination_file
=
join
(
get_cache_config
()[
'
object_cache
'
],
f
"
{
abs
(
hash
(
tuple
(
object_files
)))
:
x
}
.so
"
)
destination_file
=
join
(
get_cache_config
()[
'
object_cache
'
],
f
"
{
_hash
(
'
.
'
.
join
(
sorted
(
object_files
)).
encode
()).
hexdigest
()
}
.so
"
)
if
not
exists
(
destination_file
)
or
overwrite_destination_file
:
if
not
exists
(
destination_file
)
or
overwrite_destination_file
:
command
=
[
get_compiler_config
()[
'
command
'
],
command
=
[
get_compiler_config
()[
'
command
'
],
...
@@ -136,6 +141,7 @@ def compile_file(file, use_nvcc=False, nvcc='nvcc', overwrite_destination_file=T
...
@@ -136,6 +141,7 @@ def compile_file(file, use_nvcc=False, nvcc='nvcc', overwrite_destination_file=T
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
)
return
destination_file
return
destination_file
...
@@ -152,7 +158,7 @@ def compile_sources_and_load(host_sources, cuda_sources=[], additional_compile_f
...
@@ -152,7 +158,7 @@ def compile_sources_and_load(host_sources, cuda_sources=[], additional_compile_f
source_code
=
source
source_code
=
source
file_extension
=
'
.cu
'
if
is_cuda
else
'
.cpp
'
file_extension
=
'
.cu
'
if
is_cuda
else
'
.cpp
'
file_name
=
join
(
pystencils
.
cache
.
cache_dir
,
f
'
{
abs
(
hash
(
source_code
))
:
x
}{
file_extension
}
'
)
file_name
=
join
(
pystencils
.
cache
.
cache_dir
,
f
'
{
_
hash
(
source_code
.
encode
()).
hexdigest
()
}{
file_extension
}
'
)
write_file
(
file_name
,
source_code
)
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
,
...
...
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