"...git@developer.sourcefind.cn:OpenDAS/torch-harmonics.git" did not exist on "b6c48457994ca02832223bf2f37a16013a1729fd"
Commit 0721ddc1 authored by Paul's avatar Paul
Browse files

Formatting

parent d9fe1c6c
...@@ -15,24 +15,25 @@ void schedule::apply(program& p) const ...@@ -15,24 +15,25 @@ void schedule::apply(program& p) const
std::unordered_map<instruction_ref, std::size_t> weights; std::unordered_map<instruction_ref, std::size_t> weights;
auto last = std::prev(p.end()); auto last = std::prev(p.end());
fix<std::size_t>([&](auto self, auto ins) -> std::size_t { fix<std::size_t>([&](auto self, auto ins) -> std::size_t {
if (weights.count(ins) == 0) if(weights.count(ins) == 0)
{ {
weights[ins] = std::accumulate(ins->inputs().begin(), ins->inputs().end(), model.weight(ins->get_operator()), [&](std::size_t w, instruction_ref i) { weights[ins] =
return w + self(i); std::accumulate(ins->inputs().begin(),
}); ins->inputs().end(),
model.weight(ins->get_operator()),
[&](std::size_t w, instruction_ref i) { return w + self(i); });
} }
return weights[ins]; return weights[ins];
})(last); })(last);
// Topo sort // Topo sort
fix([&](auto self, auto ins) { fix([&](auto self, auto ins) {
for(auto i:ins->inputs()) for(auto i : ins->inputs())
p.move_instruction(i, p.begin()); p.move_instruction(i, p.begin());
for(auto i:ins->inputs()) for(auto i : ins->inputs())
self(i); self(i);
})(last); })(last);
} }
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx } // namespace migraphx
...@@ -18,7 +18,10 @@ struct schedule_model ...@@ -18,7 +18,10 @@ struct schedule_model
std::size_t n = 4; std::size_t n = 4;
std::size_t concurrency() const; std::size_t concurrency() const;
void schedule_instruction(program& p, instruction_ref ins, std::size_t n) const; void schedule_instruction(program& p, instruction_ref ins, std::size_t n) const;
void wait(program& p, instruction_ref ins, std::size_t wait_on, const std::vector<std::size_t>& wait_for) const; void wait(program& p,
instruction_ref ins,
std::size_t wait_on,
const std::vector<std::size_t>& wait_for) const;
std::size_t weight(const operation& op) const; std::size_t weight(const operation& op) const;
}; };
......
...@@ -6,18 +6,15 @@ namespace migraphx { ...@@ -6,18 +6,15 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace gpu { namespace gpu {
std::size_t schedule_model::concurrency() const std::size_t schedule_model::concurrency() const { return n; }
void schedule_model::schedule_instruction(program& p, instruction_ref ins, std::size_t n) const {}
void schedule_model::wait(program& p,
instruction_ref ins,
std::size_t wait_on,
const std::vector<std::size_t>& wait_for) const
{ {
return n;
}
void schedule_model::schedule_instruction(program& p, instruction_ref ins, std::size_t n) const
{}
void schedule_model::wait(program& p, instruction_ref ins, std::size_t wait_on, const std::vector<std::size_t>& wait_for) const
{}
std::size_t schedule_model::weight(const operation& op) const
{
return 1;
} }
std::size_t schedule_model::weight(const operation& op) const { return 1; }
} // namespace gpu } // namespace gpu
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
......
...@@ -27,8 +27,11 @@ struct schedule_model ...@@ -27,8 +27,11 @@ struct schedule_model
std::size_t concurrency() const; std::size_t concurrency() const;
/// Schedule a concurrent instruction /// Schedule a concurrent instruction
void schedule_instruction(program& p, instruction_ref ins, std::size_t n) const; void schedule_instruction(program& p, instruction_ref ins, std::size_t n) const;
// Insert necessary waits before an instruction // Insert necessary waits before an instruction
void wait(program& p, instruction_ref ins, std::size_t wait_on, const std::vector<std::size_t>& wait_for) const; void wait(program& p,
instruction_ref ins,
std::size_t wait_on,
const std::vector<std::size_t>& wait_for) const;
/// Compute weights for an operation /// Compute weights for an operation
std::size_t weight(const operation& op) const; std::size_t weight(const operation& op) const;
}; };
......
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