Commit 1cefcdfa authored by Shucai Xiao's avatar Shucai Xiao
Browse files

fix review comments.

parent 3393530b
......@@ -37,11 +37,8 @@ struct program
// copy constructor
program(const program&);
// move assignment operator
program& operator=(program&&) noexcept;
// copy assignment operator
program& operator=(const program&);
program& operator=(program);
~program() noexcept;
......
......@@ -86,20 +86,15 @@ static void print_program(const program& p, F print_func)
program::program() : impl(std::make_unique<program_impl>()) {}
program::program(program&&) noexcept = default;
program& program::operator=(program&&) noexcept = default;
program::~program() noexcept = default;
// copy constructor
program::program(const program& p) { copy(p); }
// copy assignment operator
program& program::operator=(const program& p)
program& program::operator=(program p)
{
if(this != &p)
{
copy(p);
}
std::swap(p.impl, this->impl);
return *this;
}
......
......@@ -771,7 +771,7 @@ template <typename Op>
struct cpu_binary
{
Op op;
std::string name() const { return op.name(); }
std::string name() const { return "cpu::" + op.name(); }
shape compute_shape(const std::vector<shape>& inputs) const { return inputs.front(); }
argument compute(context&, const shape& output_shape, std::vector<argument> args) const
{
......
......@@ -40,32 +40,45 @@ TEST_CASE(program_copy)
auto l2 = p.add_literal(migraphx::literal(s, data));
auto p1 = p.add_parameter("x", s);
auto po = p.add_outline(s);
auto sum = p.add_instruction(migraphx::op::add{}, l2, p1);
p.add_instruction(migraphx::op::mul{}, sum, po);
auto sum = p.add_instruction(migraphx::op::add{}, l2, po);
p.add_instruction(migraphx::op::mul{}, sum, p1);
return p;
};
{
auto p1 = create_program_1();
auto p2 = p1;
migraphx::program p2{};
p2 = p1;
p2.compile(migraphx::cpu::target{});
EXPECT(p1 != p2);
p1.compile(migraphx::cpu::target{});
EXPECT(p1 == p2);
}
{
auto p1 = create_program_1();
auto p2(p1);
p2.compile(migraphx::cpu::target{});
EXPECT(p1 == p2);
p1.compile(migraphx::cpu::target{});
EXPECT(p1 != p2);
p2 = p1;
EXPECT(p1 == p2);
}
{
auto p1 = create_program_1();
auto p2 = create_program();
p2.compile(migraphx::cpu::target{});
EXPECT(p1 != p2);
p2 = p1;
EXPECT(p1 == p2);
p1.compile(migraphx::cpu::target{});
p2.compile(migraphx::cpu::target{});
EXPECT(p1 == p2);
......
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