Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
762cee10
Commit
762cee10
authored
May 22, 2019
by
Shucai Xiao
Browse files
Merge branch 'develop' of
https://github.com/ROCmSoftwarePlatform/AMDMIGraphX
into int8_quantize
parents
33c69d55
0d796941
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
7 deletions
+38
-7
src/env.cpp
src/env.cpp
+8
-0
src/include/migraphx/env.hpp
src/include/migraphx/env.hpp
+9
-0
src/include/migraphx/raw_data.hpp
src/include/migraphx/raw_data.hpp
+12
-5
src/program.cpp
src/program.cpp
+9
-2
No files found.
src/env.cpp
View file @
762cee10
...
...
@@ -21,6 +21,14 @@ bool disabled(const char* name)
return
contains
({
"0"
,
"disable"
,
"disabled"
,
"no"
,
"false"
},
e
.
front
());
}
std
::
size_t
value_of
(
const
char
*
name
)
{
auto
e
=
env
(
name
);
if
(
e
.
empty
())
return
0
;
return
std
::
stoul
(
e
.
front
());
}
std
::
vector
<
std
::
string
>
env
(
const
char
*
name
)
{
auto
p
=
std
::
getenv
(
name
);
...
...
src/include/migraphx/env.hpp
View file @
762cee10
...
...
@@ -19,6 +19,8 @@ bool enabled(const char* name);
bool
disabled
(
const
char
*
name
);
std
::
vector
<
std
::
string
>
env
(
const
char
*
name
);
std
::
size_t
value_of
(
const
char
*
name
);
template
<
class
T
>
bool
enabled
(
T
)
{
...
...
@@ -33,6 +35,13 @@ bool disabled(T)
return
result
;
}
template
<
class
T
>
std
::
size_t
value_of
(
T
)
{
static
const
std
::
size_t
result
=
value_of
(
T
::
value
());
return
result
;
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/include/migraphx/raw_data.hpp
View file @
762cee10
...
...
@@ -27,7 +27,8 @@ struct raw_data : raw_data_base
template
<
class
Stream
>
friend
Stream
&
operator
<<
(
Stream
&
os
,
const
Derived
&
d
)
{
d
.
visit
([
&
](
auto
x
)
{
os
<<
x
;
});
if
(
not
d
.
empty
())
d
.
visit
([
&
](
auto
x
)
{
os
<<
x
;
});
return
os
;
}
...
...
@@ -40,8 +41,11 @@ struct raw_data : raw_data_base
template
<
class
Visitor
>
void
visit_at
(
Visitor
v
,
std
::
size_t
n
=
0
)
const
{
auto
&&
s
=
static_cast
<
const
Derived
&>
(
*
this
).
get_shape
();
auto
&&
buffer
=
static_cast
<
const
Derived
&>
(
*
this
).
data
();
auto
&&
derived
=
static_cast
<
const
Derived
&>
(
*
this
);
if
(
derived
.
empty
())
MIGRAPHX_THROW
(
"Visiting empty data!"
);
auto
&&
s
=
derived
.
get_shape
();
auto
&&
buffer
=
derived
.
data
();
s
.
visit_type
([
&
](
auto
as
)
{
v
(
*
(
as
.
from
(
buffer
)
+
s
.
index
(
n
)));
});
}
...
...
@@ -55,8 +59,11 @@ struct raw_data : raw_data_base
template
<
class
Visitor
>
void
visit
(
Visitor
v
)
const
{
auto
&&
s
=
static_cast
<
const
Derived
&>
(
*
this
).
get_shape
();
auto
&&
buffer
=
static_cast
<
const
Derived
&>
(
*
this
).
data
();
auto
&&
derived
=
static_cast
<
const
Derived
&>
(
*
this
);
if
(
derived
.
empty
())
MIGRAPHX_THROW
(
"Visiting empty data!"
);
auto
&&
s
=
derived
.
get_shape
();
auto
&&
buffer
=
derived
.
data
();
s
.
visit_type
([
&
](
auto
as
)
{
v
(
make_view
(
s
,
as
.
from
(
buffer
)));
});
}
...
...
src/program.cpp
View file @
762cee10
...
...
@@ -437,13 +437,20 @@ argument program::eval(std::unordered_map<std::string, argument> params) const
#else
auto
check_context
=
[](
auto
f
)
{
return
f
();
};
#endif
if
(
enabled
(
MIGRAPHX_TRACE_EVAL
{}))
auto
trace_level
=
value_of
(
MIGRAPHX_TRACE_EVAL
{});
if
(
trace_level
>
0
)
{
return
generic_eval
(
*
this
,
ctx
,
std
::
move
(
params
),
[
&
](
auto
&
ins
,
auto
f
)
{
ctx
.
finish
();
std
::
cout
<<
"Run instruction: "
;
this
->
debug_print
(
ins
);
return
check_context
(
f
);
auto
result
=
check_context
(
f
);
ctx
.
finish
();
if
(
trace_level
>
1
and
ins
->
name
().
front
()
!=
'@'
and
ins
->
name
()
!=
"load"
)
std
::
cout
<<
"Ouput: "
<<
result
<<
std
::
endl
;
return
result
;
});
}
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment