Commit d7ba7f44 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

add more test for the refinement.

parent f8511fad
......@@ -20,6 +20,12 @@ static bool try_compute_shape(instruction_ref ins, const std::vector<shape>& inp
return true;
}
// if no changes for the shape, the contiguous can also be removed
if (new_shape == ins->get_shape())
{
return true;
}
auto outputs = ins->outputs();
// If the current instruction has no output, it means it is the last
// instruction and generates a non-standard output. But for unary
......
......@@ -21,7 +21,7 @@ struct binary
shape compute_shape(std::vector<shape> inputs) const
{
check_shapes{inputs}.has(2).same_type().same_dims();
return {inputs.at(0).type(), inputs.at(0).lens()};
return inputs.at(0);
}
};
......
......@@ -21,7 +21,7 @@ struct unary
shape compute_shape(std::vector<shape> inputs) const
{
check_shapes{inputs}.has(1);
return {inputs.at(0).type(), inputs.at(0).lens()};
return inputs.at(0);
}
};
......
......@@ -2,6 +2,7 @@
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/op/identity.hpp>
#include <migraphx/op/dot.hpp>
#include <migraphx/op/add.hpp>
#include <migraphx/op/transpose.hpp>
#include <migraphx/op/contiguous.hpp>
#include <basic_ops.hpp>
......@@ -54,4 +55,17 @@ TEST_CASE(transpose_gemm)
EXPECT(std::distance(p.begin(), p.end()) == (count - 1));
}
TEST_CASE(transpose_standard_op)
{
migraphx::program p;
auto l = p.add_literal(get_2x2());
auto t = p.add_instruction(migraphx::op::transpose{{1, 0}}, l);
auto c = p.add_instruction(migraphx::op::contiguous{}, t);
auto sum = p.add_instruction(migraphx::op::add{}, c, c);
p.add_instruction(pass_standard_op{}, sum);
auto count = std::distance(p.begin(), p.end());
p.compile(eliminate_contiguous_target{});
EXPECT(std::distance(p.begin(), p.end()) == count);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
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