ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw_internal.h File Reference
#include "nnfw.h"

Go to the source code of this file.

Functions

NNFW_STATUS nnfw_set_config (nnfw_session *session, const char *key, const char *value)
 
NNFW_STATUS nnfw_get_config (nnfw_session *session, const char *key, char *value, size_t value_size)
 
NNFW_STATUS nnfw_load_circle_from_buffer (nnfw_session *session, uint8_t *buffer, size_t size)
 Load a circle model from buffer.
 
NNFW_STATUS nnfw_train_export_circleplus (nnfw_session *session, const char *file_path)
 Export circle+ model.
 
NNFW_STATUS nnfw_get_output (nnfw_session *session, uint32_t index, nnfw_tensorinfo *out_info, const void **out_buffer)
 Python-binding-only API to retrieve a read-only output buffer and its tensor info.
 

Function Documentation

◆ nnfw_get_config()

NNFW_STATUS nnfw_get_config ( nnfw_session session,
const char *  key,
char *  value,
size_t  value_size 
)

Definition at line 439 of file APIImpl.cc.

440{
442 return reinterpret_cast<Session *>(session)->get_config(key, value, value_size);
443}
#define NNFW_RETURN_ERROR_IF_NULL(p)
Definition APIImpl.cc:52
onert::api::Session Session
Definition APIImpl.cc:59
SessionID session(const coco::Module *m)
Definition Session.cpp:48

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_get_output()

NNFW_STATUS nnfw_get_output ( nnfw_session session,
uint32_t  index,
nnfw_tensorinfo out_info,
const void **  out_buffer 
)

Python-binding-only API to retrieve a read-only output buffer and its tensor info.

After nnfw_run has been called, the session has already resized or allocated the internal output buffer to match the latest output dimensions. This API simply retrieves that internal buffer pointer and the corresponding tensor info without performing any allocation itself.

Note: this function is intended for Python binding only. The buffer is managed internally by the session and must not be modified by the caller. In Python, wrap the pointer as a NumPy array and set array.flags.writeable = False to enforce read-only access.

Important: To use this API, you must call nnfw_set_prepare_config(session, NNFW_ENABLE_INTERNAL_OUTPUT_ALLOC, "true") before calling nnfw_prepare().

Parameters
[in]sessionThe session object
[in]indexOutput tensor index
[out]out_infonnfw_tensorinfo to be filled with the latest shape/type information
[out]out_bufferPointer to a const buffer managed by the session
Returns
NNFW_STATUS_NO_ERROR on success, otherwise an error code

Definition at line 457 of file APIImpl.cc.

459{
461 return reinterpret_cast<Session *>(session)->get_output(index, out_info, out_buffer);
462}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by onert::api::python::NNFW_SESSION::get_output().

◆ nnfw_load_circle_from_buffer()

NNFW_STATUS nnfw_load_circle_from_buffer ( nnfw_session session,
uint8_t *  buffer,
size_t  size 
)

Load a circle model from buffer.

The buffer must outlive the session.

Parameters
[in]sessionsession
[in]bufferPointer to the buffer
[in]sizeBuffer size
Returns
NNFW_STATUS

Definition at line 445 of file APIImpl.cc.

446{
448 return reinterpret_cast<Session *>(session)->load_circle_from_buffer(buffer, size);
449}
int32_t size[5]
Definition Slice.cpp:35

References NNFW_RETURN_ERROR_IF_NULL, and size.

◆ nnfw_set_config()

NNFW_STATUS nnfw_set_config ( nnfw_session session,
const char *  key,
const char *  value 
)

Definition at line 433 of file APIImpl.cc.

434{
436 return reinterpret_cast<Session *>(session)->set_config(key, value);
437}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_export_circleplus()

NNFW_STATUS nnfw_train_export_circleplus ( nnfw_session session,
const char *  file_path 
)

Export circle+ model.

Note
This function should be called on training mode This function should be called before or after nnfw_train
Parameters
[in]sessionThe session to export training model
[in]file_pathThe path to export training model
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 451 of file APIImpl.cc.

452{
454 return reinterpret_cast<Session *>(session)->train_export_circleplus(path);
455}

References NNFW_RETURN_ERROR_IF_NULL.