2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __DALGONA_UTILS_H__
18 #define __DALGONA_UTILS_H__
20 #include <luci_interpreter/Interpreter.h>
22 #include <pybind11/embed.h>
24 namespace py = pybind11;
29 template <typename... Args> void pySafeCall(py::object func, Args... args)
35 catch (py::error_already_set &e)
37 throw std::runtime_error(e.what());
41 py::dict outputPyArray(const luci::CircleNode *node, luci_interpreter::Interpreter *interpreter);
43 // Return a vector of Tensors(py::dict) which correspond to node's inputs
44 std::vector<py::dict> inputsPyArray(const luci::CircleNode *node,
45 luci_interpreter::Interpreter *interpreter);
47 // Return a vector of Tensors(py::dict) which correspond to the outputs of multi-out node (ex:
49 std::vector<py::dict> outputsPyArray(const luci::CircleNode *node,
50 luci_interpreter::Interpreter *interpreter);
54 bool multi_out_node(const luci::CircleNode *node);
56 } // namespace dalgona
58 #endif // __DALGONA_UTILS_H__