cpu_event_test.cpp 1.33 KB
Newer Older
mei-ye's avatar
mei-ye committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <migraphx/pre_scheduling.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/program.hpp>
#include <migraphx/cpu/target.hpp>
#include <basic_ops.hpp>
#include <test.hpp>

// This is a test to trigger the code in cpu's context.hpp and runtime
// codes in program.cpp.
//

TEST_CASE(test1)
{
    migraphx::program p;
    auto in1 = p.add_parameter("0", migraphx::shape{migraphx::shape::float_type, {32, 64, 1, 1}});
    auto in2 = p.add_parameter("1", migraphx::shape{migraphx::shape::float_type, {64, 64, 1, 1}});
    auto p1  = p.add_instruction(migraphx::op::convolution{}, in1, in2);
    p1->set_stream(0);
    auto in3 = p.add_parameter("2", migraphx::shape{migraphx::shape::float_type, {64, 64, 1, 1}});
    auto p2  = p.add_instruction(migraphx::op::convolution{}, in1, in3);
    p2->set_stream(1);
    p2->set_event(0);
    p2->add_mask(migraphx::record_event);
    auto p3 = p.add_instruction(migraphx::op::concat{1}, p1, p2);
    p3->set_stream(0);
    p3->add_mask(migraphx::wait_event);
    p.compile(migraphx::cpu::target{});
    migraphx::program::parameter_map m;
    for(auto&& x : p.get_parameter_shapes())
    {
        m[x.first] = migraphx::generate_argument(x.second);
    }
    p.eval(m);
}

int main(int argc, const char* argv[]) { test::run(argc, argv); }