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

Formatting

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