ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 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
21#ifndef __NNFW_H__
22#define __NNFW_H__
23
24#include <stddef.h>
25#include <stdint.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
61
105
129
148
152typedef enum
153{
159
163#define NNFW_MAX_RANK (6)
164
177typedef struct nnfw_tensorinfo
178{
182 int32_t rank;
187 int32_t dims[NNFW_MAX_RANK];
189
204
214
225NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *path);
226
242NNFW_STATUS nnfw_apply_tensorinfo(nnfw_session *session, uint32_t index,
243 nnfw_tensorinfo tensor_info);
244
265NNFW_STATUS nnfw_set_input_tensorinfo(nnfw_session *session, uint32_t index,
266 const nnfw_tensorinfo *tensor_info);
267
279
293
311
327
347NNFW_STATUS nnfw_set_input(nnfw_session *session, uint32_t index, NNFW_TYPE type,
348 const void *buffer, size_t length);
349
369NNFW_STATUS nnfw_set_output(nnfw_session *session, uint32_t index, NNFW_TYPE type, void *buffer,
370 size_t length);
371
383NNFW_STATUS nnfw_input_size(nnfw_session *session, uint32_t *number);
384
396NNFW_STATUS nnfw_output_size(nnfw_session *session, uint32_t *number);
397
409NNFW_STATUS nnfw_set_input_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout);
410
422NNFW_STATUS nnfw_set_output_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout);
423
439NNFW_STATUS nnfw_input_tensorinfo(nnfw_session *session, uint32_t index,
440 nnfw_tensorinfo *tensor_info);
441
460NNFW_STATUS nnfw_output_tensorinfo(nnfw_session *session, uint32_t index,
461 nnfw_tensorinfo *tensor_info);
462
481
498NNFW_STATUS nnfw_set_op_backend(nnfw_session *session, const char *op, const char *backend);
499
513NNFW_STATUS nnfw_query_info_u32(nnfw_session *session, NNFW_INFO_ID id, uint32_t *val);
514
527NNFW_STATUS nnfw_set_workspace(nnfw_session *session, const char *dir);
528
529#ifdef __cplusplus
530}
531#endif
532
533#endif
NNFW_STATUS nnfw_create_session(nnfw_session **session)
Create a new session instance.
NNFW_STATUS nnfw_load_model_from_file(nnfw_session *session, const char *path)
Load model from path to model or nnpackage.
NNFW_STATUS
Result values returned from a call to an API function.
Definition nnfw.h:110
@ NNFW_STATUS_INVALID_STATE
Definition nnfw.h:121
@ NNFW_STATUS_UNEXPECTED_NULL
Definition nnfw.h:119
@ NNFW_STATUS_NO_ERROR
Definition nnfw.h:112
@ NNFW_STATUS_DEPRECATED_API
Definition nnfw.h:127
@ NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE
Definition nnfw.h:125
@ NNFW_STATUS_ERROR
Definition nnfw.h:117
@ NNFW_STATUS_OUT_OF_MEMORY
Definition nnfw.h:123
NNFW_STATUS nnfw_set_input(nnfw_session *session, uint32_t index, NNFW_TYPE type, const void *buffer, size_t length)
Set input buffer.
Definition nnfw_api.cc:96
NNFW_STATUS nnfw_await(nnfw_session *session)
Wait for asynchronous run to finish.
Definition nnfw_api.cc:90
NNFW_STATUS nnfw_apply_tensorinfo(nnfw_session *session, uint32_t index, nnfw_tensorinfo tensor_info)
Apply i-th input's tensor info to resize input tensor.
Definition nnfw_api.cc:155
NNFW_STATUS nnfw_close_session(nnfw_session *session)
Close a session instance.
Definition nnfw_api.cc:60
NNFW_STATUS nnfw_query_info_u32(nnfw_session *session, NNFW_INFO_ID id, uint32_t *val)
Retrieve uint32 type of nnfw information for given information ID.
Definition nnfw_api.cc:178
NNFW_STATUS nnfw_run_async(nnfw_session *session)
Run inference asynchronously.
Definition nnfw_api.cc:84
NNFW_STATUS nnfw_output_tensorinfo(nnfw_session *session, uint32_t index, nnfw_tensorinfo *tensor_info)
Get i-th output tensor info.
Definition nnfw_api.cc:141
NNFW_STATUS nnfw_set_available_backends(nnfw_session *session, const char *backends)
Set available backends.
Definition nnfw_api.cc:167
NNFW_STATUS nnfw_input_tensorinfo(nnfw_session *session, uint32_t index, nnfw_tensorinfo *tensor_info)
Get i-th input tensor info.
Definition nnfw_api.cc:134
NNFW_STATUS nnfw_output_size(nnfw_session *session, uint32_t *number)
Get the number of outputs.
Definition nnfw_api.cc:116
NNFW_INFO_ID
Information ID for retrieving information on nnfw (e.g. version)
Definition nnfw.h:153
@ NNFW_INFO_ID_VERSION
Definition nnfw.h:157
NNFW_STATUS nnfw_set_workspace(nnfw_session *session, const char *dir)
Set runtime's workspace directory.
Definition nnfw_api.cc:230
NNFW_STATUS nnfw_input_size(nnfw_session *session, uint32_t *number)
Get the number of inputs.
Definition nnfw_api.cc:110
NNFW_STATUS nnfw_set_input_tensorinfo(nnfw_session *session, uint32_t index, const nnfw_tensorinfo *tensor_info)
Set input model's tensor info for resizing.
Definition nnfw_api.cc:160
NNFW_STATUS nnfw_run(nnfw_session *session)
Run inference.
Definition nnfw_api.cc:78
NNFW_STATUS nnfw_prepare(nnfw_session *session)
Prepare session to be ready for inference.
Definition nnfw_api.cc:72
NNFW_STATUS nnfw_set_output(nnfw_session *session, uint32_t index, NNFW_TYPE type, void *buffer, size_t length)
Set output buffer.
Definition nnfw_api.cc:103
NNFW_STATUS nnfw_set_op_backend(nnfw_session *session, const char *op, const char *backend)
Set the operation's backend.
Definition nnfw_api.cc:173
NNFW_TYPE
Tensor types.
Definition nnfw.h:68
@ NNFW_TYPE_TENSOR_INT64
Definition nnfw.h:86
@ NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED
Definition nnfw.h:102
@ NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED
Definition nnfw.h:93
@ NNFW_TYPE_TENSOR_BOOL
Definition nnfw.h:80
@ NNFW_TYPE_TENSOR_INT32
Definition nnfw.h:72
@ NNFW_TYPE_TENSOR_QUANT8_ASYMM
Definition nnfw.h:78
@ NNFW_TYPE_TENSOR_UINT8
Definition nnfw.h:83
@ NNFW_TYPE_TENSOR_FLOAT32
Definition nnfw.h:70
#define NNFW_MAX_RANK
Maximum rank expressible with nnfw.
Definition nnfw.h:163
NNFW_STATUS nnfw_set_output_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
Set the layout of an output.
Definition nnfw_api.cc:128
NNFW_LAYOUT
Data format of a tensor.
Definition nnfw.h:134
@ NNFW_LAYOUT_CHANNELS_LAST
Definition nnfw.h:141
@ NNFW_LAYOUT_CHANNELS_FIRST
Definition nnfw.h:146
@ NNFW_LAYOUT_NONE
Definition nnfw.h:136
NNFW_STATUS nnfw_set_input_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
Set the layout of an input.
Definition nnfw_api.cc:122
NNFW_STATUS
Result values returned from a call to an API function.
Definition onert-micro.h:86
NNFW_TYPE
Definition onert-micro.h:75
tensor info describes the type and shape of tensors
NNFW_TYPE dtype
int32_t dims[NNFW_MAX_RANK]