Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
hpvm-release
Commits
5837cfe5
Commit
5837cfe5
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Added code to handle local paths for fp32 row
parent
26eb0e32
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
llvm/projects/hpvm-tensor-rt/code_autogenerators/source_code_autogenerator.py
+23
-11
23 additions, 11 deletions
...ensor-rt/code_autogenerators/source_code_autogenerator.py
with
23 additions
and
11 deletions
llvm/projects/hpvm-tensor-rt/code_autogenerators/source_code_autogenerator.py
+
23
−
11
View file @
5837cfe5
...
@@ -113,19 +113,19 @@ def get_new_function_calls(complete_line, knob_config):
...
@@ -113,19 +113,19 @@ def get_new_function_calls(complete_line, knob_config):
return
''
.
join
(
new_line
)
return
''
.
join
(
new_line
)
def
generate_fp32_source
(
new_file
,
source_file
):
def
convert_local_paths
(
file_contents
,
orig_source_dir
):
# Copy the source code over
'''
new_file
.
write
(
source_file
.
read
())
Converts all local paths wrt the original source file
'
s directory to paths compatible
with the current source code directory
def
generate_fp16_source
(
knob_config
,
new_file
,
source_file
,
orig_source_dir
):
file_contents
=
source_file
.
read
()
# Fix all local paths
Args:
file_contents: String containing source code read from file
orig_source_dir: Path of original source code dir wrt the current directory
'''
last_include_ind
=
file_contents
.
rfind
(
"
#include
"
)
last_include_ind
=
file_contents
.
rfind
(
"
#include
"
)
last_include_newline_ind
=
file_contents
.
find
(
"
\n
"
,
last_include_ind
)
last_include_newline_ind
=
file_contents
.
find
(
"
\n
"
,
last_include_ind
)
include_lines
=
file_contents
[
:
last_include_newline_ind
].
split
(
"
\n
"
)
include_lines
=
file_contents
[
:
last_include_newline_ind
].
split
(
"
\n
"
)
new_file_contents
=
[]
new_file_contents
=
[]
for
line
in
include_lines
:
for
line
in
include_lines
:
if
line
.
startswith
(
"
#
"
):
if
line
.
startswith
(
"
#
"
):
...
@@ -136,7 +136,19 @@ def generate_fp16_source(knob_config, new_file, source_file, orig_source_dir):
...
@@ -136,7 +136,19 @@ def generate_fp16_source(knob_config, new_file, source_file, orig_source_dir):
else
:
else
:
new_file_contents
.
append
(
line
)
new_file_contents
.
append
(
line
)
new_file_contents
.
append
(
file_contents
[
last_include_newline_ind
:
])
new_file_contents
.
append
(
file_contents
[
last_include_newline_ind
:
])
new_file_contents
=
'
\n
'
.
join
(
new_file_contents
)
return
'
\n
'
.
join
(
new_file_contents
)
def
generate_fp32_source
(
new_file
,
source_file
,
orig_source_dir
):
# Copy the source code over
new_file_contents
=
convert_local_paths
(
source_file
.
read
(),
orig_source_dir
)
new_file
.
write
(
new_file_contents
)
def
generate_fp16_source
(
knob_config
,
new_file
,
source_file
,
orig_source_dir
):
file_contents
=
source_file
.
read
()
new_file_contents
=
convert_local_paths
(
file_contents
,
orig_source_dir
)
# Replace all tensorOperation calls with tensorHalfOperation calls
# Replace all tensorOperation calls with tensorHalfOperation calls
# Derived from ../bin/replace_half_calls.py
# Derived from ../bin/replace_half_calls.py
...
@@ -207,7 +219,7 @@ def generate_source_code(table, dir_name, filename, source_name):
...
@@ -207,7 +219,7 @@ def generate_source_code(table, dir_name, filename, source_name):
if
knob_config
.
approx
==
Approx
.
FP16
:
if
knob_config
.
approx
==
Approx
.
FP16
:
generate_fp16_source
(
knob_config
,
new_file
,
source_file
,
orig_source_dir
)
generate_fp16_source
(
knob_config
,
new_file
,
source_file
,
orig_source_dir
)
elif
knob_config
.
approx
==
Approx
.
FP32
:
elif
knob_config
.
approx
==
Approx
.
FP32
:
generate_fp32_source
(
new_file
,
source_file
)
generate_fp32_source
(
new_file
,
source_file
,
orig_source_dir
)
else
:
else
:
generate_approx_source
(
knob_config
,
new_file
,
source_file
,
orig_source_dir
)
generate_approx_source
(
knob_config
,
new_file
,
source_file
,
orig_source_dir
)
...
...
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