Skip to content

Commit

Permalink
[onert-micro] Introduce user interface entities (#12538)
Browse files Browse the repository at this point in the history
This commit introduces user interface entities.

ONE-DCO-1.0-Signed-off-by: Artem Balyshev <[email protected]>

Co-authored-by: Artem Balyshev <[email protected]>
  • Loading branch information
BalyshevArtem and Artem Balyshev authored Jan 26, 2024
1 parent e3eba64 commit 2f5c40a
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 0 deletions.
31 changes: 31 additions & 0 deletions onert-micro/onert-micro/include/OMConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ONERT_MICRO_CONFIG_H
#define ONERT_MICRO_CONFIG_H

namespace onert_micro
{

struct OMConfig
{
bool keep_input = false;
bool cmsis_nn = false;
};

} // namespace onert_micro

#endif // ONERT_MICRO_CONFIG_H
61 changes: 61 additions & 0 deletions onert-micro/onert-micro/include/OMInterpreter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ONERT_MICRO_INTERPRETER_H
#define ONERT_MICRO_INTERPRETER_H

#include "OMStatus.h"
#include "OMConfig.h"

#include "core/OMRuntimeModule.h"

namespace onert_micro
{

class OMInterpreter
{
private:
core::OMRuntimeModule _runtime_module;

public:
OMInterpreter() = default;
OMInterpreter(const OMInterpreter &) = delete;
OMInterpreter(OMInterpreter &&) = delete;
OMInterpreter &operator=(const OMInterpreter &) = delete;
OMInterpreter &&operator=(const OMInterpreter &&) = delete;
~OMInterpreter() = default;

OMStatus importModel(const char *model_ptr, const OMConfig &config);

OMStatus run();

OMStatus reset();

uint32_t getNumberOfInputs();
uint32_t getNumberOfOutputs();

OMStatus allocateInputs();

uint32_t getInputSizeAt(uint32_t position);
uint32_t getOutputSizeAt(uint32_t position);

void *getInputDataAt(uint32_t position);
void *getOutputDataAt(uint32_t position);
};

} // namespace onert_micro

#endif // ONERT_MICRO_INTERPRETER_H
38 changes: 38 additions & 0 deletions onert-micro/onert-micro/include/OMStatus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef ONERT_MICRO_STATUS_H
#define ONERT_MICRO_STATUS_H

namespace onert_micro
{

enum OMStatus
{
Ok,
UnsupportedType,
UnsupportedActivation,
UnsupportedOp,
UnknownError,
ModelNotImport,
FailedCheckCondition,
NoQuantization,
UnsupportedDynamicShapeCase,
};

} // namespace onert_micro

#endif // ONERT_MICRO_STATUS_H
58 changes: 58 additions & 0 deletions onert-micro/onert-micro/src/OMInterpreter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "OMInterpreter.h"

using namespace onert_micro;

OMStatus OMInterpreter::importModel(const char *model_ptr, const OMConfig &config)
{
assert(model_ptr != nullptr && "Model ptr shouldn't be nullptr");
if (model_ptr == nullptr)
return UnknownError;

return _runtime_module.importModel(model_ptr, config);
}

OMStatus OMInterpreter::run() { return _runtime_module.run(); }

OMStatus OMInterpreter::reset() { return _runtime_module.reset(); }

uint32_t OMInterpreter::getNumberOfInputs() { return _runtime_module.getNumberOfInputs(); }

uint32_t OMInterpreter::getNumberOfOutputs() { return _runtime_module.getNumberOfOutputs(); }

void *OMInterpreter::getInputDataAt(uint32_t position)
{
return _runtime_module.getInputDataAt(position);
}

void *OMInterpreter::getOutputDataAt(uint32_t position)
{
return _runtime_module.getOutputDataAt(position);
}

uint32_t OMInterpreter::getInputSizeAt(uint32_t position)
{
return _runtime_module.getInputSizeAt(position);
}

uint32_t OMInterpreter::getOutputSizeAt(uint32_t position)
{
return _runtime_module.getOutputSizeAt(position);
}

OMStatus OMInterpreter::allocateInputs() { return _runtime_module.allocateInputs(); }

0 comments on commit 2f5c40a

Please sign in to comment.