"git@developer.sourcefind.cn:wuxk1/megatron-lm.git" did not exist on "2d98cfbf235febbd7c10d48af6b619af8079a7ff"
Commit 0d94f068 authored by Paul's avatar Paul
Browse files

Format

parent bb7f65d9
...@@ -615,7 +615,7 @@ inline auto var(std::string s) ...@@ -615,7 +615,7 @@ inline auto var(std::string s)
[=, s = std::move(s)](const matcher_context& ctx, [=, s = std::move(s)](const matcher_context& ctx,
instruction_ref) -> optional<instruction_ref> { instruction_ref) -> optional<instruction_ref> {
auto it = ctx.instructions.find(s); auto it = ctx.instructions.find(s);
if(it == ctx.instructions.end()) if(it == ctx.instructions.end())
return nullopt; return nullopt;
return it->second; return it->second;
}); });
......
...@@ -92,9 +92,9 @@ struct find_layernorm ...@@ -92,9 +92,9 @@ struct find_layernorm
{ {
auto ins = r.result; auto ins = r.result;
auto x_ins = r.instructions["x"]; auto x_ins = r.instructions["x"];
float eps = 0; float eps = 0;
if(contains(r.instructions, "eps")) if(contains(r.instructions, "eps"))
eps = r.instructions["eps"]->eval().at<float>(); eps = r.instructions["eps"]->eval().at<float>();
m.replace_instruction(ins, layernorm{eps}, x_ins); m.replace_instruction(ins, layernorm{eps}, x_ins);
} }
...@@ -104,14 +104,15 @@ struct find_add_layernorm ...@@ -104,14 +104,15 @@ struct find_add_layernorm
{ {
auto matcher() const auto matcher() const
{ {
return match::name("gpu::prelayernorm")(match::args(match::name("add")(match::used_once()).bind("add"))); return match::name("gpu::prelayernorm")(
match::args(match::name("add")(match::used_once()).bind("add")));
} }
void apply(module& m, const match::matcher_result& r) const void apply(module& m, const match::matcher_result& r) const
{ {
auto ins = r.result; auto ins = r.result;
auto add_ins = r.instructions["add"]; auto add_ins = r.instructions["add"];
auto op = any_cast<layernorm>(ins->get_operator()); auto op = any_cast<layernorm>(ins->get_operator());
m.replace_instruction(ins, add_layernorm{op.epsilon}, add_ins->inputs()); m.replace_instruction(ins, add_layernorm{op.epsilon}, add_ins->inputs());
} }
......
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