ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert_micro::execute::OMKernelExecute Struct Reference

#include <OMKernelExecute.h>

Static Public Member Functions

static OMStatus runForward (OMExecuteArgs &, core::memory::OMRuntimeAllocator &allocator)
 

Detailed Description

Definition at line 31 of file OMKernelExecute.h.

Member Function Documentation

◆ runForward()

OMStatus OMKernelExecute::runForward ( OMExecuteArgs execute_args,
core::memory::OMRuntimeAllocator allocator 
)
static

Definition at line 24 of file OMKernelExecute.cpp.

26{
27 OMStatus status = Ok;
28
29 core::OMRuntimeContext &context = execute_args.runtime_context;
30 core::OMRuntimeStorage &storage = execute_args.runtime_storage;
31
32 const core::reader::CircleOperators *operators = context.getCircleOperators();
33
34 const auto num_operators = static_cast<uint16_t>(operators->size());
35 const auto *op_codes = context.getCircleOpcodes();
36
37 for (uint16_t i = 0; i < num_operators; ++i)
38 {
39 status = allocator.allocate(i, &context, &storage);
40
41 if (status != Ok)
42 return status;
43
45 const circle::Operator *op = operators->operator[](i);
46 uint32_t index = op->opcode_index();
47
48 assert(index < op_codes->size());
49
50 const auto opcode = op_codes->operator[](index);
51
52 status = core::getBuilderId(opcode, builder_id);
53
54 assert(status == Ok);
55 if (status != Ok)
56 return status;
57
58 execute_args.kernel_index = i;
59
60 KernelExecuteFunc *execute_func = nullptr;
61 if (size_t(builder_id) < size_t(core::OMBuilderID::BuiltinOperatorsSize))
62 {
63 // Builtin operator
64 status = kernel_builtin_execute.getKernelExecuteFunc(builder_id, &execute_func);
65 }
66 else
67 {
68 // Custom
69 status = kernel_custom_execute.getKernelExecuteFunc(builder_id, &execute_func);
70 }
71
72 assert(execute_func != nullptr);
73
74 if (status != Ok)
75 return status;
76
77 status = execute_func(execute_args);
78
79 assert(status == Ok);
80
81 if (status != Ok)
82 return status;
83
84#ifdef OM_MEMORY_ESTIMATE
85 status = allocator.deallocate(i, &storage, &context);
86#else
87 status = allocator.deallocate(i, &storage);
88#endif // OM_MEMORY_ESTIMATE
89 }
90
91 return status;
92}
uoffset_t size() const
const reader::CircleOperatorCodes * getCircleOpcodes()
const reader::CircleOperators * getCircleOperators()
OMStatus allocate(size_t kernel_index, OMRuntimeContext *context, OMRuntimeStorage *storage)
OMStatus deallocate(size_t kernel_index, OMRuntimeStorage *storage)
OMStatus getKernelExecuteFunc(core::OMBuilderID builderID, KernelExecuteFunc **execute_func) const
OMStatus getKernelExecuteFunc(core::OMBuilderID builderID, KernelExecuteFunc **execute_func) const
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54
OMStatus getBuilderId(const circle::OperatorCode *opcode, core::OMBuilderID &builderID)
constexpr KernelBuiltinExecuteRegistry kernel_builtin_execute
constexpr KernelCustomExecuteRegistry kernel_custom_execute
OMStatus(const OMExecuteArgs &) KernelExecuteFunc
int32_t size[5]
Definition Slice.cpp:35
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage

References onert_micro::core::memory::OMRuntimeAllocator::allocate(), onert_micro::core::BuiltinOperatorsSize, onert_micro::core::memory::OMRuntimeAllocator::deallocate(), onert_micro::core::getBuilderId(), onert_micro::core::OMRuntimeContext::getCircleOpcodes(), onert_micro::core::OMRuntimeContext::getCircleOperators(), onert_micro::execute::KernelBuiltinExecuteRegistry::getKernelExecuteFunc(), onert_micro::execute::KernelCustomExecuteRegistry::getKernelExecuteFunc(), onert_micro::execute::kernel_builtin_execute, onert_micro::execute::kernel_custom_execute, onert_micro::execute::OMExecuteArgs::kernel_index, onert_micro::Ok, onert_micro::execute::OMExecuteArgs::runtime_context, onert_micro::execute::OMExecuteArgs::runtime_storage, flatbuffers::Vector< T >::size(), size, and onert_micro::core::Size.

Referenced by onert_micro::core::OMRuntimeModule::run().


The documentation for this struct was generated from the following files: