ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Support.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2017 The TensorFlow Authors. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __SUPPORT_H__
19#define __SUPPORT_H__
20
21#include <tensorflow/core/framework/graph.pb.h>
22
23#include <iostream>
24#include <string>
25
26namespace tfkit
27{
28namespace tf
29{
30
31bool HasAttr(const tensorflow::NodeDef &, const std::string &);
32tensorflow::DataType GetDataTypeAttr(const tensorflow::NodeDef &, const std::string &);
33tensorflow::TensorProto *GetTensorAttr(tensorflow::NodeDef &, const std::string &);
35int GetElementCount(const tensorflow::TensorShapeProto &);
36
37} // namespace tf
38
40{
41public:
42 CmdArguments() = delete;
43 CmdArguments(int argc, const char *const *argv)
44 : _argc(static_cast<unsigned int>(argc)), _argv{argv}
45 {
46 }
47
48 std::string get(unsigned int index) const;
49 std::string get_or(unsigned int index, const std::string &) const;
50
51private:
52 unsigned int _argc;
53 const char *const *_argv;
54};
55
57{
58public:
59 std::istream *in() const { return _in ? _in.get() : &std::cin; }
60 std::ostream *out() const { return _out ? _out.get() : &std::cout; }
61
62public:
63 void in(std::unique_ptr<std::istream> &&in) { _in = std::move(in); }
64 void out(std::unique_ptr<std::ostream> &&out) { _out = std::move(out); }
65
66private:
67 std::unique_ptr<std::istream> _in;
68 std::unique_ptr<std::ostream> _out;
69};
70
71std::unique_ptr<IOConfiguration> make_ioconfig(const CmdArguments &cmdargs);
72
73} // namespace tfkit
74
75#endif // __SUPPORT_H__
CmdArguments(int argc, const char *const *argv)
Definition Support.hpp:43
std::string get_or(unsigned int index, const std::string &) const
Definition Support.cpp:103
std::string get(unsigned int index) const
Definition Support.cpp:95
std::istream * in() const
Definition Support.hpp:59
std::ostream * out() const
Definition Support.hpp:60
void out(std::unique_ptr< std::ostream > &&out)
Definition Support.hpp:64
void in(std::unique_ptr< std::istream > &&in)
Definition Support.hpp:63
bool HasAttr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Support.cpp:53
int GetElementCount(const tensorflow::TensorShapeProto &shape)
GetElementCount returns -1 for rank-0 tensor shape.
Definition Support.cpp:74
tensorflow::TensorProto * GetTensorAttr(tensorflow::NodeDef &node, const std::string &attr_name)
Definition Support.cpp:66
tensorflow::DataType GetDataTypeAttr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Support.cpp:58
std::unique_ptr< IOConfiguration > make_ioconfig(const CmdArguments &cmdargs)
Definition Support.cpp:111