test_tf_parser.cpp 1.32 KB
Newer Older
kahmed10's avatar
kahmed10 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
39
40
41
42
43
44
45
#include <migraphx/migraphx.h>
#include <migraphx/migraphx.hpp>
#include "test.hpp"

TEST_CASE(load_tf)
{
    auto p      = migraphx::parse_tf("add_test.pb");
    auto shapes = p.get_output_shapes();
    CHECK(shapes.size() == 1);
}

TEST_CASE(load_tf_default_dim)
{
    migraphx::tf_options tf_options;
    size_t batch = 2;
    tf_options.set_default_dim_value(batch);
    tf_options.set_nhwc();
    auto p      = migraphx::parse_tf("conv_batch_test.pb", tf_options);
    auto shapes = p.get_output_shapes();
    CHECK(shapes.size() == 1);
    CHECK(shapes.front().lengths().front() == batch);
}

TEST_CASE(load_tf_param_shape)
{
    migraphx::tf_options tf_options;
    std::vector<size_t> new_shape{1, 3};
    tf_options.set_input_parameter_shape("0", new_shape);
    tf_options.set_input_parameter_shape("1", new_shape);
    auto p      = migraphx::parse_tf("add_test.pb", tf_options);
    auto shapes = p.get_output_shapes();
    CHECK(shapes.size() == 1);
    CHECK(shapes.front().lengths() == new_shape);
}

TEST_CASE(load_tf_multi_outputs)
{
    migraphx::tf_options tf_options;
    tf_options.set_output_names({"relu", "tanh"});
    auto p      = migraphx::parse_tf("multi_output_test.pb", tf_options);
    auto shapes = p.get_output_shapes();
    CHECK(shapes.size() == 2);
}

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