test_sub2.cpp 847 Bytes
Newer Older
1
2
3
4

#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
5
#include <migraphx/make_op.hpp>
6
7
8
9
10
11

struct test_sub2 : verify_program<test_sub2>
{
    migraphx::program create_program() const
    {
        migraphx::program p;
12
        auto* mm = p.get_main_module();
13
14
        migraphx::shape s{migraphx::shape::float_type, {2, 3}};
        migraphx::shape b{migraphx::shape::float_type, {3}};
15
16
17
18
        auto x  = mm->add_parameter("x", s);
        auto y  = mm->add_parameter("y", s);
        auto z  = mm->add_parameter("z", b);
        auto zb = mm->add_instruction(
19
            migraphx::make_op("broadcast", {{"axis", 1}, {"out_lens", s.lens()}}), z);
20
21
        auto diff = mm->add_instruction(migraphx::make_op("sub"), x, y);
        mm->add_instruction(migraphx::make_op("sub"), diff, zb);
22
23
24
        return p;
    }
};