Commit 13b53697 authored by Khalique Ahmed's avatar Khalique Ahmed
Browse files

add test

parent e3e487a1
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
#include <migraphx/op/reduce_mean.hpp> #include <migraphx/op/reduce_mean.hpp>
migraphx::instruction_ref migraphx::instruction_ref
add_layernorm(migraphx::module& m, migraphx::instruction_ref x, std::vector<size_t> dims) add_layernorm(migraphx::module& m, migraphx::instruction_ref x, std::vector<size_t> dims, float eps=1e-12f)
{ {
auto scale = auto scale =
m.add_parameter("scale", migraphx::shape{migraphx::shape::float_type, {dims.back()}}); m.add_parameter("scale", migraphx::shape{migraphx::shape::float_type, {dims.back()}});
auto bias = auto bias =
m.add_parameter("bias", migraphx::shape{migraphx::shape::float_type, {dims.back()}}); m.add_parameter("bias", migraphx::shape{migraphx::shape::float_type, {dims.back()}});
auto epsilon = m.add_literal(1e-12f); auto epsilon = m.add_literal(eps);
auto exponent = m.add_literal(2.0f); auto exponent = m.add_literal(2.0f);
auto mean = m.add_instruction(migraphx::op::reduce_mean({2}), x); auto mean = m.add_instruction(migraphx::op::reduce_mean({2}), x);
...@@ -88,6 +88,19 @@ struct test_layernorm2 : verify_program<test_layernorm2> ...@@ -88,6 +88,19 @@ struct test_layernorm2 : verify_program<test_layernorm2>
} }
}; };
struct test_layernorm_eps : verify_program<test_layernorm_eps>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<size_t> dims = {1, 2, 5};
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, dims});
add_layernorm(*mm, x, dims, 1e-5f);
return p;
}
};
struct test_layernorm_triadd : verify_program<test_layernorm_triadd> struct test_layernorm_triadd : verify_program<test_layernorm_triadd>
{ {
migraphx::program create_program() const migraphx::program create_program() 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