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;
* Remove multiple memory allocations using graph coloring to find memory allocations that can be
* reused.
*/
struct memory_coloring
struct MIGRAPHX_EXPORT memory_coloring
{
std::string allocation_op{};
bool verify = false;
......
......@@ -52,7 +52,7 @@ using ins_dep_map = std::unordered_map<instruction_ref, std::unordered_set<ins
/**
* @brief Stores the instruction stream
*/
struct module
struct MIGRAPHX_EXPORT module
{
module(const std::string& name = "");
......@@ -225,8 +225,8 @@ struct module
module& sort();
ins_dep_map calc_implicit_deps() const;
friend std::ostream& operator<<(std::ostream& os, const module& m);
friend bool operator==(const module& x, const module& y);
MIGRAPHX_EXPORT friend std::ostream& operator<<(std::ostream& os, const module& m);
MIGRAPHX_EXPORT friend bool operator==(const module& x, const module& y);
friend bool operator!=(const module& x, const module& y) { return not(x == y); }
private:
......
......@@ -31,10 +31,11 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
void to_msgpack(const value& v, std::function<void(const char*, std::size_t)> writer);
std::vector<char> to_msgpack(const value& v);
value from_msgpack(const std::vector<char>& buffer);
value from_msgpack(const char* buffer, std::size_t size);
MIGRAPHX_EXPORT void to_msgpack(const value& v,
std::function<void(const char*, std::size_t)> writer);
MIGRAPHX_EXPORT std::vector<char> to_msgpack(const value& v);
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
......
......@@ -42,6 +42,7 @@ struct select_dependent_type
template <class T, class... Ts>
using dependent_type = typename select_dependent_type<T, Ts...>::type;
MIGRAPHX_EXPORT
bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens);
} // namespace MIGRAPHX_INLINE_NS
......
......@@ -39,7 +39,7 @@ struct module;
* Process negative axis attributes of ops
*/
struct normalize_ops
struct MIGRAPHX_EXPORT normalize_ops
{
std::string name() const { return "normalize_ops"; }
void apply(module& m) const;
......
......@@ -26,6 +26,7 @@
#include <migraphx/program.hpp>
#include <migraphx/config.hpp>
#include <migraphx/onnx/export.h>
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
......@@ -54,15 +55,19 @@ struct onnx_options
};
/// 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
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
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
......
......@@ -59,8 +59,8 @@ enum class rnn_direction
bidirectional,
};
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, pooling_mode v);
MIGRAPHX_EXPORT std::ostream& operator<<(std::ostream& os, rnn_direction v);
} // namespace op
} // namespace MIGRAPHX_INLINE_NS
......
......@@ -499,7 +499,7 @@ lifetime get_lifetime_op(const T&)
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct operation
struct MIGRAPHX_EXPORT operation
{
//
std::string name() const;
......@@ -1390,8 +1390,8 @@ bool has_finalize(const T& x)
return detail::has_finalize_op(x);
}
void migraphx_to_value(value& v, const operation& op);
void migraphx_from_value(const value& v, operation& op);
MIGRAPHX_EXPORT void migraphx_to_value(value& v, const operation& op);
MIGRAPHX_EXPORT void migraphx_from_value(const value& v, operation& op);
#endif
......
......@@ -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;
......
......@@ -47,12 +47,14 @@ struct module_pass_manager
virtual ~module_pass_manager() {}
};
void run_passes(program& prog,
module_ref root_mod,
const std::vector<pass>& passes,
tracer trace = tracer{});
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)
......@@ -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
*/
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())
*/
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);
} // 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();
......@@ -130,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"; }
......
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