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

refine the changes

parent c201c46b
......@@ -58,7 +58,7 @@ void auto_contiguous::apply(module& p) const
continue;
auto ins_alias = ins->get_operator().output_alias({});
if(ins_alias == 0)
if(ins_alias == 0 and ins->get_shape().element_space() != ins->inputs().front()->get_shape().element_space())
{
auto cont_ins = p.insert_instruction(last, make_op("contiguous"), ins);
p.replace_instruction(ins, cont_ins);
......
......@@ -223,11 +223,11 @@ struct shape
static type_t parse_type(const std::string& s);
const std::vector<shape>& sub_shapes() const;
std::size_t element_space() const;
private:
std::shared_ptr<const shape_impl> impl;
std::size_t element_space() const;
};
void migraphx_to_value(value& v, const shape& s);
......
......@@ -120,7 +120,9 @@ struct find_nop_reshapes
void apply(module& p, const match::matcher_result& mr) const
{
auto ins = mr.result;
if(ins->name() == "contiguous")
// output of reshape and contiguous is standard, so no need to add another contiguous
// if the output is used an a ret value
if(ins->name() == "contiguous" and ins->name() != "contiguous" and ins->name() != "reshape")
{
auto& outputs = ins->outputs();
if(std::any_of(
......
......@@ -34,12 +34,12 @@ TEST_CASE(basic_graph_test)
EXPECT(migraphx::contains(test, "\"main:@0\"[label=\"@literal\"]"));
EXPECT(migraphx::contains(test, "\"y\"[label=\"@param:y\"]"));
EXPECT(migraphx::contains(test, "\"x\"[label=\"@param:x\"]"));
EXPECT(migraphx::contains(test, "\"main:@1\"[label=\"sum\"]"));
EXPECT(migraphx::contains(test, "\"main:@2\"[label=\"sum\"]"));
EXPECT(migraphx::contains(test, "\"x\" -> \"main:@1\""));
EXPECT(migraphx::contains(test, "\"y\" -> \"main:@1\""));
EXPECT(migraphx::contains(test, "\"main:@1\" -> \"main:@2\""));
EXPECT(migraphx::contains(test, "\"main:@0\" -> \"main:@2\""));
EXPECT(migraphx::contains(test, "\"main:@3\"[label=\"sum\"]"));
EXPECT(migraphx::contains(test, "\"main:@4\"[label=\"sum\"]"));
EXPECT(migraphx::contains(test, "\"x\" -> \"main:@3\""));
EXPECT(migraphx::contains(test, "\"y\" -> \"main:@3\""));
EXPECT(migraphx::contains(test, "\"main:@3\" -> \"main:@4\""));
EXPECT(migraphx::contains(test, "\"main:@0\" -> \"main:@4\""));
EXPECT(migraphx::contains(test, "[label=\"int64_type, {1}, {0}\"]"));
}
......
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