ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __DALGONA_UTILS_H__
18#define __DALGONA_UTILS_H__
19
20#include <luci_interpreter/Interpreter.h>
21
22#include <pybind11/embed.h>
23
24namespace py = pybind11;
25
26namespace dalgona
27{
28
29template <typename... Args> void pySafeCall(py::object func, Args... args)
30{
31 try
32 {
33 func(args...);
34 }
35 catch (py::error_already_set &e)
36 {
37 throw std::runtime_error(e.what());
38 }
39}
40
41py::dict outputPyArray(const luci::CircleNode *node, luci_interpreter::Interpreter *interpreter);
42
43// Return a vector of Tensors(py::dict) which correspond to node's inputs
44std::vector<py::dict> inputsPyArray(const luci::CircleNode *node,
46
47// Return a vector of Tensors(py::dict) which correspond to the outputs of multi-out node (ex:
48// SPLIT)
49std::vector<py::dict> outputsPyArray(const luci::CircleNode *node,
51
52py::object none();
53
54bool multi_out_node(const luci::CircleNode *node);
55
56} // namespace dalgona
57
58#endif // __DALGONA_UTILS_H__
std::vector< py::dict > inputsPyArray(const luci::CircleNode *node, luci_interpreter::Interpreter *interpreter)
Definition Utils.cpp:109
std::vector< py::dict > outputsPyArray(const luci::CircleNode *node, luci_interpreter::Interpreter *interpreter)
Definition Utils.cpp:134
void pySafeCall(py::object func, Args... args)
Definition Utils.h:29
py::dict outputPyArray(const luci::CircleNode *node, luci_interpreter::Interpreter *interpreter)
Definition Utils.cpp:160
py::object none()
Definition Utils.cpp:107
bool multi_out_node(const luci::CircleNode *node)
Definition Utils.cpp:175