Commit eea003a5 authored by Paul's avatar Paul
Browse files

s/rtg/migraph

parent 5f1ea74f
#ifndef RTG_GUARD_RTGLIB_OPERAND_HPP
#define RTG_GUARD_RTGLIB_OPERAND_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_OPERAND_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_OPERAND_HPP
#include <string>
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>
#include <rtg/shape.hpp>
#include <rtg/argument.hpp>
#include <rtg/context.hpp>
#include <migraph/shape.hpp>
#include <migraph/argument.hpp>
#include <migraph/context.hpp>
namespace rtg {
namespace migraph {
namespace operation_stream {
......@@ -174,7 +174,7 @@ struct operation
std::ostream& operator_shift_left(std::ostream& os) const override
{
using rtg::operation_stream::operator<<;
using migraph::operation_stream::operator<<;
return os << private_detail_te_value;
}
......@@ -243,6 +243,6 @@ inline const ValueType& any_cast(const operation& x)
return *y;
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_OPERATORS_HPP
#define RTG_GUARD_OPERATORS_HPP
#ifndef MIGRAPH_GUARD_OPERATORS_HPP
#define MIGRAPH_GUARD_OPERATORS_HPP
#include <array>
#include <rtg/operation.hpp>
#include <rtg/stringutils.hpp>
#include <rtg/streamutils.hpp>
#include <migraph/operation.hpp>
#include <migraph/stringutils.hpp>
#include <migraph/streamutils.hpp>
#include <cmath>
namespace rtg {
namespace migraph {
struct check_shapes
{
......@@ -33,7 +33,7 @@ struct check_shapes
{
assert(shapes != nullptr);
if(shapes->size() != n)
RTG_THROW(prefix() + "Wrong number of arguments: expected " + std::to_string(n) +
MIGRAPH_THROW(prefix() + "Wrong number of arguments: expected " + std::to_string(n) +
" but given " + std::to_string(shapes->size()));
return *this;
}
......@@ -44,7 +44,7 @@ struct check_shapes
if(!shapes->empty())
{
if(shapes->front().lens().size() != n)
RTG_THROW(prefix() + "Only " + std::to_string(n) + "d supported");
MIGRAPH_THROW(prefix() + "Only " + std::to_string(n) + "d supported");
}
return *this;
}
......@@ -52,28 +52,28 @@ struct check_shapes
const check_shapes& same_shape() const
{
if(!this->same([](const shape& s) { return s; }))
RTG_THROW(prefix() + "Shapes do not match");
MIGRAPH_THROW(prefix() + "Shapes do not match");
return *this;
}
const check_shapes& same_type() const
{
if(!this->same([](const shape& s) { return s.type(); }))
RTG_THROW(prefix() + "Types do not match");
MIGRAPH_THROW(prefix() + "Types do not match");
return *this;
}
const check_shapes& same_dims() const
{
if(!this->same([](const shape& s) { return s.lens(); }))
RTG_THROW(prefix() + "Dimensions do not match");
MIGRAPH_THROW(prefix() + "Dimensions do not match");
return *this;
}
const check_shapes& same_ndims() const
{
if(!this->same([](const shape& s) { return s.lens().size(); }))
RTG_THROW(prefix() + "Dimensions do not match");
MIGRAPH_THROW(prefix() + "Dimensions do not match");
return *this;
}
......@@ -97,7 +97,7 @@ struct check_shapes
struct not_computable
{
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
};
struct convolution
......@@ -163,11 +163,11 @@ struct convolution
}
else
{
RTG_THROW("Invalid padding mode");
MIGRAPH_THROW("Invalid padding mode");
}
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
friend std::ostream& operator<<(std::ostream& os, const convolution& op)
{
......@@ -214,7 +214,7 @@ struct pooling
}};
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
friend std::ostream& operator<<(std::ostream& os, const pooling& op)
{
......@@ -237,7 +237,7 @@ struct activation
return inputs.front();
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
friend std::ostream& operator<<(std::ostream& os, const activation& op)
{
os << op.name() << ":" << op.mode;
......@@ -258,13 +258,13 @@ struct transpose
auto t = input.type();
if(dims.size() != input_lens.size())
{
RTG_THROW("Permutation has wrong number of axes");
MIGRAPH_THROW("Permutation has wrong number of axes");
}
std::vector<int64_t> axes(dims.size());
std::iota(axes.begin(), axes.end(), 0);
if(!std::is_permutation(axes.begin(), axes.end(), dims.begin()))
{
RTG_THROW("Invalid permutation");
MIGRAPH_THROW("Invalid permutation");
}
std::vector<size_t> output_lens(input_lens.size());
std::vector<size_t> output_strides(input_lens.size());
......@@ -275,7 +275,7 @@ struct transpose
}
return {t, output_lens, output_strides};
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
};
struct contiguous
......@@ -288,11 +288,11 @@ struct contiguous
auto t = inputs.at(0).type();
if(lens.size() < 2)
{
RTG_THROW("Number of dimensions should exceed 1");
MIGRAPH_THROW("Number of dimensions should exceed 1");
}
return {t, lens};
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
};
struct reshape
......@@ -316,11 +316,11 @@ struct reshape
}
shape s{inputs.front().type(), rdims};
if(s.elements() != inputs.front().elements())
RTG_THROW("Wrong number of elements for reshape");
MIGRAPH_THROW("Wrong number of elements for reshape");
return s;
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
friend std::ostream& operator<<(std::ostream& os, const reshape& op)
{
......@@ -342,11 +342,11 @@ struct gemm
auto t = a.type();
if(a.lens()[1] != b.lens()[0])
RTG_THROW("Inner dimensions do not match");
MIGRAPH_THROW("Inner dimensions do not match");
return {t, {a.lens()[0], b.lens()[1]}};
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
friend std::ostream& operator<<(std::ostream& os, const gemm& op)
{
......@@ -363,7 +363,7 @@ struct unary
check_shapes{inputs}.has(1);
return inputs.at(0);
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
};
struct identity : unary
......@@ -451,14 +451,14 @@ struct broadcast
result.lens().cbegin(), result.lens().cend(), [&](auto x) { return x == 1; }))
{
if(axis != 0)
RTG_THROW("when broadcasting tensor of size 1, axis should be 0");
MIGRAPH_THROW("when broadcasting tensor of size 1, axis should be 0");
return {t, result.lens(), std::move(bcast_strides)};
}
else
{
assert(result.lens().size() - axis >= input.lens().size());
if(!std::equal(input.lens().begin(), input.lens().end(), result.lens().begin() + axis))
RTG_THROW("when broadcasting success sizes must match");
MIGRAPH_THROW("when broadcasting success sizes must match");
std::copy(input.strides().begin(), input.strides().end(), bcast_strides.begin() + axis);
return {t, result.lens(), std::move(bcast_strides)};
}
......@@ -477,7 +477,7 @@ struct binary
check_shapes{inputs}.has(2).same_type().same_dims();
return inputs.at(0);
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
};
struct add : binary
......@@ -521,11 +521,11 @@ struct check_context
{
T* x = any_cast<T>(&ctx);
if(x == nullptr)
RTG_THROW(std::string("Unexpected context type: ") + ctx.type_id().name());
MIGRAPH_THROW(std::string("Unexpected context type: ") + ctx.type_id().name());
return {};
}
};
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RTGLIB_PROGRAM_HPP
#define RTG_GUARD_RTGLIB_PROGRAM_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_PROGRAM_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_PROGRAM_HPP
#include <list>
#include <unordered_map>
#include <rtg/operation.hpp>
#include <rtg/literal.hpp>
#include <rtg/builtin.hpp>
#include <rtg/instruction_ref.hpp>
#include <rtg/target.hpp>
#include <migraph/operation.hpp>
#include <migraph/literal.hpp>
#include <migraph/builtin.hpp>
#include <migraph/instruction_ref.hpp>
#include <migraph/target.hpp>
#include <algorithm>
#include <iostream>
namespace rtg {
namespace migraph {
struct program_impl;
......@@ -83,6 +83,6 @@ struct program
std::unique_ptr<program_impl> impl;
};
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RTGLIB_RANGES_HPP
#define RTG_GUARD_RTGLIB_RANGES_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_RANGES_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_RANGES_HPP
namespace rtg {
namespace migraph {
template <class C, class T>
bool contains(C&& c, T&& x)
......@@ -15,6 +15,6 @@ void copy(Range&& r, Iterator it)
std::copy(r.begin(), r.end(), it);
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RAW_DATA_HPP
#define RTG_GUARD_RAW_DATA_HPP
#ifndef MIGRAPH_GUARD_RAW_DATA_HPP
#define MIGRAPH_GUARD_RAW_DATA_HPP
#include <rtg/tensor_view.hpp>
#include <rtg/requires.hpp>
#include <migraph/tensor_view.hpp>
#include <migraph/requires.hpp>
namespace rtg {
namespace migraph {
struct raw_data_base
{
......@@ -102,7 +102,7 @@ struct raw_data : raw_data_base
bool matches() const
{
return is_data_ptr<T>{} ||
self->get_shape().type() == rtg::shape::get_type<get_data_type<T>>{};
self->get_shape().type() == migraph::shape::get_type<get_data_type<T>>{};
}
template <class T>
......@@ -123,15 +123,15 @@ struct raw_data : raw_data_base
{
auto&& s = static_cast<const Derived&>(*this).get_shape();
auto&& buffer = static_cast<const Derived&>(*this).data();
if(s.type() != rtg::shape::get_type<T>{})
RTG_THROW("Incorrect data type for raw data");
if(s.type() != migraph::shape::get_type<T>{})
MIGRAPH_THROW("Incorrect data type for raw data");
return make_view(s, reinterpret_cast<T*>(buffer));
}
};
template <class T,
class U,
RTG_REQUIRES(std::is_base_of<raw_data_base, T>{} && std::is_base_of<raw_data_base, U>{})>
MIGRAPH_REQUIRES(std::is_base_of<raw_data_base, T>{} && std::is_base_of<raw_data_base, U>{})>
bool operator==(const T& x, const U& y)
{
auto&& xshape = x.get_shape();
......@@ -153,7 +153,7 @@ bool operator==(const T& x, const U& y)
template <class T,
class U,
RTG_REQUIRES(std::is_base_of<raw_data_base, T>{} && std::is_base_of<raw_data_base, U>{})>
MIGRAPH_REQUIRES(std::is_base_of<raw_data_base, T>{} && std::is_base_of<raw_data_base, U>{})>
bool operator!=(const T& x, const U& y)
{
return !(x == y);
......@@ -184,13 +184,13 @@ auto visit_all(T&& x, Ts&&... xs)
auto&& s = x.get_shape();
std::initializer_list<shape::type_t> types = {xs.get_shape().type()...};
if(!std::all_of(types.begin(), types.end(), [&](shape::type_t t) { return t == s.type(); }))
RTG_THROW("Types must be the same");
MIGRAPH_THROW("Types must be the same");
return [&](auto v) {
// Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70100
detail::visit_all_impl(s, v, x, xs...);
};
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RTGLIB_REQUIRES_HPP
#define RTG_GUARD_RTGLIB_REQUIRES_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_REQUIRES_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_REQUIRES_HPP
#include <type_traits>
namespace rtg {
namespace migraph {
template <bool... Bs>
struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT
......@@ -14,13 +14,13 @@ template <bool B>
using bool_c = std::integral_constant<bool, B>;
#ifdef CPPCHECK
#define RTG_REQUIRES(...) class = void
#define MIGRAPH_REQUIRES(...) class = void
#else
#define RTG_REQUIRES(...) \
#define MIGRAPH_REQUIRES(...) \
bool PrivateRequires##__LINE__ = true, \
class = typename std::enable_if<and_<__VA_ARGS__, PrivateRequires##__LINE__>{}>::type
#endif
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RTGLIB_SHAPE_HPP
#define RTG_GUARD_RTGLIB_SHAPE_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_SHAPE_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_SHAPE_HPP
#include <vector>
#include <cassert>
#include <ostream>
#include <numeric>
#include <rtg/errors.hpp>
#include <migraph/errors.hpp>
namespace rtg {
namespace migraph {
struct shape
{
// Add new types here
// clang-format off
#define RTG_SHAPE_VISIT_TYPES(m) \
#define MIGRAPH_SHAPE_VISIT_TYPES(m) \
m(float_type, float) \
m(double_type, double) \
m(uint8_type, uint8_t) \
......@@ -28,22 +28,22 @@ struct shape
m(uint64_type, uint64_t)
// clang-format on
#define RTG_SHAPE_ENUM_TYPES(x, t) x,
#define MIGRAPH_SHAPE_ENUM_TYPES(x, t) x,
enum type_t
{
RTG_SHAPE_VISIT_TYPES(RTG_SHAPE_ENUM_TYPES)
MIGRAPH_SHAPE_VISIT_TYPES(MIGRAPH_SHAPE_ENUM_TYPES)
};
#undef RTG_SHAPE_ENUM_TYPES
#undef MIGRAPH_SHAPE_ENUM_TYPES
template <class T, class = void>
struct get_type;
#define RTG_SHAPE_GET_TYPE(x, t) \
#define MIGRAPH_SHAPE_GET_TYPE(x, t) \
template <class T> \
struct get_type<t, T> : std::integral_constant<type_t, x> \
{ \
};
RTG_SHAPE_VISIT_TYPES(RTG_SHAPE_GET_TYPE)
#undef RTG_SHAPE_GET_TYPE
MIGRAPH_SHAPE_VISIT_TYPES(MIGRAPH_SHAPE_GET_TYPE)
#undef MIGRAPH_SHAPE_GET_TYPE
shape();
shape(type_t t);
......@@ -122,12 +122,12 @@ struct shape
{
switch(this->m_type)
{
#define RTG_SHAPE_VISITOR_CASE(x, t) \
#define MIGRAPH_SHAPE_VISITOR_CASE(x, t) \
case x: v(as<t>()); return;
RTG_SHAPE_VISIT_TYPES(RTG_SHAPE_VISITOR_CASE)
#undef RTG_SHAPE_VISITOR_CASE
MIGRAPH_SHAPE_VISIT_TYPES(MIGRAPH_SHAPE_VISITOR_CASE)
#undef MIGRAPH_SHAPE_VISITOR_CASE
}
RTG_THROW("Unknown type");
MIGRAPH_THROW("Unknown type");
}
private:
......@@ -141,6 +141,6 @@ struct shape
std::string type_string() const;
};
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RTGLIB_SHAPE_FOR_EACH_HPP
#define RTG_GUARD_RTGLIB_SHAPE_FOR_EACH_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_SHAPE_FOR_EACH_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_SHAPE_FOR_EACH_HPP
#include <rtg/shape.hpp>
#include <migraph/shape.hpp>
#include <algorithm>
namespace rtg {
namespace migraph {
template <class F>
void shape_for_each(const rtg::shape& s, F f)
void shape_for_each(const migraph::shape& s, F f)
{
// Ensure calls to f use const ref to vector
auto call = [&f](const std::vector<std::size_t>& i) { f(i); };
......@@ -26,6 +26,6 @@ void shape_for_each(const rtg::shape& s, F f)
}
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_STREAMUTILS_HPP
#define RTG_GUARD_STREAMUTILS_HPP
#ifndef MIGRAPH_GUARD_STREAMUTILS_HPP
#define MIGRAPH_GUARD_STREAMUTILS_HPP
#include <ostream>
#include <algorithm>
namespace rtg {
namespace migraph {
template <class T>
struct stream_range_container
......@@ -31,6 +31,6 @@ inline stream_range_container<Range> stream_range(const Range& r)
return {r};
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RTGLIB_STRINGUTILS_HPP
#define RTG_GUARD_RTGLIB_STRINGUTILS_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_STRINGUTILS_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_STRINGUTILS_HPP
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
namespace rtg {
namespace migraph {
inline std::string
replace_string(std::string subject, const std::string& search, const std::string& replace)
......@@ -77,6 +77,6 @@ inline std::string to_string(const Range& r)
return ss.str();
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_RTGLIB_TARGET_HPP
#define RTG_GUARD_RTGLIB_TARGET_HPP
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_TARGET_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_TARGET_HPP
#include <string>
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>
#include <rtg/context.hpp>
#include <migraph/context.hpp>
namespace rtg {
namespace migraph {
struct program;
......@@ -210,6 +210,6 @@ inline const ValueType& any_cast(const target& x)
return *y;
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_TENSOR_VIEW_HPP
#define RTG_GUARD_TENSOR_VIEW_HPP
#ifndef MIGRAPH_GUARD_TENSOR_VIEW_HPP
#define MIGRAPH_GUARD_TENSOR_VIEW_HPP
#include <rtg/shape.hpp>
#include <rtg/float_equal.hpp>
#include <rtg/requires.hpp>
#include <migraph/shape.hpp>
#include <migraph/float_equal.hpp>
#include <migraph/requires.hpp>
#include <iostream>
namespace rtg {
namespace migraph {
template <class T>
struct tensor_view
......@@ -26,25 +26,25 @@ struct tensor_view
const T* data() const { return this->m_data; }
template <class... Ts, RTG_REQUIRES(std::is_integral<Ts>{}...)>
template <class... Ts, MIGRAPH_REQUIRES(std::is_integral<Ts>{}...)>
const T& operator()(Ts... xs) const
{
return m_data[m_shape.index({static_cast<std::size_t>(xs)...})];
}
template <class... Ts, RTG_REQUIRES(std::is_integral<Ts>{}...)>
template <class... Ts, MIGRAPH_REQUIRES(std::is_integral<Ts>{}...)>
T& operator()(Ts... xs)
{
return m_data[m_shape.index({static_cast<std::size_t>(xs)...})];
}
template <class Iterator, RTG_REQUIRES(not std::is_integral<Iterator>{})>
template <class Iterator, MIGRAPH_REQUIRES(not std::is_integral<Iterator>{})>
const T& operator()(Iterator start, Iterator last) const
{
return m_data[m_shape.index(start, last)];
}
template <class Iterator, RTG_REQUIRES(not std::is_integral<Iterator>{})>
template <class Iterator, MIGRAPH_REQUIRES(not std::is_integral<Iterator>{})>
T& operator()(Iterator start, Iterator last)
{
return m_data[m_shape.index(start, last)];
......@@ -162,6 +162,6 @@ tensor_view<T> make_view(shape s, T* data)
return {s, data};
}
} // namespace rtg
} // namespace migraph
#endif
#ifndef RTG_GUARD_FALLTHROUGH_HPP
#define RTG_GUARD_FALLTHROUGH_HPP
namespace rtg {
#ifdef __clang__
#define RTG_FALLTHROUGH [[clang::fallthrough]]
#else
#define RTG_FALLTHROUGH
#endif
} // namespace rtg
#endif
#ifndef GUARD_RTGLIB_ONNX_HPP
#define GUARD_RTGLIB_ONNX_HPP
#include <rtg/program.hpp>
namespace rtg {
program parse_onnx(const std::string& name);
} // namespace rtg
#endif
......@@ -7,17 +7,17 @@ target_compile_options(onnx-proto PRIVATE -w)
target_link_libraries(onnx-proto PRIVATE ${PROTOBUF_LIBRARY})
set_target_properties(onnx-proto PROPERTIES POSITION_INDEPENDENT_CODE On)
add_library(rtg_onnx onnx.cpp)
rocm_clang_tidy_check(rtg_onnx)
target_link_libraries(rtg_onnx PRIVATE onnx-proto)
target_link_libraries(rtg_onnx PUBLIC rtg)
add_library(migraph_onnx onnx.cpp)
rocm_clang_tidy_check(migraph_onnx)
target_link_libraries(migraph_onnx PRIVATE onnx-proto)
target_link_libraries(migraph_onnx PUBLIC migraph)
add_executable(read_onnx read_onnx.cpp)
rocm_clang_tidy_check(read_onnx)
target_link_libraries(read_onnx rtg_onnx)
target_link_libraries(read_onnx migraph_onnx)
if(RTG_ENABLE_MIOPEN)
if(MIGRAPH_ENABLE_MIOPEN)
add_executable(verify_onnx verify_onnx.cpp)
rocm_clang_tidy_check(verify_onnx)
target_link_libraries(verify_onnx rtg_onnx rtg_cpu rtg_miopen)
target_link_libraries(verify_onnx migraph_onnx migraph_cpu migraph_miopen)
endif()
......@@ -7,12 +7,12 @@
#include <functional>
#include <array>
#include <rtg/fallthrough.hpp>
#include <rtg/program.hpp>
#include <rtg/operators.hpp>
#include <rtg/ranges.hpp>
#include <migraph/fallthrough.hpp>
#include <migraph/program.hpp>
#include <migraph/operators.hpp>
#include <migraph/ranges.hpp>
namespace rtg {
namespace migraph {
struct unknown
{
......@@ -25,7 +25,7 @@ struct unknown
else
return input.front();
}
argument compute(context&, shape, std::vector<argument>) const { RTG_THROW("not computable"); }
argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("not computable"); }
friend std::ostream& operator<<(std::ostream& os, const unknown& x)
{
os << x.name();
......@@ -162,7 +162,7 @@ struct onnx_parser
void parse_node(std::string name)
{
if(name.empty())
RTG_THROW("Onnx node must have a name");
MIGRAPH_THROW("Onnx node must have a name");
if(instructions.count(name) == 0)
{
auto&& node = nodes.at(name);
......@@ -239,7 +239,7 @@ struct onnx_parser
case onnx::AttributeProto::TENSORS: return {};
case onnx::AttributeProto::GRAPHS: return {};
}
RTG_THROW("Invalid attribute type");
MIGRAPH_THROW("Invalid attribute type");
}
static literal parse_tensor(const onnx::TensorProto& t)
......@@ -273,7 +273,7 @@ struct onnx_parser
case onnx::TensorProto::COMPLEX64: throw std::runtime_error("");
case onnx::TensorProto::COMPLEX128: throw std::runtime_error("");
}
RTG_THROW("Invalid tensor type");
MIGRAPH_THROW("Invalid tensor type");
}
static shape parse_type(const onnx::TypeProto& t)
......@@ -336,4 +336,4 @@ program parse_onnx(const std::string& name)
return std::move(parser.prog);
}
} // namespace rtg
} // namespace migraph
#include <rtg/onnx.hpp>
#include <migraph/onnx.hpp>
int main(int argc, char const* argv[])
{
if(argc > 1)
{
std::string file = argv[1];
auto prog = rtg::parse_onnx(file);
auto prog = migraph::parse_onnx(file);
std::cout << prog << std::endl;
}
}
#include <rtg/onnx.hpp>
#include <migraph/onnx.hpp>
#include <rtg/cpu/cpu_target.hpp>
#include <rtg/miopen/miopen_target.hpp>
#include <rtg/miopen/hip.hpp>
#include <rtg/generate.hpp>
#include <migraph/cpu/cpu_target.hpp>
#include <migraph/miopen/miopen_target.hpp>
#include <migraph/miopen/hip.hpp>
#include <migraph/generate.hpp>
#include <miopen/miopen.h>
#include <rtg/miopen/miopen.hpp>
#include <migraph/miopen/miopen.hpp>
rtg::argument run_cpu(std::string file)
migraph::argument run_cpu(std::string file)
{
auto p = rtg::parse_onnx(file);
p.compile(rtg::cpu::cpu_target{});
auto p = migraph::parse_onnx(file);
p.compile(migraph::cpu::cpu_target{});
auto s = p.get_parameter_shape("Input3");
auto input3 = rtg::generate_argument(s);
auto input3 = migraph::generate_argument(s);
auto out = p.eval({{"Input3", input3}});
std::cout << p << std::endl;
return out;
}
rtg::argument run_gpu(std::string file)
migraph::argument run_gpu(std::string file)
{
auto p = rtg::parse_onnx(file);
p.compile(rtg::cpu::cpu_target{});
auto p = migraph::parse_onnx(file);
p.compile(migraph::cpu::cpu_target{});
auto s = p.get_parameter_shape("Input3");
auto input3 = rtg::miopen::to_gpu(rtg::generate_argument(s));
auto input3 = migraph::miopen::to_gpu(migraph::generate_argument(s));
auto output = rtg::miopen::to_gpu(rtg::generate_argument(p.get_parameter_shape("output")));
auto handle = rtg::miopen::make_obj<rtg::miopen::miopen_handle>(&miopenCreate);
auto output = migraph::miopen::to_gpu(migraph::generate_argument(p.get_parameter_shape("output")));
auto handle = migraph::miopen::make_obj<migraph::miopen::miopen_handle>(&miopenCreate);
auto out = p.eval({{"Input3", input3}, {"output", output}});
std::cout << p << std::endl;
return rtg::miopen::from_gpu(out);
return migraph::miopen::from_gpu(out);
}
int main(int argc, char const* argv[])
......
#include <rtg/program.hpp>
#include <rtg/stringutils.hpp>
#include <rtg/instruction.hpp>
#include <migraph/program.hpp>
#include <migraph/stringutils.hpp>
#include <migraph/instruction.hpp>
#include <iostream>
#include <algorithm>
namespace rtg {
namespace migraph {
struct program_impl
{
......@@ -113,7 +113,7 @@ void program::compile(const target& t)
this->impl->ctx = t.get_context();
t.apply(*this);
if(this->validate() == impl->instructions.end())
RTG_THROW("Invalid program from compilation");
MIGRAPH_THROW("Invalid program from compilation");
}
argument program::eval(std::unordered_map<std::string, argument> params) const
......@@ -196,4 +196,4 @@ std::ostream& operator<<(std::ostream& os, const program& p)
return os;
}
} // namespace rtg
} // namespace migraph
#include <rtg/shape.hpp>
#include <rtg/stringutils.hpp>
#include <migraph/shape.hpp>
#include <migraph/stringutils.hpp>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iostream>
namespace rtg {
namespace migraph {
shape::shape() : m_type(float_type), m_packed(false) {}
......@@ -109,12 +109,12 @@ std::string shape::type_string() const
{
switch(this->m_type)
{
#define RTG_SHAPE_TYPE_STRING_CASE(x, t) \
#define MIGRAPH_SHAPE_TYPE_STRING_CASE(x, t) \
case x: return #x;
RTG_SHAPE_VISIT_TYPES(RTG_SHAPE_TYPE_STRING_CASE)
#undef RTG_SHAPE_TYPE_STRING_CASE
MIGRAPH_SHAPE_VISIT_TYPES(MIGRAPH_SHAPE_TYPE_STRING_CASE)
#undef MIGRAPH_SHAPE_TYPE_STRING_CASE
}
RTG_THROW("Invalid type");
MIGRAPH_THROW("Invalid type");
}
bool operator==(const shape& x, const shape& y)
......@@ -131,4 +131,4 @@ std::ostream& operator<<(std::ostream& os, const shape& x)
return os;
}
} // namespace rtg
} // namespace migraph
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