Unverified Commit 40fbef9b authored by Ted Themistokleous's avatar Ted Themistokleous Committed by GitHub
Browse files

Merge branch 'develop' into threaded_nms

parents d164b151 aeb9f78c
......@@ -36,7 +36,7 @@ struct module_pass_manager;
/**
* Runs several passes in a loop
*/
struct optimize_module
struct MIGRAPHX_EXPORT optimize_module
{
std::string name() const { return "optimize_module"; }
void apply(module_pass_manager& mpm) const;
......
......@@ -32,6 +32,7 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
MIGRAPHX_EXPORT
void calculate_padding(int64_t idx,
std::vector<int64_t>& pads,
int64_t input_dim,
......@@ -45,6 +46,7 @@ void calculate_padding(int64_t idx,
* where the padding calculation must be done at evaluation time.
* \return padding in the form of {x0_begin, x1_begin, ... x0_end , x1_end, ...}
*/
MIGRAPHX_EXPORT
std::vector<std::size_t> calc_dyn_auto_pad(const std::vector<std::size_t>& input_lens,
const std::vector<std::size_t>& wei_lens,
const std::vector<std::size_t>& strides,
......@@ -53,6 +55,7 @@ std::vector<std::size_t> calc_dyn_auto_pad(const std::vector<std::size_t>& input
// Used for dynamic auto padding of convolution operators since padding needs to be computed at
// evaulation time.
MIGRAPHX_EXPORT
shape compute_padded_shape(const shape& input,
const shape& weights,
const std::vector<std::size_t>& padding,
......
......@@ -57,7 +57,7 @@ struct pass
#else
module& get_module(module_pass_manager& mpm);
MIGRAPHX_EXPORT module& get_module(module_pass_manager& mpm);
namespace detail {
......@@ -84,7 +84,7 @@ void module_pass_manager_apply(const T& x, module_pass_manager& mpm)
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct pass
struct MIGRAPHX_EXPORT pass
{
//
std::string name() const;
......@@ -116,7 +116,7 @@ struct pass
{
using std::swap;
auto* derived = this->any_cast<PrivateDetailTypeErasedT>();
if(derived and private_detail_te_handle_mem_var.unique())
if(derived and private_detail_te_handle_mem_var.use_count() == 1)
{
*derived = std::forward<PrivateDetailTypeErasedT>(value);
}
......@@ -292,7 +292,7 @@ struct pass
private_detail_te_handle_base_type& private_detail_te_get_handle()
{
assert(private_detail_te_handle_mem_var != nullptr);
if(not private_detail_te_handle_mem_var.unique())
if(private_detail_te_handle_mem_var.use_count() > 1)
private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone();
return *private_detail_te_handle_mem_var;
}
......
......@@ -26,6 +26,7 @@
#include <migraphx/config.hpp>
#include <migraphx/pass.hpp>
#include <migraphx/module_ref.hpp>
#include <migraphx/tracer.hpp>
#include <vector>
......@@ -46,8 +47,14 @@ struct module_pass_manager
virtual ~module_pass_manager() {}
};
void run_passes(module& mod, const std::vector<pass>& passes, tracer trace = tracer{});
void run_passes(program& prog, const std::vector<pass>& passes, tracer trace = tracer{});
MIGRAPHX_EXPORT void run_passes(program& prog,
module_ref root_mod,
const std::vector<pass>& passes,
tracer trace = tracer{});
MIGRAPHX_EXPORT void
run_passes(module& mod, const std::vector<pass>& passes, tracer trace = tracer{});
MIGRAPHX_EXPORT void
run_passes(program& prog, const std::vector<pass>& passes, tracer trace = tracer{});
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -43,7 +43,7 @@ inline Vector reorder_dims(const Vector& dims, const std::vector<int64_t>& permu
return result;
}
shape reorder_shape(const shape& s, const std::vector<int64_t>& permutation);
MIGRAPHX_EXPORT shape reorder_shape(const shape& s, const std::vector<int64_t>& permutation);
template <class Vector, class Op>
inline std::vector<int64_t> sort_permutation(const Vector& data, Op op)
......@@ -56,15 +56,19 @@ inline std::vector<int64_t> sort_permutation(const Vector& data, Op op)
}
/*!
* Returns the permutation needed to apply to the shape to undo the current permutation
* Returns the inverse permutation that could be applied to undo the inputted permutation
*/
std::vector<int64_t> invert_permutation(const std::vector<int64_t>& permutation);
MIGRAPHX_EXPORT std::vector<int64_t> invert_permutation(const std::vector<int64_t>& permutation);
/*!
* Finds the permutation most likely from a transpose operator that has been applied to the shape.
* Finds the permutation that would make the shape not transposed (refering to shape.transposed())
*/
std::vector<int64_t> find_permutation(const shape& s);
std::vector<int64_t> find_permutation(const std::vector<shape>& shapes);
MIGRAPHX_EXPORT std::vector<int64_t> find_permutation(const shape& s);
MIGRAPHX_EXPORT std::vector<int64_t> find_permutation(const std::vector<shape>& shapes);
/// Normalize the shapes so the order of dimensions will be in the order it is
/// in memory as much as possible.
MIGRAPHX_EXPORT std::vector<shape> normalize_permutation(const std::vector<shape>& shapes);
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct module;
struct preallocate_param
struct MIGRAPHX_EXPORT preallocate_param
{
std::string param;
allocation_model model;
......
......@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct process_impl;
struct process
struct MIGRAPHX_EXPORT process
{
using writer = std::function<void(const char*, std::size_t)>;
process(const std::string& cmd);
......
......@@ -54,7 +54,7 @@ struct marker;
/**
* @brief Stores the instruction stream
*/
struct program
struct MIGRAPHX_EXPORT program
{
program();
......@@ -79,6 +79,9 @@ struct program
std::vector<argument> eval(parameter_map params,
execution_environment exec_env = execution_environment{}) const;
void finish() const;
std::size_t size() const;
std::vector<shape> get_output_shapes() const;
......@@ -92,6 +95,9 @@ struct program
void compile(const target& t, compile_options options = compile_options{});
void compile(const std::vector<target>& targets,
std::vector<compile_options> compile_opts = {});
bool is_compiled() const;
void finalize();
......@@ -124,8 +130,8 @@ struct program
program& sort();
friend std::ostream& operator<<(std::ostream& os, const program& p);
friend bool operator==(const program& x, const program& y);
MIGRAPHX_EXPORT friend std::ostream& operator<<(std::ostream& os, const program& p);
MIGRAPHX_EXPORT friend bool operator==(const program& x, const program& y);
friend bool operator!=(const program& x, const program& y) { return not(x == y); }
// module related api
......
......@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
* Replace literals in submodules with literals in the root module.
* Intended to allow for reuse of the literals between submodules.
*/
struct promote_literals
struct MIGRAPHX_EXPORT promote_literals
{
std::string name() const { return "promote_literals"; }
void apply(module_pass_manager&) const;
......
......@@ -35,7 +35,7 @@ struct module;
/**
* Replace instructions which take all literals with a literal of the computation.
*/
struct propagate_constant
struct MIGRAPHX_EXPORT propagate_constant
{
std::string name() const { return "propagate_constant"; }
void apply(module& m) const;
......
......@@ -38,12 +38,14 @@ inline namespace MIGRAPHX_INLINE_NS {
struct program;
void quantize_fp16(program& prog, const std::vector<std::string>& ins_names = {"all"});
MIGRAPHX_EXPORT void quantize_fp16(program& prog,
const std::vector<std::string>& ins_names = {"all"});
void quantize_int8(program& prog,
const target& t,
const std::vector<parameter_map>& calibration,
const std::vector<std::string>& ins_names = {"dot", "convolution"});
MIGRAPHX_EXPORT void quantize_int8(program& prog,
const target& t,
const std::vector<parameter_map>& calibration,
const std::vector<std::string>& ins_names = {"dot",
"convolution"});
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -37,7 +37,7 @@ struct module;
/**
* quantize a program to fp16
*/
struct quantize_fp16_pass
struct MIGRAPHX_EXPORT quantize_fp16_pass
{
std::vector<std::string> ins_names = {"all"};
std::string name() const { return "quantize_fp16"; }
......
......@@ -39,7 +39,7 @@ struct module;
/**
* capture inputs of operators to be quantized to int8
*/
struct capture_arguments_pass
struct MIGRAPHX_EXPORT capture_arguments_pass
{
std::vector<std::string> ins_names = {"dot", "convolution"};
std::function<void(std::size_t, std::vector<argument>)> f{};
......@@ -51,7 +51,7 @@ struct capture_arguments_pass
/**
* quantize a program to int8
*/
struct quantize_int8_pass
struct MIGRAPHX_EXPORT quantize_int8_pass
{
std::vector<std::string> ins_names = {"dot", "convolution"};
std::vector<std::pair<float, float>> quant_params;
......
......@@ -187,6 +187,7 @@ struct raw_data : raw_data_base
std::string to_string() const
{
std::stringstream ss;
ss.precision(std::numeric_limits<double>::max_digits10);
ss << static_cast<const Derived&>(*this);
return ss.str();
}
......
......@@ -31,7 +31,7 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
std::vector<shape> reduce_dims(const std::vector<shape>& shapes);
MIGRAPHX_EXPORT std::vector<shape> reduce_dims(const std::vector<shape>& shapes);
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -78,7 +78,7 @@ template <class T>
struct wrapper
{
using type = typename remove_rvalue_reference<T>::type;
type data;
type data; // NOLINT
type get() const { return data; }
};
......
......@@ -34,7 +34,7 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
// unregister all ops for specified target, useful when unloading dynamically plugged-in target lib
void unregister_op(const std::string& op_name);
MIGRAPHX_EXPORT void unregister_op(const std::string& op_name);
namespace detail {
struct op_handler
......@@ -47,15 +47,15 @@ struct op_handler
} // namespace detail
void register_op_init();
MIGRAPHX_EXPORT void register_op_init();
void register_op(const operation& op);
MIGRAPHX_EXPORT void register_op(const operation& op);
operation load_op(const std::string& name);
MIGRAPHX_EXPORT operation load_op(const std::string& name);
bool has_op(const std::string& name);
MIGRAPHX_EXPORT bool has_op(const std::string& name);
std::vector<std::string> get_operators();
MIGRAPHX_EXPORT std::vector<std::string> get_operators();
template <class T>
void register_op()
......
......@@ -33,11 +33,11 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
void register_target_init();
void register_target(const target& t);
void unregister_target(const std::string& name);
target make_target(const std::string& name);
std::vector<std::string> get_targets();
MIGRAPHX_EXPORT void register_target_init();
MIGRAPHX_EXPORT void register_target(const target& t);
MIGRAPHX_EXPORT void unregister_target(const std::string& name);
MIGRAPHX_EXPORT target make_target(const std::string& name);
MIGRAPHX_EXPORT std::vector<std::string> get_targets();
namespace detail {
struct target_handler
......
......@@ -30,17 +30,17 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
struct module;
struct module_pass_manager;
/**
* Replace `allocate` instructions with target allocations or output parameters.
*/
struct replace_allocate
struct MIGRAPHX_EXPORT replace_allocate
{
allocation_model model;
bool offload_copy = false;
std::string name() const { return "replace_allocate"; }
void apply(module& m) const;
void apply(module_pass_manager& mpm) const;
};
} // namespace MIGRAPHX_INLINE_NS
......
......@@ -36,7 +36,7 @@ struct module;
/**
* Rewrite gelu standard formula as the sigmoid approximation formula
*/
struct rewrite_gelu
struct MIGRAPHX_EXPORT rewrite_gelu
{
std::string name() const { return "rewrite_gelu"; }
void apply(module& m) const;
......
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