Commit e1b6ce59 authored by Paul's avatar Paul
Browse files

Write literals to the gpu

parent 9bc4ce27
...@@ -26,6 +26,20 @@ struct hip_allocate ...@@ -26,6 +26,20 @@ struct hip_allocate
} }
}; };
struct hip_write
{
std::string name() const { return "hip::write"; }
shape compute_shape(std::vector<shape> inputs) const
{
check_shapes{inputs}.has(1);
return inputs.front();
}
argument compute(context&, shape, std::vector<argument> args) const
{
return to_gpu(args.front());
}
};
} // namespace miopen } // namespace miopen
} // namespace migraph } // namespace migraph
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <migraph/miopen/miopen.hpp> #include <migraph/miopen/miopen.hpp>
#include <migraph/miopen/hip.hpp> #include <migraph/miopen/hip.hpp>
#include <migraph/dfor.hpp> #include <migraph/dfor.hpp>
#include <migraph/iterator_for.hpp>
namespace migraph { namespace migraph {
namespace miopen { namespace miopen {
...@@ -306,7 +307,25 @@ struct miopen_pass ...@@ -306,7 +307,25 @@ struct miopen_pass
void apply(program& p) const { miopen_apply{&p}.apply(); } void apply(program& p) const { miopen_apply{&p}.apply(); }
}; };
std::vector<pass> miopen_target::get_passes(context&) const { return {miopen_pass{}}; } struct miopen_write_literals
{
std::string name() const { return "miopen::write_literals"; }
void apply(program& p) const
{
for(auto ins:iterator_for(p))
{
if(ins->op.name() == "@literal")
{
literal l = ins->lit;
auto pre = p.add_literal(l);
p.replace_instruction(ins, hip_write{}, pre);
}
}
}
};
std::vector<pass> miopen_target::get_passes(context&) const { return {miopen_pass{}, miopen_write_literals{}}; }
std::string miopen_target::name() const { return "miopen"; } std::string miopen_target::name() const { return "miopen"; }
......
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