Skip to content

Commit

Permalink
[onert/odc] Auto-compilation. OdcInfo and input/output buffers in Exe…
Browse files Browse the repository at this point in the history
…cution

This PR for `odc:auto-compilation` introduces OdcInfo structure and input/output buffers in Execution.
For [Issue]( #13288).
From [Draft](#13530).

ONE-DCO-1.0-Signed-off-by: Evgenii Maltsev [email protected]
  • Loading branch information
Torrero committed Nov 29, 2024
1 parent c6c8c0d commit cf0fdb2
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
14 changes: 14 additions & 0 deletions runtime/onert/core/include/exec/Execution.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ class Execution
size_t getInputTotalSize(ir::IOIndex ind) const;
size_t getOutputTotalSize(ir::IOIndex ind) const;

/**
* @brief Get pointer of Input Buffer
* @param[in] index Input index
* @return Pointer of Input Buffer
*/
const void *getInputBuffer(ir::IOIndex ind) const;

/**
* @brief Get pointer of Output Buffer
* @param[in] index Output index
* @return Pointer of Output Buffer
*/
void *getOutputBuffer(ir::IOIndex ind);

ExecutionOptions &executionOptions() { return _ctx.options; }

private:
Expand Down
78 changes: 78 additions & 0 deletions runtime/onert/core/include/odc/OdcInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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_ODC_ODC_INFO_H__
#define __ONERT_ODC_ODC_INFO_H__

namespace onert
{
namespace odc
{

/**
* @brief Structure contains information about current state of on-device compiler
*/
class OdcInfo
{
public:
OdcInfo() {}
OdcInfo(const OdcInfo &) = default;
OdcInfo(OdcInfo &&) = default;
OdcInfo &operator=(const OdcInfo &) = default;
OdcInfo &operator=(OdcInfo &&) = default;
~OdcInfo() = default;

/**
* @brief Flag provides information about loading quantized model
*
* Within ODC pipeline, float model is quantized during inference and then this quantized model is
* loaded and run.
*
* @return @c true if quantized model loaded, otherwise @c false
*/
int isQuantizedModelLoaded() const { return _is_quantized_model_loaded; }

/**
* @brief Flag provides information about loading compiled model
*
* Within ODC pipeline, after quantization ODC launches code generation for quantized model
* automatically. After compilation, ODC tries to load and run compiled model.
*
* @return @c true if compiled model loaded, otherwise @c false
*/
int isCompiledModelLoaded() const { return _is_compiled_model_loaded; }

/**
* @brief Set loading flag for quantized model
* @param[in] new_value New value
*/
void setQuantizedModelLoaded(bool new_value) { _is_quantized_model_loaded = new_value; }

/**
* @brief Set loading flag for compiled model
* @param[in] new_value New value
*/
void setCompiledModelLoaded(bool new_value) { _is_compiled_model_loaded = new_value; }

private:
bool _is_quantized_model_loaded = false;
bool _is_compiled_model_loaded = false;
};

} // namespace odc
} // namespace onert

#endif // __ONERT_ODC_ODC_INFO_H__
10 changes: 10 additions & 0 deletions runtime/onert/core/src/exec/Execution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,15 @@ size_t Execution::getOutputTotalSize(ir::IOIndex ind) const
return _ctx.desc.outputs.at(ind.value())->info.total_size();
}

const void *Execution::getInputBuffer(ir::IOIndex ind) const
{
return _ctx.desc.inputs.at(ind.value())->buffer;
}

void *Execution::getOutputBuffer(ir::IOIndex ind)
{
return _ctx.desc.outputs.at(ind.value())->buffer;
}

} // namespace exec
} // namespace onert

0 comments on commit cf0fdb2

Please sign in to comment.