Commit d79346d1 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

Added inline namespace for all .hpp and .cpp file.

parent 7d972d2b
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <ostream> #include <ostream>
#include <migraph/functional.hpp> #include <migraph/functional.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
struct tracer struct tracer
{ {
...@@ -28,6 +29,7 @@ struct tracer ...@@ -28,6 +29,7 @@ struct tracer
std::ostream* os = nullptr; std::ostream* os = nullptr;
}; };
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#define MIGRAPH_GUARD_RTGLIB_TYPE_NAME_HPP #define MIGRAPH_GUARD_RTGLIB_TYPE_NAME_HPP
#include <string> #include <string>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
template <class PrivateMigraphTypeNameProbe> template <class PrivateMigraphTypeNameProbe>
const std::string& get_type_name() const std::string& get_type_name()
...@@ -39,6 +40,7 @@ const std::string& get_type_name(const T&) ...@@ -39,6 +40,7 @@ const std::string& get_type_name(const T&)
return migraph::get_type_name<T>(); return migraph::get_type_name<T>();
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
#include <type_traits> #include <type_traits>
#include <migraph/half.hpp> #include <migraph/half.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
#define MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(trait, T) \ #define MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(trait, T) \
template <class X> \ template <class X> \
...@@ -28,6 +29,7 @@ MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(is_floating_point, half) ...@@ -28,6 +29,7 @@ MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(is_floating_point, half)
MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(is_signed, half) MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(is_signed, half)
MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(is_arithmetic, half) MIGRAPH_DETAIL_EXTEND_TRAIT_FOR(is_arithmetic, half)
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
#include <numeric> #include <numeric>
#include <migraph/float_equal.hpp> #include <migraph/float_equal.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
// Compute the value of a range // Compute the value of a range
template <class R> template <class R>
...@@ -170,5 +171,7 @@ bool verify_range(R1&& r1, R2&& r2, double tolerance = 80, double* out_error = n ...@@ -170,5 +171,7 @@ bool verify_range(R1&& r1, R2&& r2, double tolerance = 80, double* out_error = n
*out_error = error; *out_error = error;
return error <= threshold; return error <= threshold;
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <migraph/verify.hpp> #include <migraph/verify.hpp>
#include <migraph/argument.hpp> #include <migraph/argument.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
inline bool verify_args(const std::string& name, inline bool verify_args(const std::string& name,
const argument& cpu_arg, const argument& cpu_arg,
...@@ -82,6 +83,7 @@ inline bool verify_args(const std::string& name, ...@@ -82,6 +83,7 @@ inline bool verify_args(const std::string& name,
return passed; return passed;
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <migraph/builtin.hpp> #include <migraph/builtin.hpp>
#include <migraph/erase.hpp> #include <migraph/erase.hpp>
namespace migraph { namespace migraph { namespace MIGRAPH_INLINE_NS {
instruction::instruction(operation o, shape r, std::vector<instruction_ref> args) instruction::instruction(operation o, shape r, std::vector<instruction_ref> args)
: op(std::move(o)), result(std::move(r)), arguments(std::move(args)) : op(std::move(o)), result(std::move(r)), arguments(std::move(args))
...@@ -182,4 +182,5 @@ shape compute_shape(const operation& op, const std::vector<instruction_ref>& arg ...@@ -182,4 +182,5 @@ shape compute_shape(const operation& op, const std::vector<instruction_ref>& arg
return op.compute_shape(compute_shapes(args)); return op.compute_shape(compute_shapes(args));
} }
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
...@@ -14,9 +14,10 @@ ...@@ -14,9 +14,10 @@
#include <migraph/operators.hpp> #include <migraph/operators.hpp>
#include <migraph/ranges.hpp> #include <migraph/ranges.hpp>
#include <migraph/instruction.hpp> #include <migraph/instruction.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph {
namespace MIGRAPH_INLINE_NS {
struct unknown struct unknown
{ {
std::string op; std::string op;
...@@ -625,4 +626,5 @@ program parse_onnx(const std::string& name) ...@@ -625,4 +626,5 @@ program parse_onnx(const std::string& name)
return std::move(parser.prog); return std::move(parser.prog);
} }
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
...@@ -6,13 +6,14 @@ ...@@ -6,13 +6,14 @@
#include <migraph/operators.hpp> #include <migraph/operators.hpp>
#include <migraph/iterator_for.hpp> #include <migraph/iterator_for.hpp>
#include <migraph/pass_config.hpp> #include <migraph/pass_config.hpp>
#include <migraph/config.hpp>
#include <set> #include <set>
#include <list> #include <list>
#include <vector> #include <vector>
#include <queue> #include <queue>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
//#define MIGRAPH_DEBUG_OPT //#define MIGRAPH_DEBUG_OPT
...@@ -21,6 +22,8 @@ namespace migraph { ...@@ -21,6 +22,8 @@ namespace migraph {
#else #else
#define MIGRAPH_DEBUG(s) #define MIGRAPH_DEBUG(s)
#endif // MIGRAPH_DEBUG_OPT #endif // MIGRAPH_DEBUG_OPT
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif // MIGRAPH_GUARD_RTGLIB_COMMON_HEADER_HPP #endif // MIGRAPH_GUARD_RTGLIB_COMMON_HEADER_HPP
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "memory_coloring_impl.hpp" #include "memory_coloring_impl.hpp"
namespace migraph { namespace migraph {
namespace MIGRAPH_INLINE_NS {
void memory_coloring::apply(program& p) const void memory_coloring::apply(program& p) const
{ {
...@@ -11,4 +12,6 @@ void memory_coloring::apply(program& p) const ...@@ -11,4 +12,6 @@ void memory_coloring::apply(program& p) const
opt.run(); opt.run();
} }
} }
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#include "memory_coloring_impl.hpp" #include "memory_coloring_impl.hpp"
namespace migraph { namespace migraph {
namespace MIGRAPH_INLINE_NS {
void memory_coloring_impl::run() void memory_coloring_impl::run()
{ {
...@@ -357,4 +358,6 @@ void live_interval::dump() ...@@ -357,4 +358,6 @@ void live_interval::dump()
} }
#endif #endif
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#ifndef MIGRAPH_GUARD_RTGLIB_MEMORY_COLORING_IMPL_HPP #ifndef MIGRAPH_GUARD_RTGLIB_MEMORY_COLORING_IMPL_HPP
#define MIGRAPH_GUARD_RTGLIB_MEMORY_COLORING_IMPL_HPP #define MIGRAPH_GUARD_RTGLIB_MEMORY_COLORING_IMPL_HPP
#include "common_header.hpp" #include "common_header.hpp"
#include <migraph/config.hpp>
namespace migraph { namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
static const int invalid_offset = -1; static const int invalid_offset = -1;
...@@ -177,5 +179,7 @@ struct memory_coloring_impl ...@@ -177,5 +179,7 @@ struct memory_coloring_impl
bool unify_literals; bool unify_literals;
std::string allocation_op{}; std::string allocation_op{};
}; };
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <utility> #include <utility>
namespace migraph { namespace migraph {
namespace MIGRAPH_INLINE_NS {
MIGRAPH_DECLARE_ENV_VAR(MIGRAPH_TRACE_COMPILE) MIGRAPH_DECLARE_ENV_VAR(MIGRAPH_TRACE_COMPILE)
MIGRAPH_DECLARE_ENV_VAR(MIGRAPH_TRACE_EVAL) MIGRAPH_DECLARE_ENV_VAR(MIGRAPH_TRACE_EVAL)
...@@ -498,4 +499,6 @@ std::ostream& operator<<(std::ostream& os, const program& p) ...@@ -498,4 +499,6 @@ std::ostream& operator<<(std::ostream& os, const program& p)
print_program(os, p, [](auto&&...) {}); print_program(os, p, [](auto&&...) {});
return os; return os;
} }
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <functional> #include <functional>
#include <iostream> #include <iostream>
namespace migraph { namespace migraph { namespace MIGRAPH_INLINE_NS {
struct shape_impl struct shape_impl
{ {
...@@ -190,4 +190,5 @@ std::ostream& operator<<(std::ostream& os, const shape& x) ...@@ -190,4 +190,5 @@ std::ostream& operator<<(std::ostream& os, const shape& x)
return os; return os;
} }
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <migraph/literal.hpp> #include <migraph/literal.hpp>
namespace migraph { namespace migraph {
namespace MIGRAPH_INLINE_NS {
struct find_add_lit_broadcast struct find_add_lit_broadcast
{ {
...@@ -60,4 +61,5 @@ struct find_add_lit_broadcast ...@@ -60,4 +61,5 @@ struct find_add_lit_broadcast
void simplify_algebra::apply(program& p) const { match::find_matches(p, find_add_lit_broadcast{}); } void simplify_algebra::apply(program& p) const { match::find_matches(p, find_add_lit_broadcast{}); }
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <unordered_set> #include <unordered_set>
namespace migraph { namespace migraph {
namespace MIGRAPH_INLINE_NS {
bool is_reshaper(const std::string& name) bool is_reshaper(const std::string& name)
{ {
...@@ -59,4 +60,5 @@ void simplify_reshapes::apply(program& p) const ...@@ -59,4 +60,5 @@ void simplify_reshapes::apply(program& p) const
} }
} }
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <blaze/math/CustomMatrix.h> #include <blaze/math/CustomMatrix.h>
namespace migraph { namespace migraph {
namespace MIGRAPH_INLINE_NS {
namespace cpu { namespace cpu {
template <class T> template <class T>
...@@ -93,5 +94,5 @@ void migemm( ...@@ -93,5 +94,5 @@ void migemm(
} }
} // namespace cpu } // namespace cpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#ifndef MIGRAPH_GUARD_RTGLIB_CONTEXT_HPP #ifndef MIGRAPH_GUARD_RTGLIB_CONTEXT_HPP
#define MIGRAPH_GUARD_RTGLIB_CONTEXT_HPP #define MIGRAPH_GUARD_RTGLIB_CONTEXT_HPP
namespace migraph { #include <migraph/config.hpp>
namespace migraph { inline namespace MIGRAPH_INLINE_NS {
namespace cpu { namespace cpu {
struct context struct context
...@@ -10,6 +12,7 @@ struct context ...@@ -10,6 +12,7 @@ struct context
}; };
} // namespace cpu } // namespace cpu
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -2,15 +2,16 @@ ...@@ -2,15 +2,16 @@
#define MIGRAPH_GUARD_RTGLIB_CPU_GEMM_HPP #define MIGRAPH_GUARD_RTGLIB_CPU_GEMM_HPP
#include <migraph/argument.hpp> #include <migraph/argument.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
namespace cpu { namespace cpu {
void migemm( void migemm(
const argument& c_arg, const argument& a_arg, const argument& b_arg, float alpha, float beta); const argument& c_arg, const argument& a_arg, const argument& b_arg, float alpha, float beta);
} // namespace cpu } // namespace cpu
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#define MIGRAPH_GUARD_RTGLIB_CPU_LOWERING_HPP #define MIGRAPH_GUARD_RTGLIB_CPU_LOWERING_HPP
#include <migraph/program.hpp> #include <migraph/program.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
namespace cpu { namespace cpu {
struct lowering struct lowering
...@@ -13,7 +14,7 @@ struct lowering ...@@ -13,7 +14,7 @@ struct lowering
}; };
} // namespace cpu } // namespace cpu
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <migraph/program.hpp> #include <migraph/program.hpp>
#include <migraph/cpu/context.hpp> #include <migraph/cpu/context.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
namespace cpu { namespace cpu {
struct target struct target
...@@ -15,7 +16,7 @@ struct target ...@@ -15,7 +16,7 @@ struct target
}; };
} // namespace cpu } // namespace cpu
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
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