Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
morse_cmake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
morse_cmake
Commits
0622c996
Commit
0622c996
authored
2 years ago
by
Mathieu Faverge
Browse files
Options
Downloads
Patches
Plain Diff
Add a preliminary pass on mixed precision files
parent
becf28f4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/precision_generator/codegen.py
+40
-1
40 additions, 1 deletion
modules/precision_generator/codegen.py
with
40 additions
and
1 deletion
modules/precision_generator/codegen.py
+
40
−
1
View file @
0622c996
...
...
@@ -181,7 +181,46 @@ class SourceFile( object ):
# --------------------
def
_substitute
(
self
,
text
,
precision
):
'''
Apply substitutions to text for given precision.
'''
'''
Apply substitutions to text for given precision.
If we use mixed precision algrotihm as input and output, we
apply a first pass from single precision, and then the mixed
one.
'''
if
self
.
_src
[
0
]
==
'
x
'
and
precision
[
0
]
==
'
x
'
:
precfrom
=
self
.
_src
[
1
]
precto
=
precision
[
1
]
try
:
# Get substitution table based on self._table
subs_o
=
self
.
_subs
.
subs
[
self
.
_table
]
# original
subs_s
=
self
.
_subs
.
subs_search
[
self
.
_table
]
# compiled as search regexp
subs_r
=
self
.
_subs
.
subs_replace
[
self
.
_table
]
# with regexp removed for replacement
# Get which column is from and to.
header
=
subs_o
[
0
]
jfrom
=
header
.
index
(
precfrom
)
jto
=
header
.
index
(
precto
)
except
Exception
as
err
:
print
(
"
Error: bad table or precision in
'
%s
'
, @precisions %s %s -> %s:
"
%
(
self
.
_filename
,
self
.
_table
,
precfrom
,
self
.
_dsts
),
file
=
sys
.
stderr
)
traceback
.
print_exc
()
exit
(
1
)
# Apply substitutions
try
:
line
=
0
for
(
orig
,
search
,
replace
)
in
zip
(
subs_o
[
1
:],
subs_s
[
1
:],
subs_r
[
1
:]
):
line
+=
1
if
search
[
jfrom
]
is
None
:
search
[
jfrom
]
=
re
.
compile
(
orig
[
jfrom
]
)
text
=
re
.
sub
(
search
[
jfrom
],
replace
[
jto
],
text
)
# end
except
Exception
as
err
:
print
(
"
Error: in row %d of substitution table
'
%s
'
: %s
"
%
(
line
,
self
.
_table
,
subs_o
[
line
]),
file
=
sys
.
stderr
)
traceback
.
print_exc
()
exit
(
1
)
try
:
# Get substitution table based on self._table
subs_o
=
self
.
_subs
.
subs
[
self
.
_table
]
# original
...
...
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