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
e9a25b8b
Commit
e9a25b8b
authored
Apr 18, 2019
by
Shucai Xiao
Browse files
code cleanup according to comments.
parent
47eee83f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
src/CMakeLists.txt
src/CMakeLists.txt
+1
-1
src/include/migraphx/quantize.hpp
src/include/migraphx/quantize.hpp
+3
-3
src/py/migraphx_py.cpp
src/py/migraphx_py.cpp
+2
-2
src/quantize.cpp
src/quantize.cpp
+7
-5
No files found.
src/CMakeLists.txt
View file @
e9a25b8b
...
...
@@ -18,7 +18,7 @@ add_library(migraphx
generate.cpp
instruction.cpp
program.cpp
quantize
_ins
.cpp
quantize.cpp
shape.cpp
schedule.cpp
pass_manager.cpp
...
...
src/include/migraphx/quantize
_ins
.hpp
→
src/include/migraphx/quantize.hpp
View file @
e9a25b8b
#ifndef MIGRAPHX_GUARD_RTGLIB_QUANTIZE_
INS_
HPP
#define MIGRAPHX_GUARD_RTGLIB_QUANTIZE_
INS_
HPP
#ifndef MIGRAPHX_GUARD_RTGLIB_QUANTIZE_HPP
#define MIGRAPHX_GUARD_RTGLIB_QUANTIZE_HPP
#include <string>
#include <vector>
...
...
@@ -12,7 +12,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
program
;
void
quantize
_ins
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
);
void
quantize
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
);
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
...
...
src/py/migraphx_py.cpp
View file @
e9a25b8b
...
...
@@ -2,7 +2,7 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <migraphx/program.hpp>
#include <migraphx/quantize
_ins
.hpp>
#include <migraphx/quantize.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/cpu/target.hpp>
#include <migraphx/stringutils.hpp>
...
...
@@ -182,7 +182,7 @@ PYBIND11_MODULE(migraphx, m)
});
m
.
def
(
"generate_argument"
,
&
migraphx
::
generate_argument
,
py
::
arg
(
"s"
),
py
::
arg
(
"seed"
)
=
0
);
m
.
def
(
"quantize
_ins
"
,
&
migraphx
::
quantize
_ins
);
m
.
def
(
"quantize"
,
&
migraphx
::
quantize
);
#ifdef HAVE_GPU
m
.
def
(
"allocate_gpu"
,
&
migraphx
::
gpu
::
allocate_gpu
,
py
::
arg
(
"s"
),
py
::
arg
(
"host"
)
=
false
);
...
...
src/quantize
_ins
.cpp
→
src/quantize.cpp
View file @
e9a25b8b
#include <migraphx/quantize
_ins
.hpp>
#include <migraphx/quantize.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/op/fp_conversion.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/ranges.hpp>
#include <utility>
namespace
migraphx
{
...
...
@@ -46,13 +47,13 @@ instruction_ref insert_fp16(program& prog,
return
ins_fp16
;
}
void
quantize
_ins
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
)
void
quantize
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
)
{
std
::
unordered_map
<
instruction_ref
,
instruction_ref
>
map_fp16
;
for
(
auto
ins
:
iterator_for
(
prog
))
{
auto
name_it
=
std
::
find
(
ins_names
.
begin
(),
ins_names
.
end
(),
ins
->
name
());
if
(
name_it
==
ins_names
.
end
())
// all indicates every instruction is converted
if
((
not
contains
(
ins_names
,
"all"
))
and
(
not
contains
(
ins_names
,
ins
->
name
())
))
{
continue
;
}
...
...
@@ -106,7 +107,8 @@ void quantize_ins(program& prog, const std::vector<std::string>& ins_names)
}
}
instruction
::
replace
(
ins
,
op
,
compute_shape
(
op
,
converted_inputs
),
converted_inputs
);
prog
.
replace_instruction
(
ins
,
op
,
converted_inputs
);
//instruction::replace(ins, op, compute_shape(op, converted_inputs), converted_inputs);
}
}
}
...
...
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