context_serialize.cpp 667 Bytes
Newer Older
Shucai Xiao's avatar
Shucai Xiao committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <vector>
#include <migraphx/verify.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/context.hpp>
#include "test.hpp"

TEST_CASE(gpu_context)
{
    migraphx::context ctx = migraphx::gpu::context{0, 3};

    auto v = ctx.to_value();
    EXPECT(v.size() == 2);

    EXPECT(v.contains("events"));
Shucai Xiao's avatar
Shucai Xiao committed
16
    EXPECT(v.at("events").without_key().to<int>() == 0);
Shucai Xiao's avatar
Shucai Xiao committed
17
18

    EXPECT(v.contains("streams"));
Shucai Xiao's avatar
Shucai Xiao committed
19
    EXPECT(v.at("streams").without_key().to<int>() == 3);
Shucai Xiao's avatar
Shucai Xiao committed
20
21
22
23
24
25
26
27
28

    migraphx::gpu::context g_ctx;
    g_ctx.from_value(v);

    auto v1 = g_ctx.to_value();
    EXPECT(v == v1);
}

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