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
9bb91d78
Commit
9bb91d78
authored
5 years ago
by
Elizabeth
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up code
parent
70cb1583
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+14
-4
14 additions, 4 deletions
...ensor-rt/code_autogenerators/source_code_autogenerator.py
with
14 additions
and
4 deletions
llvm/projects/hpvm-tensor-rt/code_autogenerators/source_code_autogenerator.py
+
14
−
4
View file @
9bb91d78
...
@@ -46,7 +46,18 @@ def get_new_path(old_path, orig_source_code_dir):
...
@@ -46,7 +46,18 @@ def get_new_path(old_path, orig_source_code_dir):
# "complete_line" = a valid line of code
# "complete_line" = a valid line of code
def
replace_function_calls
(
complete_line
,
knob_config
):
def
get_new_function_calls
(
complete_line
,
knob_config
):
'''
Returns a copy of an inputted line of code such that all instances of old
function calls are replaced with newFunctionCall(old params, knobs)
Note: The old calls aren
'
t completely overriden, as we still need the old parameters but
insert new parameters as well
Args:
complete_line: A complete line of code to process
knob_config: KnobConfiguration object representing current configuration
'''
orig_func_ind
=
complete_line
.
find
(
knob_config
.
orig_func_name
)
orig_func_ind
=
complete_line
.
find
(
knob_config
.
orig_func_name
)
new_line
=
[]
new_line
=
[]
line_start_ind
=
0
line_start_ind
=
0
...
@@ -57,8 +68,7 @@ def replace_function_calls(complete_line, knob_config):
...
@@ -57,8 +68,7 @@ def replace_function_calls(complete_line, knob_config):
line_start_ind
=
complete_line
.
find
(
"
)
"
,
orig_func_ind
)
+
1
line_start_ind
=
complete_line
.
find
(
"
)
"
,
orig_func_ind
)
+
1
old_func_call
=
complete_line
[
complete_line
.
find
(
"
(
"
,
orig_func_ind
):
line_start_ind
]
old_func_call
=
complete_line
[
complete_line
.
find
(
"
(
"
,
orig_func_ind
):
line_start_ind
]
new_line
.
append
(
knob_config
.
modified_func_name
+
old_func_call
[:
-
1
]
+
"
,
"
\
new_line
.
append
(
"
%s%s, %s)
"
%
(
knob_config
.
modified_func_name
,
old_func_call
[:
-
1
],
'
,
'
.
join
(
knob_config
.
params
)))
+
'
,
'
.
join
(
knob_config
.
params
)
+
"
)
"
)
orig_func_ind
=
complete_line
.
find
(
knob_config
.
orig_func_name
,
line_start_ind
)
orig_func_ind
=
complete_line
.
find
(
knob_config
.
orig_func_name
,
line_start_ind
)
new_line
.
append
(
complete_line
[
line_start_ind
:
])
new_line
.
append
(
complete_line
[
line_start_ind
:
])
#print(new_line)
#print(new_line)
...
@@ -110,7 +120,7 @@ def generate_source_code(table, dir_name, filename, source_name):
...
@@ -110,7 +120,7 @@ def generate_source_code(table, dir_name, filename, source_name):
complete_line
+=
line
complete_line
+=
line
orig_func_ind
=
complete_line
.
find
(
knob_config
.
orig_func_name
)
orig_func_ind
=
complete_line
.
find
(
knob_config
.
orig_func_name
)
if
orig_func_ind
!=
-
1
:
if
orig_func_ind
!=
-
1
:
new_file_contents
.
append
(
replace
_function_calls
(
complete_line
,
knob_config
))
new_file_contents
.
append
(
get_new
_function_calls
(
complete_line
,
knob_config
))
else
:
else
:
new_file_contents
.
append
(
complete_line
)
new_file_contents
.
append
(
complete_line
)
complete_line
=
""
complete_line
=
""
...
...
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