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

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

parent 1cdb49a6
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_DFOR_HPP #ifndef MIGRAPH_GUARD_MIGRAPHLIB_DFOR_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_DFOR_HPP #define MIGRAPH_GUARD_MIGRAPHLIB_DFOR_HPP
namespace migraph { #include <migraph/config.hpp>
namespace migraph { inline namespace MIGRAPH_INLINE_NS {
// Multidimensional for loop // Multidimensional for loop
inline auto dfor() inline auto dfor()
...@@ -20,6 +22,7 @@ auto dfor(T x, Ts... xs) ...@@ -20,6 +22,7 @@ auto dfor(T x, Ts... xs)
}; };
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
#include <string> #include <string>
#include <migraph/instruction_ref.hpp> #include <migraph/instruction_ref.hpp>
#include <migraph/config.hpp>
namespace migraph { inline namespace MIGRAPH_INLINE_NS {
namespace migraph {
struct program; struct program;
struct eliminate_allocation struct eliminate_allocation
...@@ -14,6 +16,8 @@ struct eliminate_allocation ...@@ -14,6 +16,8 @@ struct eliminate_allocation
std::string name() const { return "eliminate_allocation"; } std::string name() const { return "eliminate_allocation"; }
void apply(program& p) const; void apply(program& p) const;
}; };
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <string> #include <string>
#include <migraph/instruction_ref.hpp> #include <migraph/instruction_ref.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
...@@ -14,6 +15,7 @@ struct eliminate_contiguous ...@@ -14,6 +15,7 @@ struct eliminate_contiguous
void apply(program& p) const; void apply(program& p) const;
}; };
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
// Declare a cached environment variable // Declare a cached environment variable
#define MIGRAPH_DECLARE_ENV_VAR(x) \ #define MIGRAPH_DECLARE_ENV_VAR(x) \
...@@ -31,6 +32,7 @@ bool disabled(T) ...@@ -31,6 +32,7 @@ bool disabled(T)
return result; return result;
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#define MIGRAPH_GUARD_ERASE_HPP #define MIGRAPH_GUARD_ERASE_HPP
#include <algorithm> #include <algorithm>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
/** /**
* @brief Erase all elements from a container * @brief Erase all elements from a container
...@@ -31,6 +32,7 @@ auto erase_if(R&& r, P&& pred) ...@@ -31,6 +32,7 @@ auto erase_if(R&& r, P&& pred)
return r.erase(std::remove_if(r.begin(), r.end(), pred), r.end()); return r.erase(std::remove_if(r.begin(), r.end(), pred), r.end());
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include <exception> #include <exception>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
/// Represents exceptions that can be thrown by migraphlib /// Represents exceptions that can be thrown by migraphlib
struct exception : std::runtime_error struct exception : std::runtime_error
...@@ -44,6 +45,7 @@ inline std::string make_source_context(const std::string& file, int line) ...@@ -44,6 +45,7 @@ inline std::string make_source_context(const std::string& file, int line)
#define MIGRAPH_THROW(...) \ #define MIGRAPH_THROW(...) \
throw migraph::make_exception(migraph::make_source_context(__FILE__, __LINE__), __VA_ARGS__) throw migraph::make_exception(migraph::make_source_context(__FILE__, __LINE__), __VA_ARGS__)
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
#ifndef MIGRAPH_GUARD_FALLTHROUGH_HPP #ifndef MIGRAPH_GUARD_FALLTHROUGH_HPP
#define MIGRAPH_GUARD_FALLTHROUGH_HPP #define MIGRAPH_GUARD_FALLTHROUGH_HPP
namespace migraph { #include <migraph/config.hpp>
namespace migraph { inline namespace MIGRAPH_INLINE_NS {
#ifdef __clang__ #ifdef __clang__
#define MIGRAPH_FALLTHROUGH [[clang::fallthrough]] #define MIGRAPH_FALLTHROUGH [[clang::fallthrough]]
...@@ -9,6 +11,7 @@ namespace migraph { ...@@ -9,6 +11,7 @@ namespace migraph {
#define MIGRAPH_FALLTHROUGH #define MIGRAPH_FALLTHROUGH
#endif #endif
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
#endif #endif
#include <migraph/requires.hpp> #include <migraph/requires.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
template <class... Ts> template <class... Ts>
using common_type = typename std::common_type<Ts...>::type; using common_type = typename std::common_type<Ts...>::type;
...@@ -40,6 +41,7 @@ struct float_equal_fn ...@@ -40,6 +41,7 @@ struct float_equal_fn
static constexpr float_equal_fn float_equal{}; static constexpr float_equal_fn float_equal{};
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#define MIGRAPH_GUARD_RTGLIB_FUNCTIONAL_HPP #define MIGRAPH_GUARD_RTGLIB_FUNCTIONAL_HPP
#include <utility> #include <utility>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
struct swallow struct swallow
{ {
...@@ -129,6 +130,7 @@ auto fold(F f) ...@@ -129,6 +130,7 @@ auto fold(F f)
return [=](auto&&... xs) { return fold_impl(f, std::forward<decltype(xs)>(xs)...); }; return [=](auto&&... xs) { return fold_impl(f, std::forward<decltype(xs)>(xs)...); };
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <string> #include <string>
#include <migraph/instruction_ref.hpp> #include <migraph/instruction_ref.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
...@@ -14,6 +15,7 @@ struct fwd_conv_batchnorm_rewrite ...@@ -14,6 +15,7 @@ struct fwd_conv_batchnorm_rewrite
void apply(program& p) const; void apply(program& p) const;
}; };
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
#include <migraph/argument.hpp> #include <migraph/argument.hpp>
#include <migraph/literal.hpp> #include <migraph/literal.hpp>
#include <migraph/type_traits.hpp> #include <migraph/type_traits.hpp>
#include <migraph/config.hpp>
#include <random> #include <random>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
template <class T, MIGRAPH_REQUIRES(is_floating_point<T>{})> template <class T, MIGRAPH_REQUIRES(is_floating_point<T>{})>
constexpr T normalize(unsigned long z) constexpr T normalize(unsigned long z)
...@@ -91,6 +92,7 @@ literal generate_literal(shape s, unsigned long seed = 0); ...@@ -91,6 +92,7 @@ literal generate_literal(shape s, unsigned long seed = 0);
literal abs(literal l); literal abs(literal l);
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
#define MIGRAPH_GUARD_RTGLIB_HALF_HPP #define MIGRAPH_GUARD_RTGLIB_HALF_HPP
#include <half.hpp> #include <half.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
using half = half_float::half; using half = half_float::half;
...@@ -31,6 +32,7 @@ struct deduce<half_float::detail::expr> ...@@ -31,6 +32,7 @@ struct deduce<half_float::detail::expr>
template <class T> template <class T>
using deduce = typename detail::deduce<T>::type; using deduce = typename detail::deduce<T>::type;
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
#include <migraph/instruction_ref.hpp> #include <migraph/instruction_ref.hpp>
#include <migraph/operation.hpp> #include <migraph/operation.hpp>
#include <migraph/erase.hpp> #include <migraph/erase.hpp>
#include <migraph/config.hpp>
#include <string> #include <string>
#include <utility> #include <utility>
namespace migraph { namespace migraph { inline namespace MIGRAPH_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);
...@@ -88,6 +89,7 @@ struct instruction ...@@ -88,6 +89,7 @@ struct instruction
std::vector<instruction_ref> arguments; std::vector<instruction_ref> arguments;
literal lit; literal lit;
}; };
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
namespace std { namespace std {
...@@ -101,6 +103,7 @@ struct hash<migraph::instruction_ref> ...@@ -101,6 +103,7 @@ struct hash<migraph::instruction_ref>
return std::hash<migraph::instruction*>{}(&*x); return std::hash<migraph::instruction*>{}(&*x);
} }
}; };
} // namespace std } // namespace std
#endif #endif
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
#include <list> #include <list>
#include <functional> #include <functional>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
struct instruction; struct instruction;
using instruction_ref = std::list<instruction>::iterator; using instruction_ref = std::list<instruction>::iterator;
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <cassert> #include <cassert>
#include <type_traits> #include <type_traits>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
template <class T> template <class T>
struct iterator_for_range struct iterator_for_range
...@@ -37,6 +38,7 @@ iterator_for_range<T> iterator_for(T& x) ...@@ -37,6 +38,7 @@ iterator_for_range<T> iterator_for(T& x)
return {&x}; return {&x};
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
#include <migraph/tensor_view.hpp> #include <migraph/tensor_view.hpp>
#include <migraph/raw_data.hpp> #include <migraph/raw_data.hpp>
#include <migraph/make_shared_array.hpp> #include <migraph/make_shared_array.hpp>
#include <migraph/config.hpp>
#include <memory> #include <memory>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
/** /**
* @brief Represents a raw literal * @brief Represents a raw literal
...@@ -122,6 +123,7 @@ literal transform(literal l1, literal l2, F f) ...@@ -122,6 +123,7 @@ literal transform(literal l1, literal l2, F f)
return result; return result;
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#define MIGRAPH_GUARD_MIGRAPHLIB_MAKE_SHARED_ARRAY_HPP #define MIGRAPH_GUARD_MIGRAPHLIB_MAKE_SHARED_ARRAY_HPP
#include <memory> #include <memory>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
template <typename T> template <typename T>
std::shared_ptr<T> make_shared_array(size_t size) std::shared_ptr<T> make_shared_array(size_t size)
...@@ -11,6 +12,7 @@ std::shared_ptr<T> make_shared_array(size_t size) ...@@ -11,6 +12,7 @@ std::shared_ptr<T> make_shared_array(size_t size)
return std::shared_ptr<T>(new T[size], std::default_delete<T[]>()); return std::shared_ptr<T>(new T[size], std::default_delete<T[]>());
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
template <class F, F f> // NOLINT template <class F, F f> // NOLINT
struct manage_deleter struct manage_deleter
...@@ -49,6 +50,7 @@ shared<T> share(T p) ...@@ -49,6 +50,7 @@ shared<T> share(T p)
return shared<T>{std::move(p)}; return shared<T>{std::move(p)};
} }
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#define MIGRAPH_MANAGE_PTR(T, F) \ #define MIGRAPH_MANAGE_PTR(T, F) \
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
#include <migraph/instruction.hpp> #include <migraph/instruction.hpp>
#include <migraph/program.hpp> #include <migraph/program.hpp>
#include <migraph/iterator_for.hpp> #include <migraph/iterator_for.hpp>
#include <migraph/config.hpp>
#include <unordered_map> #include <unordered_map>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
namespace match { namespace match {
...@@ -338,7 +339,7 @@ inline auto either_arg(std::size_t i, std::size_t j) ...@@ -338,7 +339,7 @@ inline auto either_arg(std::size_t i, std::size_t j)
} }
} // namespace match } // namespace match
} // inline namespace MIGRAPH_INLINE_NS
} // namespace migraph } // namespace migraph
#endif #endif
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <string> #include <string>
#include <migraph/instruction_ref.hpp> #include <migraph/instruction_ref.hpp>
#include <migraph/config.hpp>
namespace migraph { namespace migraph { inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
struct memory_coloring struct memory_coloring
...@@ -13,6 +14,8 @@ struct memory_coloring ...@@ -13,6 +14,8 @@ struct memory_coloring
std::string name() const { return "memory coloring"; } std::string name() const { return "memory coloring"; }
void apply(program& p) const; void apply(program& p) const;
}; };
} // 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