tf.cpp 1023 Bytes
Newer Older
kahmed10's avatar
kahmed10 committed
1
#include <migraphx/tf/tf_parser.hpp>
Khalique's avatar
Khalique committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <functional>
#include <array>
#include <utility>
#include <vector>

#include <migraphx/program.hpp>
#include <migraphx/tf.hpp>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {

Shucai Xiao's avatar
Shucai Xiao committed
16
program parse_tf(const std::string& name, const tf_options& options)
Khalique's avatar
Khalique committed
17
18
{
    std::fstream input(name.c_str(), std::ios::in | std::ios::binary);
kahmed10's avatar
kahmed10 committed
19
    tf::tf_parser parser;
kahmed10's avatar
kahmed10 committed
20
21
22
23
    parser.is_nhwc           = options.is_nhwc;
    parser.batch_size        = options.batch_size;
    parser.map_input_dims    = options.map_input_dims;
    parser.output_node_names = options.output_node_names;
Khalique's avatar
Khalique committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

#ifndef NDEBUG
    // Log the program when it can't be parsed
    try
    {
        parser.parse_from(input);
    }
    catch(...)
    {
        std::cerr << parser.prog << std::endl;
        throw;
    }
#else
    parser.parse_from(input);
#endif
    return std::move(parser.prog);
}

} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx