2 * Copyright (c) 2018 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 __EXECUTION_H__
18 #define __EXECUTION_H__
20 #include <NeuralNetworks.h>
24 #include "exec/Execution.h"
26 struct ANeuralNetworksExecution
29 ANeuralNetworksExecution(const std::shared_ptr<onert::exec::ExecutorMap> &executors)
30 : _execution{std::make_shared<onert::exec::Execution>(executors)}
36 bool setInput(uint32_t index, const ANeuralNetworksOperandType *type, const void *buffer,
37 size_t length) noexcept;
38 bool setOptionalInput(uint32_t index, const ANeuralNetworksOperandType *type, const void *buffer,
39 size_t length) noexcept;
40 bool setOutput(uint32_t index, const ANeuralNetworksOperandType *type, void *buffer,
41 size_t length) noexcept;
42 bool startExecute(void) noexcept;
43 bool execute(void) noexcept;
45 const onert::ir::OperandIndex getInputOperandIndex(int32_t index) noexcept;
46 const onert::ir::OperandIndex getOutputOperandIndex(int32_t index) noexcept;
47 bool compareDataType(const ANeuralNetworksOperandType *type,
48 const onert::ir::OperandIndex index) noexcept;
49 bool compareShape(const ANeuralNetworksOperandType *type,
50 const onert::ir::OperandIndex index) noexcept;
51 bool IsOptionalInput(const onert::ir::OperandIndex index) noexcept;
52 bool hasUnspecifiedDims(const onert::ir::OperandIndex index) noexcept;
53 size_t getOperandSize(const onert::ir::OperandIndex index) noexcept;
54 const std::shared_ptr<onert::exec::Execution> instance(void) noexcept;
57 * @brief Get output operand's rank
58 * @param[in] index Output index
59 * @param[out] rank Output operand's rank
60 * @return @c true if success to get rank, otherwise @c false
62 bool getOutputOperandRank(uint32_t index, uint32_t *rank) noexcept;
64 * @brief Get dimensions of the output operand
65 * @param[in] index Output index
66 * @param[out] dimensions Output operand's dimensions
67 * @return @c true if success to get rank, otherwise @c false
68 * @note This must be called after execution is finished to get resolved output shape
69 * unspecified in model
71 bool getOutputOperandDimensions(uint32_t index, uint32_t *dimensions);
74 std::shared_ptr<onert::exec::Execution> _execution;