Commit 264a7647 authored by Brian Pickrell's avatar Brian Pickrell
Browse files

Merge branch 'develop' into multinomial_parse_merge

parents d99729f8 8e18544f
......@@ -31,11 +31,13 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
std::vector<char> read_buffer(const std::string& filename, size_t offset = 0, size_t nbytes = 0);
std::string read_string(const std::string& filename);
MIGRAPHX_EXPORT std::vector<char>
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);
void write_buffer(const std::string& filename, const std::vector<char>& buffer);
MIGRAPHX_EXPORT void
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
......
......@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct module_pass_manager;
struct fuse_pointwise
struct MIGRAPHX_EXPORT fuse_pointwise
{
std::string name() const { return "fuse_pointwise"; }
void apply(module_pass_manager& mpm) const;
......
......@@ -32,7 +32,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct module_pass_manager;
struct fuse_reduce
struct MIGRAPHX_EXPORT fuse_reduce
{
std::string name() const { return "fuse_reduce"; }
void apply(module_pass_manager& mpm) const;
......
......@@ -117,20 +117,20 @@ auto generate_tensor_data(const migraphx::shape& s, unsigned long seed = 0)
}
template <class T>
auto fill_tensor_data(const migraphx::shape& s, unsigned long value = 0)
auto fill_tensor_data(const migraphx::shape& s, double value = 0)
{
auto result = make_shared_array<T>(s.element_space());
std::generate(result.get(), result.get() + s.element_space(), [=] { return value; });
return result;
}
argument fill_argument(shape s, unsigned long value = 0);
MIGRAPHX_EXPORT argument fill_argument(shape s, double 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
......
......@@ -33,7 +33,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct module;
struct inline_module
struct MIGRAPHX_EXPORT inline_module
{
std::string name() const { return "inline_module"; }
void apply(module& m) const;
......
......@@ -38,7 +38,7 @@ struct module;
/**
* insert pads if attribute of padding is asymmetrical
*/
struct insert_pad
struct MIGRAPHX_EXPORT insert_pad
{
std::string name() const { return "insert_pad"; }
......
......@@ -37,14 +37,15 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
shape compute_shape(const operation& op, const std::vector<instruction_ref>& args);
shape compute_shape(const operation& op,
const std::vector<instruction_ref>& args,
const std::vector<module_ref>& mods);
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);
struct instruction
MIGRAPHX_EXPORT 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,
const std::vector<module_ref>& mods);
MIGRAPHX_EXPORT std::vector<shape> to_shapes(const std::vector<instruction_ref>& args);
MIGRAPHX_EXPORT std::vector<shape> try_compute_shape(const operation& op,
const std::vector<shape>& inputs);
struct MIGRAPHX_EXPORT instruction
{
instruction() {}
......@@ -137,6 +138,7 @@ struct instruction
operation normalized_operator() const;
std::size_t get_target_id() const;
void set_target_id(std::size_t tid);
void debug_print() const;
......
......@@ -34,7 +34,7 @@ inline namespace MIGRAPHX_INLINE_NS {
struct instruction;
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
......
......@@ -31,10 +31,10 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
std::string to_pretty_json_string(const value& val, std::size_t indent = 4);
std::string to_json_string(const value& val);
value from_json_string(const std::string& str);
value from_json_string(const char* str, std::size_t size);
MIGRAPHX_EXPORT std::string to_pretty_json_string(const value& val, std::size_t indent = 4);
MIGRAPHX_EXPORT std::string to_json_string(const value& val);
MIGRAPHX_EXPORT value from_json_string(const std::string& str);
MIGRAPHX_EXPORT value from_json_string(const char* str, std::size_t size);
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -36,7 +36,7 @@ struct module_pass_manager;
/**
* Transform convolutions to nhwc
*/
struct layout_nhwc
struct MIGRAPHX_EXPORT layout_nhwc
{
std::string name() const { return "layout_nhwc"; }
void apply(module_pass_manager& mpm) const;
......
......@@ -147,8 +147,8 @@ literal transform(literal l1, literal l2, F f)
return result;
}
void migraphx_to_value(value& v, const literal& l);
void migraphx_from_value(const value& v, literal& l);
MIGRAPHX_EXPORT void migraphx_to_value(value& v, const literal& l);
MIGRAPHX_EXPORT void migraphx_from_value(const value& v, literal& l);
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -36,15 +36,18 @@ struct file_options
std::string format = "msgpack";
};
program load(const std::string& filename, const file_options& options = file_options{});
program load_buffer(const std::vector<char>& buffer, const file_options& options = file_options{});
program
load_buffer(const char* buffer, std::size_t size, const file_options& options = file_options{});
MIGRAPHX_EXPORT program load(const std::string& filename,
const file_options& options = file_options{});
MIGRAPHX_EXPORT program load_buffer(const std::vector<char>& buffer,
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,
const std::string& filename,
const file_options& options = file_options{});
std::vector<char> save_buffer(const program& p, const file_options& options = file_options{});
MIGRAPHX_EXPORT void
save(const program& p, const std::string& filename, const file_options& options = file_options{});
MIGRAPHX_EXPORT std::vector<char> save_buffer(const program& p,
const file_options& options = file_options{});
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -33,10 +33,10 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
operation make_op(const std::string& name);
operation make_op(const std::string& name,
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(const std::string& name);
MIGRAPHX_EXPORT operation make_op(const std::string& name,
const std::initializer_list<std::pair<std::string, 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
// 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)
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
......
......@@ -46,7 +46,7 @@ inline namespace MIGRAPHX_INLINE_NS {
#ifdef TYPE_ERASED_DECLARATION
// Type-erased interface for:
struct marker
struct MIGRAPHX_EXPORT marker
{
//
void mark_start(instruction_ref ins_ref);
......@@ -80,7 +80,7 @@ struct marker
{
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);
}
......@@ -233,7 +233,7 @@ struct marker
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;
}
......
......@@ -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 = "");
......@@ -189,7 +189,7 @@ struct module
instruction_ref validate() const;
instruction_ref find_dangling_reference() const;
void finalize(context& ctx);
void finalize(std::vector<context>& contexts);
void debug_print() const;
void debug_print(instruction_ref ins) const;
......@@ -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,7 +42,8 @@ struct select_dependent_type
template <class T, class... Ts>
using dependent_type = typename select_dependent_type<T, Ts...>::type;
bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens);
MIGRAPHX_EXPORT
bool normalize_attributes(operation& op, const shape& input_shape);
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -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
......
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