Commit 74b3d019 authored by Paul's avatar Paul
Browse files

Formatting

parent 4f778e9f
...@@ -10,10 +10,10 @@ namespace migraph { ...@@ -10,10 +10,10 @@ namespace migraph {
template <class T> template <class T>
struct xorshf96_generator struct xorshf96_generator
{ {
long max = 16; long max = 16;
unsigned long x = 123456789; unsigned long x = 123456789;
unsigned long y = 362436069; unsigned long y = 362436069;
unsigned long z = 521288629; unsigned long z = 521288629;
constexpr T operator()() noexcept constexpr T operator()() noexcept
{ {
......
...@@ -7,36 +7,32 @@ namespace migraph { ...@@ -7,36 +7,32 @@ namespace migraph {
struct swallow struct swallow
{ {
template<class... Ts> template <class... Ts>
swallow(Ts&&...) swallow(Ts&&...)
{} {
}
}; };
struct tracer struct tracer
{ {
tracer() tracer() {}
{}
tracer(std::ostream& s) : os(&s) tracer(std::ostream& s) : os(&s) {}
{}
bool enabled() const bool enabled() const { return os != nullptr; }
{
return os != nullptr;
}
template<class... Ts> template <class... Ts>
void operator()(const Ts&... xs) const void operator()(const Ts&... xs) const
{ {
if(os != nullptr) if(os != nullptr)
{ {
swallow{*os << xs...}; swallow{*os << xs...};
*os << std::endl; *os << std::endl;
} }
} }
private: private:
std::ostream * os = nullptr; std::ostream* os = nullptr;
}; };
} // namespace migraph } // namespace migraph
......
...@@ -24,16 +24,20 @@ ...@@ -24,16 +24,20 @@
// An improved async, that doesn't block // An improved async, that doesn't block
template <class Function> template <class Function>
std::future<typename std::result_of<Function()>::type> detach_async(Function&& f, bool parallel=true) std::future<typename std::result_of<Function()>::type> detach_async(Function&& f,
bool parallel = true)
{ {
if(parallel){ if(parallel)
using result_type = typename std::result_of<Function()>::type; {
std::packaged_task<result_type()> task(std::forward<Function>(f)); using result_type = typename std::result_of<Function()>::type;
auto fut = task.get_future(); std::packaged_task<result_type()> task(std::forward<Function>(f));
std::thread(std::move(task)).detach(); auto fut = task.get_future();
return std::move(fut); std::thread(std::move(task)).detach();
} else { return std::move(fut);
return std::async(std::launch::deferred, std::move(f)); }
else
{
return std::async(std::launch::deferred, std::move(f));
} }
} }
...@@ -57,10 +61,10 @@ std::array<std::function<void()>, 2> auto_print::handlers = {}; ...@@ -57,10 +61,10 @@ std::array<std::function<void()>, 2> auto_print::handlers = {};
void compile_check(migraph::program& p, migraph::target t) void compile_check(migraph::program& p, migraph::target t)
{ {
auto name = t.name(); auto name = t.name();
auto s = p.get_shape(); auto s = p.get_shape();
std::stringstream ss; std::stringstream ss;
p.compile(std::move(t), migraph::tracer{ss}); p.compile(std::move(t), migraph::tracer{ss});
if(p.get_shape() != s) if(p.get_shape() != s)
{ {
std::cout << ss.str() << std::endl; std::cout << ss.str() << std::endl;
throw std::runtime_error("Compiling program with " + name + " alters its shape"); throw std::runtime_error("Compiling program with " + name + " alters its shape");
......
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