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
...@@ -37,7 +37,7 @@ struct module; ...@@ -37,7 +37,7 @@ struct module;
/** /**
* Remove concat operators by having each operator can write to different chunk of memory. * Remove concat operators by having each operator can write to different chunk of memory.
*/ */
struct eliminate_concat struct MIGRAPHX_EXPORT eliminate_concat
{ {
concat_optimization concat_opt; concat_optimization concat_opt;
std::string name() const { return "eliminate_concat"; } std::string name() const { return "eliminate_concat"; }
......
...@@ -36,7 +36,7 @@ struct module; ...@@ -36,7 +36,7 @@ struct module;
/** /**
* Remove contiguous instructions by checking if the operator can use non-standard shapes. * Remove contiguous instructions by checking if the operator can use non-standard shapes.
*/ */
struct eliminate_contiguous struct MIGRAPHX_EXPORT eliminate_contiguous
{ {
std::string op_name; std::string op_name;
std::string name() const { return "eliminate_contiguous"; } std::string name() const { return "eliminate_contiguous"; }
......
...@@ -38,7 +38,7 @@ struct module; ...@@ -38,7 +38,7 @@ struct module;
* Remove data types. This will instert convert operators so the data type * Remove data types. This will instert convert operators so the data type
* is not used by any operator. * is not used by any operator.
*/ */
struct eliminate_data_type struct MIGRAPHX_EXPORT eliminate_data_type
{ {
std::set<shape::type_t> types; std::set<shape::type_t> types;
shape::type_t target_type; shape::type_t target_type;
......
...@@ -38,7 +38,7 @@ struct module; ...@@ -38,7 +38,7 @@ struct module;
* preserve the semantics of previous program state, therefore dead code elimination * preserve the semantics of previous program state, therefore dead code elimination
* should not be used afterwards. * should not be used afterwards.
*/ */
struct eliminate_identity struct MIGRAPHX_EXPORT eliminate_identity
{ {
std::string name() const { return "eliminate_identity"; } std::string name() const { return "eliminate_identity"; }
void apply(module& m) const; void apply(module& m) const;
......
...@@ -39,7 +39,7 @@ struct module; ...@@ -39,7 +39,7 @@ struct module;
* Remove pads if they can be written as an * Remove pads if they can be written as an
* attribute to another op (im2col, convolution, pooling) * attribute to another op (im2col, convolution, pooling)
*/ */
struct eliminate_pad struct MIGRAPHX_EXPORT eliminate_pad
{ {
std::string name() const { return "eliminate_pad"; } std::string name() const { return "eliminate_pad"; }
......
...@@ -38,13 +38,13 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -38,13 +38,13 @@ inline namespace MIGRAPHX_INLINE_NS {
static const char* value() { return #x; } \ static const char* value() { return #x; } \
}; // NOLINT }; // NOLINT
bool enabled(const char* name); MIGRAPHX_EXPORT bool enabled(const char* name);
bool disabled(const char* name); MIGRAPHX_EXPORT bool disabled(const char* name);
std::vector<std::string> env(const char* name); MIGRAPHX_EXPORT std::vector<std::string> env(const char* name);
std::size_t value_of(const char* name, std::size_t fallback = 0); MIGRAPHX_EXPORT std::size_t value_of(const char* name, std::size_t fallback = 0);
std::string string_value_of(const char* name, std::string fallback = ""); MIGRAPHX_EXPORT std::string string_value_of(const char* name, std::string fallback = "");
template <class T> template <class T>
bool enabled(T) bool enabled(T)
......
...@@ -31,11 +31,13 @@ ...@@ -31,11 +31,13 @@
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
std::vector<char> read_buffer(const std::string& filename, size_t offset = 0, size_t nbytes = 0); MIGRAPHX_EXPORT std::vector<char>
std::string read_string(const std::string& filename); read_buffer(const std::string& filename, size_t offset = 0, size_t nbytes = 0);
MIGRAPHX_EXPORT std::string read_string(const std::string& filename);
void write_buffer(const std::string& filename, const char* buffer, std::size_t size); MIGRAPHX_EXPORT void
void write_buffer(const std::string& filename, const std::vector<char>& buffer); write_buffer(const std::string& filename, const char* buffer, std::size_t size);
MIGRAPHX_EXPORT void write_buffer(const std::string& filename, const std::vector<char>& buffer);
} // 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_pass_manager; struct module_pass_manager;
struct fuse_pointwise struct MIGRAPHX_EXPORT fuse_pointwise
{ {
std::string name() const { return "fuse_pointwise"; } std::string name() const { return "fuse_pointwise"; }
void apply(module_pass_manager& mpm) const; void apply(module_pass_manager& mpm) const;
......
...@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct module_pass_manager; struct module_pass_manager;
struct fuse_reduce struct MIGRAPHX_EXPORT fuse_reduce
{ {
std::string name() const { return "fuse_reduce"; } std::string name() const { return "fuse_reduce"; }
void apply(module_pass_manager& mpm) const; void apply(module_pass_manager& mpm) const;
......
...@@ -124,13 +124,13 @@ auto fill_tensor_data(const migraphx::shape& s, unsigned long value = 0) ...@@ -124,13 +124,13 @@ auto fill_tensor_data(const migraphx::shape& s, unsigned long value = 0)
return result; return result;
} }
argument fill_argument(shape s, unsigned long value = 0); MIGRAPHX_EXPORT argument fill_argument(shape s, unsigned long value = 0);
argument generate_argument(shape s, unsigned long seed = 0); MIGRAPHX_EXPORT argument generate_argument(shape s, unsigned long seed = 0);
literal generate_literal(shape s, unsigned long seed = 0); MIGRAPHX_EXPORT literal generate_literal(shape s, unsigned long seed = 0);
literal abs(literal l); MIGRAPHX_EXPORT literal abs(literal l);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -33,7 +33,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -33,7 +33,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct module; struct module;
struct inline_module struct MIGRAPHX_EXPORT inline_module
{ {
std::string name() const { return "inline_module"; } std::string name() const { return "inline_module"; }
void apply(module& m) const; void apply(module& m) const;
......
...@@ -38,7 +38,7 @@ struct module; ...@@ -38,7 +38,7 @@ struct module;
/** /**
* insert pads if attribute of padding is asymmetrical * insert pads if attribute of padding is asymmetrical
*/ */
struct insert_pad struct MIGRAPHX_EXPORT insert_pad
{ {
std::string name() const { return "insert_pad"; } std::string name() const { return "insert_pad"; }
......
...@@ -37,14 +37,15 @@ ...@@ -37,14 +37,15 @@
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
shape compute_shape(const operation& op, const std::vector<instruction_ref>& args); MIGRAPHX_EXPORT shape compute_shape(const operation& op, const std::vector<instruction_ref>& args);
shape compute_shape(const operation& op, MIGRAPHX_EXPORT shape compute_shape(const operation& op,
const std::vector<instruction_ref>& args, const std::vector<instruction_ref>& args,
const std::vector<module_ref>& mods); const std::vector<module_ref>& mods);
std::vector<shape> to_shapes(const std::vector<instruction_ref>& args); MIGRAPHX_EXPORT std::vector<shape> to_shapes(const std::vector<instruction_ref>& args);
std::vector<shape> try_compute_shape(const operation& op, const std::vector<shape>& inputs); MIGRAPHX_EXPORT std::vector<shape> try_compute_shape(const operation& op,
const std::vector<shape>& inputs);
struct instruction
struct MIGRAPHX_EXPORT instruction
{ {
instruction() {} instruction() {}
......
...@@ -34,7 +34,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -34,7 +34,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct instruction; struct instruction;
using instruction_ref = std::list<instruction>::iterator; using instruction_ref = std::list<instruction>::iterator;
migraphx::instruction* as_address(const instruction_ref& ins) noexcept; MIGRAPHX_EXPORT migraphx::instruction* as_address(const instruction_ref& ins) noexcept;
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
std::string to_pretty_json_string(const value& val, std::size_t indent = 4); MIGRAPHX_EXPORT std::string to_pretty_json_string(const value& val, std::size_t indent = 4);
std::string to_json_string(const value& val); MIGRAPHX_EXPORT std::string to_json_string(const value& val);
value from_json_string(const std::string& str); MIGRAPHX_EXPORT value from_json_string(const std::string& str);
value from_json_string(const char* str, std::size_t size); MIGRAPHX_EXPORT value from_json_string(const char* str, std::size_t size);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -36,7 +36,7 @@ struct module_pass_manager; ...@@ -36,7 +36,7 @@ struct module_pass_manager;
/** /**
* Transform convolutions to nhwc * Transform convolutions to nhwc
*/ */
struct layout_nhwc struct MIGRAPHX_EXPORT layout_nhwc
{ {
std::string name() const { return "layout_nhwc"; } std::string name() const { return "layout_nhwc"; }
void apply(module_pass_manager& mpm) const; void apply(module_pass_manager& mpm) const;
......
...@@ -147,8 +147,8 @@ literal transform(literal l1, literal l2, F f) ...@@ -147,8 +147,8 @@ literal transform(literal l1, literal l2, F f)
return result; return result;
} }
void migraphx_to_value(value& v, const literal& l); MIGRAPHX_EXPORT void migraphx_to_value(value& v, const literal& l);
void migraphx_from_value(const value& v, literal& l); MIGRAPHX_EXPORT void migraphx_from_value(const value& v, literal& l);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -36,15 +36,18 @@ struct file_options ...@@ -36,15 +36,18 @@ struct file_options
std::string format = "msgpack"; std::string format = "msgpack";
}; };
program load(const std::string& filename, const file_options& options = file_options{}); MIGRAPHX_EXPORT program load(const std::string& filename,
program load_buffer(const std::vector<char>& buffer, const file_options& options = file_options{}); const file_options& options = file_options{});
program MIGRAPHX_EXPORT program load_buffer(const std::vector<char>& buffer,
load_buffer(const char* buffer, std::size_t size, const file_options& options = file_options{}); const file_options& options = file_options{});
MIGRAPHX_EXPORT program load_buffer(const char* buffer,
std::size_t size,
const file_options& options = file_options{});
void save(const program& p, MIGRAPHX_EXPORT void
const std::string& filename, save(const program& p, const std::string& filename, const file_options& options = file_options{});
const file_options& options = file_options{}); MIGRAPHX_EXPORT std::vector<char> save_buffer(const program& p,
std::vector<char> save_buffer(const program& p, const file_options& options = file_options{}); const file_options& options = file_options{});
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
operation make_op(const std::string& name); MIGRAPHX_EXPORT operation make_op(const std::string& name);
operation make_op(const std::string& name, MIGRAPHX_EXPORT operation make_op(const std::string& name,
const std::initializer_list<std::pair<std::string, value>>& v); const std::initializer_list<std::pair<std::string, value>>& v);
operation make_op_from_value(const std::string& name, const value& v); MIGRAPHX_EXPORT operation make_op_from_value(const std::string& name, const value& v);
// A template overload is added for migraphx::value so the initializer_list // A template overload is added for migraphx::value so the initializer_list
// cannot be passed in directly. This is to enforce at compile-time that all // cannot be passed in directly. This is to enforce at compile-time that all
...@@ -48,7 +48,7 @@ operation make_op(const std::string& name, const Value& v) ...@@ -48,7 +48,7 @@ operation make_op(const std::string& name, const Value& v)
return make_op_from_value(name, v); return make_op_from_value(name, v);
} }
operation make_json_op(const std::string& name, const std::string& s); MIGRAPHX_EXPORT operation make_json_op(const std::string& name, const std::string& s);
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
......
...@@ -46,7 +46,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -46,7 +46,7 @@ inline namespace MIGRAPHX_INLINE_NS {
#ifdef TYPE_ERASED_DECLARATION #ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for: // Type-erased interface for:
struct marker struct MIGRAPHX_EXPORT marker
{ {
// //
void mark_start(instruction_ref ins_ref); void mark_start(instruction_ref ins_ref);
......
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