Unverified Commit c04fbc92 authored by Artur Wojcik's avatar Artur Wojcik Committed by GitHub
Browse files

export API symbols from dynamic libraries (#1892)

Export API symbols for migraphx, migraphx_ref, migraphx_cpu, migrphx_gpu, migraphx_device, migraphx_tf, and migraphx_onnx. There is a separate PR for migrahx_c.

API symbol exporting affects only Windows. It is transparent on Linux.
parent c88d4a54
...@@ -36,7 +36,7 @@ struct module; ...@@ -36,7 +36,7 @@ struct module;
* Remove multiple memory allocations using graph coloring to find memory allocations that can be * Remove multiple memory allocations using graph coloring to find memory allocations that can be
* reused. * reused.
*/ */
struct memory_coloring struct MIGRAPHX_EXPORT memory_coloring
{ {
std::string allocation_op{}; std::string allocation_op{};
bool verify = false; bool verify = false;
......
...@@ -52,7 +52,7 @@ using ins_dep_map = std::unordered_map<instruction_ref, std::unordered_set<ins ...@@ -52,7 +52,7 @@ using ins_dep_map = std::unordered_map<instruction_ref, std::unordered_set<ins
/** /**
* @brief Stores the instruction stream * @brief Stores the instruction stream
*/ */
struct module struct MIGRAPHX_EXPORT module
{ {
module(const std::string& name = ""); module(const std::string& name = "");
...@@ -225,8 +225,8 @@ struct module ...@@ -225,8 +225,8 @@ struct module
module& sort(); module& sort();
ins_dep_map calc_implicit_deps() const; ins_dep_map calc_implicit_deps() const;
friend std::ostream& operator<<(std::ostream& os, const module& m); MIGRAPHX_EXPORT friend std::ostream& operator<<(std::ostream& os, const module& m);
friend bool operator==(const module& x, const module& y); MIGRAPHX_EXPORT friend bool operator==(const module& x, const module& y);
friend bool operator!=(const module& x, const module& y) { return not(x == y); } friend bool operator!=(const module& x, const module& y) { return not(x == y); }
private: private:
......
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
void to_msgpack(const value& v, std::function<void(const char*, std::size_t)> writer); MIGRAPHX_EXPORT void to_msgpack(const value& v,
std::vector<char> to_msgpack(const value& v); std::function<void(const char*, std::size_t)> writer);
value from_msgpack(const std::vector<char>& buffer); MIGRAPHX_EXPORT std::vector<char> to_msgpack(const value& v);
value from_msgpack(const char* buffer, std::size_t size); MIGRAPHX_EXPORT value from_msgpack(const std::vector<char>& buffer);
MIGRAPHX_EXPORT value from_msgpack(const char* buffer, std::size_t size);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -42,6 +42,7 @@ struct select_dependent_type ...@@ -42,6 +42,7 @@ struct select_dependent_type
template <class T, class... Ts> template <class T, class... Ts>
using dependent_type = typename select_dependent_type<T, Ts...>::type; using dependent_type = typename select_dependent_type<T, Ts...>::type;
MIGRAPHX_EXPORT
bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens); bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
......
...@@ -39,7 +39,7 @@ struct module; ...@@ -39,7 +39,7 @@ struct module;
* Process negative axis attributes of ops * Process negative axis attributes of ops
*/ */
struct normalize_ops struct MIGRAPHX_EXPORT normalize_ops
{ {
std::string name() const { return "normalize_ops"; } std::string name() const { return "normalize_ops"; }
void apply(module& m) const; void apply(module& m) const;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/config.hpp> #include <migraphx/config.hpp>
#include <migraphx/onnx/export.h>
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
...@@ -54,15 +55,19 @@ struct onnx_options ...@@ -54,15 +55,19 @@ struct onnx_options
}; };
/// Create a program from an onnx file /// Create a program from an onnx file
program parse_onnx(const std::string& name, const onnx_options& = onnx_options{}); MIGRAPHX_ONNX_EXPORT program parse_onnx(const std::string& name,
const onnx_options& = onnx_options{});
/// Create a program from an onnx buffer /// Create a program from an onnx buffer
program parse_onnx_buffer(const std::string& buffer, const onnx_options& options); MIGRAPHX_ONNX_EXPORT program parse_onnx_buffer(const std::string& buffer,
const onnx_options& options);
/// Create a program from an onnx buffer /// Create a program from an onnx buffer
program parse_onnx_buffer(const void* data, std::size_t size, const onnx_options& options); MIGRAPHX_ONNX_EXPORT program parse_onnx_buffer(const void* data,
std::size_t size,
const onnx_options& options);
std::vector<std::string> get_onnx_operators(); MIGRAPHX_ONNX_EXPORT std::vector<std::string> get_onnx_operators();
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -59,8 +59,8 @@ enum class rnn_direction ...@@ -59,8 +59,8 @@ enum class rnn_direction
bidirectional, bidirectional,
}; };
std::ostream& operator<<(std::ostream& os, pooling_mode v); MIGRAPHX_EXPORT std::ostream& operator<<(std::ostream& os, pooling_mode v);
std::ostream& operator<<(std::ostream& os, rnn_direction v); MIGRAPHX_EXPORT std::ostream& operator<<(std::ostream& os, rnn_direction v);
} // namespace op } // namespace op
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
......
...@@ -499,7 +499,7 @@ lifetime get_lifetime_op(const T&) ...@@ -499,7 +499,7 @@ lifetime get_lifetime_op(const T&)
#ifdef TYPE_ERASED_DECLARATION #ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for: // Type-erased interface for:
struct operation struct MIGRAPHX_EXPORT operation
{ {
// //
std::string name() const; std::string name() const;
...@@ -1390,8 +1390,8 @@ bool has_finalize(const T& x) ...@@ -1390,8 +1390,8 @@ bool has_finalize(const T& x)
return detail::has_finalize_op(x); return detail::has_finalize_op(x);
} }
void migraphx_to_value(value& v, const operation& op); MIGRAPHX_EXPORT void migraphx_to_value(value& v, const operation& op);
void migraphx_from_value(const value& v, operation& op); MIGRAPHX_EXPORT void migraphx_from_value(const value& v, operation& op);
#endif #endif
......
...@@ -36,7 +36,7 @@ struct module_pass_manager; ...@@ -36,7 +36,7 @@ struct module_pass_manager;
/** /**
* Runs several passes in a loop * Runs several passes in a loop
*/ */
struct optimize_module struct MIGRAPHX_EXPORT optimize_module
{ {
std::string name() const { return "optimize_module"; } std::string name() const { return "optimize_module"; }
void apply(module_pass_manager& mpm) const; void apply(module_pass_manager& mpm) const;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
MIGRAPHX_EXPORT
void calculate_padding(int64_t idx, void calculate_padding(int64_t idx,
std::vector<int64_t>& pads, std::vector<int64_t>& pads,
int64_t input_dim, int64_t input_dim,
...@@ -45,6 +46,7 @@ void calculate_padding(int64_t idx, ...@@ -45,6 +46,7 @@ void calculate_padding(int64_t idx,
* where the padding calculation must be done at evaluation time. * where the padding calculation must be done at evaluation time.
* \return padding in the form of {x0_begin, x1_begin, ... x0_end , x1_end, ...} * \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, 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>& wei_lens,
const std::vector<std::size_t>& strides, 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 ...@@ -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 // Used for dynamic auto padding of convolution operators since padding needs to be computed at
// evaulation time. // evaulation time.
MIGRAPHX_EXPORT
shape compute_padded_shape(const shape& input, shape compute_padded_shape(const shape& input,
const shape& weights, const shape& weights,
const std::vector<std::size_t>& padding, const std::vector<std::size_t>& padding,
......
...@@ -57,7 +57,7 @@ struct pass ...@@ -57,7 +57,7 @@ struct pass
#else #else
module& get_module(module_pass_manager& mpm); MIGRAPHX_EXPORT module& get_module(module_pass_manager& mpm);
namespace detail { namespace detail {
...@@ -84,7 +84,7 @@ void module_pass_manager_apply(const T& x, module_pass_manager& mpm) ...@@ -84,7 +84,7 @@ void module_pass_manager_apply(const T& x, module_pass_manager& mpm)
#ifdef TYPE_ERASED_DECLARATION #ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for: // Type-erased interface for:
struct pass struct MIGRAPHX_EXPORT pass
{ {
// //
std::string name() const; std::string name() const;
......
...@@ -47,12 +47,14 @@ struct module_pass_manager ...@@ -47,12 +47,14 @@ struct module_pass_manager
virtual ~module_pass_manager() {} virtual ~module_pass_manager() {}
}; };
void run_passes(program& prog, MIGRAPHX_EXPORT void run_passes(program& prog,
module_ref root_mod, module_ref root_mod,
const std::vector<pass>& passes, const std::vector<pass>& passes,
tracer trace = tracer{}); tracer trace = tracer{});
void run_passes(module& mod, const std::vector<pass>& passes, tracer trace = tracer{}); MIGRAPHX_EXPORT void
void run_passes(program& prog, const std::vector<pass>& passes, tracer trace = tracer{}); 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_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -43,7 +43,7 @@ inline Vector reorder_dims(const Vector& dims, const std::vector<int64_t>& permu ...@@ -43,7 +43,7 @@ inline Vector reorder_dims(const Vector& dims, const std::vector<int64_t>& permu
return result; 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> template <class Vector, class Op>
inline std::vector<int64_t> sort_permutation(const Vector& data, Op op) inline std::vector<int64_t> sort_permutation(const Vector& data, Op op)
...@@ -58,13 +58,13 @@ inline std::vector<int64_t> sort_permutation(const Vector& data, Op op) ...@@ -58,13 +58,13 @@ inline std::vector<int64_t> sort_permutation(const Vector& data, Op op)
/*! /*!
* Returns the inverse permutation that could be applied to undo the inputted 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 that would make the shape not transposed (refering to shape.transposed()) * Finds the permutation that would make the shape not transposed (refering to shape.transposed())
*/ */
std::vector<int64_t> find_permutation(const shape& s); MIGRAPHX_EXPORT 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 std::vector<shape>& shapes);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct module; struct module;
struct preallocate_param struct MIGRAPHX_EXPORT preallocate_param
{ {
std::string param; std::string param;
allocation_model model; allocation_model model;
......
...@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct process_impl; struct process_impl;
struct process struct MIGRAPHX_EXPORT process
{ {
using writer = std::function<void(const char*, std::size_t)>; using writer = std::function<void(const char*, std::size_t)>;
process(const std::string& cmd); process(const std::string& cmd);
......
...@@ -54,7 +54,7 @@ struct marker; ...@@ -54,7 +54,7 @@ struct marker;
/** /**
* @brief Stores the instruction stream * @brief Stores the instruction stream
*/ */
struct program struct MIGRAPHX_EXPORT program
{ {
program(); program();
...@@ -130,8 +130,8 @@ struct program ...@@ -130,8 +130,8 @@ struct program
program& sort(); program& sort();
friend std::ostream& operator<<(std::ostream& os, const program& p); MIGRAPHX_EXPORT friend std::ostream& operator<<(std::ostream& os, const program& p);
friend bool operator==(const program& x, const program& y); MIGRAPHX_EXPORT friend bool operator==(const program& x, const program& y);
friend bool operator!=(const program& x, const program& y) { return not(x == y); } friend bool operator!=(const program& x, const program& y) { return not(x == y); }
// module related api // module related api
......
...@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS {
* Replace literals in submodules with literals in the root module. * Replace literals in submodules with literals in the root module.
* Intended to allow for reuse of the literals between submodules. * 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"; } std::string name() const { return "promote_literals"; }
void apply(module_pass_manager&) const; void apply(module_pass_manager&) const;
......
...@@ -35,7 +35,7 @@ struct module; ...@@ -35,7 +35,7 @@ struct module;
/** /**
* Replace instructions which take all literals with a literal of the computation. * 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"; } std::string name() const { return "propagate_constant"; }
void apply(module& m) const; void apply(module& m) const;
......
...@@ -38,12 +38,14 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -38,12 +38,14 @@ inline namespace MIGRAPHX_INLINE_NS {
struct program; 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, MIGRAPHX_EXPORT void quantize_int8(program& prog,
const target& t, const target& t,
const std::vector<parameter_map>& calibration, const std::vector<parameter_map>& calibration,
const std::vector<std::string>& ins_names = {"dot", "convolution"}); const std::vector<std::string>& ins_names = {"dot",
"convolution"});
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -37,7 +37,7 @@ struct module; ...@@ -37,7 +37,7 @@ struct module;
/** /**
* quantize a program to fp16 * quantize a program to fp16
*/ */
struct quantize_fp16_pass struct MIGRAPHX_EXPORT quantize_fp16_pass
{ {
std::vector<std::string> ins_names = {"all"}; std::vector<std::string> ins_names = {"all"};
std::string name() const { return "quantize_fp16"; } std::string name() const { return "quantize_fp16"; }
......
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