"...targets/git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "3f29db093e6ad324f3c94ea51b327a7e9864d987"
Commit c4cd8b0a authored by Paul's avatar Paul
Browse files

Merge

parents 92324d57 4a312201
...@@ -754,10 +754,16 @@ auto skip_broadcasts(Ms... ms) ...@@ -754,10 +754,16 @@ auto skip_broadcasts(Ms... ms)
return skip(name("broadcast", "multibroadcast", "contiguous"))(ms...); return skip(name("broadcast", "multibroadcast", "contiguous"))(ms...);
} }
template <class... Ms>
auto skip_broadcasts_converts(Ms... ms)
{
return skip(name("broadcast", "multibroadcast", "contiguous", "convert"))(ms...);
}
template <class T> template <class T>
inline auto has_value(T x, float tolerance = 1e-6) inline auto has_value(T x, float tolerance = 1e-6)
{ {
return skip_broadcasts(make_basic_pred_matcher([=](instruction_ref ins) { return skip_broadcasts_converts(make_basic_pred_matcher([=](instruction_ref ins) {
if(ins->name() != "@literal") if(ins->name() != "@literal")
return false; return false;
auto l = ins->get_literal(); auto l = ins->get_literal();
......
...@@ -30,7 +30,7 @@ namespace migraphx { ...@@ -30,7 +30,7 @@ namespace migraphx {
${preamble} ${preamble}
extern "C" { extern "C" {
__global__ void kernel(${params}) __global__ void ${kernel}(${params})
{ {
auto idx = make_index(); auto idx = make_index();
pointwise(idx, ${transformers})(${lambda}, ${args}); pointwise(idx, ${transformers})(${lambda}, ${args});
...@@ -42,6 +42,18 @@ __global__ void kernel(${params}) ...@@ -42,6 +42,18 @@ __global__ void kernel(${params})
)__migraphx__"; )__migraphx__";
static std::vector<std::string> get_op_names(const module& m)
{
std::vector<std::string> result;
for(auto& ins : m)
{
if(starts_with(ins.name(), "@"))
continue;
result.push_back(ins.name());
}
return result;
}
struct pointwise_compiler : compiler<pointwise_compiler> struct pointwise_compiler : compiler<pointwise_compiler>
{ {
std::vector<std::string> names() const { return {"pointwise"}; } std::vector<std::string> names() const { return {"pointwise"}; }
...@@ -69,7 +81,8 @@ struct pointwise_compiler : compiler<pointwise_compiler> ...@@ -69,7 +81,8 @@ struct pointwise_compiler : compiler<pointwise_compiler>
options.output.elements() / vec.size, options.output.elements() / vec.size,
oversubscribe_if(not preloads.is_preloading()))); oversubscribe_if(not preloads.is_preloading())));
auto src = interpolate_string(pointwise_kernel, auto src = interpolate_string(pointwise_kernel,
{{"params", enum_params(inputs.size(), "void * private_p")}, {{"kernel", options.kernel_name},
{"params", enum_params(inputs.size(), "void * private_p")},
{"args", enum_params(inputs.size(), "private_p")}, {"args", enum_params(inputs.size(), "private_p")},
{"lambda", v.at("lambda").to<std::string>()}, {"lambda", v.at("lambda").to<std::string>()},
{"transformers", make_transformer_args(preloads, vec)}, {"transformers", make_transformer_args(preloads, vec)},
...@@ -98,8 +111,13 @@ struct pointwise_compiler : compiler<pointwise_compiler> ...@@ -98,8 +111,13 @@ struct pointwise_compiler : compiler<pointwise_compiler>
auto name = g.create_function( auto name = g.create_function(
g.generate_module(*pm).set_attributes({"__device__"}).set_generic_types(*pm)); g.generate_module(*pm).set_attributes({"__device__"}).set_generic_types(*pm));
std::string lambda = "MIGRAPHX_LIFT(" + name + ")"; std::string lambda = "MIGRAPHX_LIFT(" + name + ")";
auto op_names = get_op_names(*pm);
op_names.push_back("kernel");
auto op_name_string = join_strings(op_names, "_");
return replace( return replace(
compile_op(ctx, to_shapes(ins->inputs()), {{"lambda", lambda}, {"preamble", g.str()}})); compile_op(ctx,
to_shapes(ins->inputs()),
{{"lambda", lambda}, {"preamble", g.str()}, {"kernel", op_name_string}}));
} }
}; };
} // namespace gpu } // namespace gpu
......
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