Commit e9a25b8b authored by Shucai Xiao's avatar Shucai Xiao
Browse files

code cleanup according to comments.

parent 47eee83f
...@@ -18,7 +18,7 @@ add_library(migraphx ...@@ -18,7 +18,7 @@ add_library(migraphx
generate.cpp generate.cpp
instruction.cpp instruction.cpp
program.cpp program.cpp
quantize_ins.cpp quantize.cpp
shape.cpp shape.cpp
schedule.cpp schedule.cpp
pass_manager.cpp pass_manager.cpp
......
#ifndef MIGRAPHX_GUARD_RTGLIB_QUANTIZE_INS_HPP #ifndef MIGRAPHX_GUARD_RTGLIB_QUANTIZE_HPP
#define MIGRAPHX_GUARD_RTGLIB_QUANTIZE_INS_HPP #define MIGRAPHX_GUARD_RTGLIB_QUANTIZE_HPP
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -12,7 +12,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -12,7 +12,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct program; 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_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/quantize_ins.hpp> #include <migraphx/quantize.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/cpu/target.hpp> #include <migraphx/cpu/target.hpp>
#include <migraphx/stringutils.hpp> #include <migraphx/stringutils.hpp>
...@@ -182,7 +182,7 @@ PYBIND11_MODULE(migraphx, m) ...@@ -182,7 +182,7 @@ PYBIND11_MODULE(migraphx, m)
}); });
m.def("generate_argument", &migraphx::generate_argument, py::arg("s"), py::arg("seed") = 0); 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 #ifdef HAVE_GPU
m.def("allocate_gpu", &migraphx::gpu::allocate_gpu, py::arg("s"), py::arg("host") = false); m.def("allocate_gpu", &migraphx::gpu::allocate_gpu, py::arg("s"), py::arg("host") = false);
......
#include <migraphx/quantize_ins.hpp> #include <migraphx/quantize.hpp>
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/instruction.hpp> #include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp> #include <migraphx/iterator_for.hpp>
#include <migraphx/op/fp_conversion.hpp> #include <migraphx/op/fp_conversion.hpp>
#include <migraphx/stringutils.hpp> #include <migraphx/stringutils.hpp>
#include <migraphx/ranges.hpp>
#include <utility> #include <utility>
namespace migraphx { namespace migraphx {
...@@ -46,13 +47,13 @@ instruction_ref insert_fp16(program& prog, ...@@ -46,13 +47,13 @@ instruction_ref insert_fp16(program& prog,
return ins_fp16; 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; std::unordered_map<instruction_ref, instruction_ref> map_fp16;
for(auto ins : iterator_for(prog)) for(auto ins : iterator_for(prog))
{ {
auto name_it = std::find(ins_names.begin(), ins_names.end(), ins->name()); // all indicates every instruction is converted
if(name_it == ins_names.end()) if ((not contains(ins_names, "all")) and (not contains(ins_names, ins->name())))
{ {
continue; continue;
} }
...@@ -106,7 +107,8 @@ void quantize_ins(program& prog, const std::vector<std::string>& ins_names) ...@@ -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);
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment