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
e4debb92
Commit
e4debb92
authored
6 years ago
by
Hashim Sharif
Browse files
Options
Downloads
Patches
Plain Diff
Loading approx metrics - InsertApproxInfo pass
parent
2c3681f8
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/lib/Transforms/InsertApproxInfo/InsertApproxInfo.cpp
+68
-1
68 additions, 1 deletion
llvm/lib/Transforms/InsertApproxInfo/InsertApproxInfo.cpp
with
68 additions
and
1 deletion
llvm/lib/Transforms/InsertApproxInfo/InsertApproxInfo.cpp
+
68
−
1
View file @
e4debb92
...
...
@@ -24,6 +24,8 @@
#include
<unordered_map>
#include
<dirent.h>
#include
<stdio.h>
#include
<sstream>
#include
<fstream>
using
namespace
llvm
;
...
...
@@ -71,6 +73,8 @@ private:
void
codeGen
(
DFInternalNode
*
N
);
void
codeGen
(
DFLeafNode
*
N
);
void
loadTrainedApproxMetrics
(
std
::
string
dir_path
);
void
loadMetricsFromFile
(
std
::
string
dir_path
,
std
::
string
file_path
);
void
readApproxValues
(
const
std
::
string
line
,
ApproxMetrics
*
approx_metrics
);
// private data
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
ApproxMetrics
*>>
operation_metrics
;
...
...
@@ -108,11 +112,72 @@ bool InsertApproxInfoWrapperPass::runOnModule(Module &M) {
}
void
InsertApproxInfo
::
readApproxValues
(
const
std
::
string
line
,
ApproxMetrics
*
approx_metrics
){
std
::
istringstream
in
(
line
);
std
::
string
op_name
;
float
approx_level
;
float
mean_l1
;
float
mean_l2
;
float
mean_linf
;
float
relative_l1
;
float
relative_l2
;
float
relative_linf
;
in
>>
op_name
;
in
>>
approx_level
;
in
>>
mean_l1
;
in
>>
mean_l2
;
in
>>
mean_linf
;
in
>>
relative_l1
;
in
>>
relative_l2
;
in
>>
relative_linf
;
printf
(
"
\n
*** op_name = %s
\n
"
,
op_name
.
c_str
());
printf
(
"approx_level = %f
\n
"
,
approx_level
);
printf
(
"relative_l1 = %f
\n
"
,
relative_l1
);
printf
(
"relative_l2 = %f
\n
"
,
relative_l2
);
printf
(
"relative_linf = %f
\n
"
,
relative_linf
);
printf
(
"mean_l1 = %f
\n
"
,
mean_l1
);
printf
(
"mean_l2 = %f
\n
"
,
mean_l2
);
printf
(
"mean_linf = %f
\n
"
,
mean_linf
);
}
void
InsertApproxInfo
::
loadMetricsFromFile
(
std
::
string
dir_path
,
std
::
string
file_path
){
std
::
string
full_path
=
dir_path
+
"/"
+
file_path
;
printf
(
"full_path = %s
\n
"
,
full_path
.
c_str
());
std
::
ifstream
infile
(
full_path
.
c_str
());
std
::
string
line
;
unsigned
int
it_count
=
0
;
while
(
std
::
getline
(
infile
,
line
)){
// Skip first line with confidence information
if
(
it_count
>
0
){
std
::
vector
<
float
>
approx_values
;
ApproxMetrics
*
approx_metrics
=
new
ApproxMetrics
;
readApproxValues
(
line
,
approx_metrics
);
}
it_count
++
;
}
}
void
InsertApproxInfo
::
loadTrainedApproxMetrics
(
std
::
string
dir_path
){
struct
dirent
*
entry
;
dir_path
+=
"/high_confidence"
;
DIR
*
dir
=
opendir
(
dir_path
.
c_str
());
if
(
dir
==
NULL
){
printf
(
"Directory %s not found . Aborting ...
\n\n
"
,
dir_path
.
c_str
());
...
...
@@ -120,7 +185,9 @@ void InsertApproxInfo::loadTrainedApproxMetrics(std::string dir_path){
}
while
((
entry
=
readdir
(
dir
))
!=
NULL
){
printf
(
"%s
\n
"
,
entry
->
d_name
);
printf
(
"f_name = %s
\n
"
,
entry
->
d_name
);
std
::
string
f_name
=
entry
->
d_name
;
loadMetricsFromFile
(
dir_path
,
f_name
);
}
...
...
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