Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[luci-interpreter] Design and implement static memory planner and manager #7522

Closed
binarman opened this issue Aug 18, 2021 · 5 comments
Closed

Comments

@binarman
Copy link
Contributor

This is continuation of #7355 that should use introduced memory manager interface.

Goal

Introduce at least one static memory planner and manager suitable for MCU usage.

High level schema of interpreter setup:
interpreter_initialization

  • Static memory manager contains memory pool that it can assign to tensors on request.
  • Static memory manager do not owns memory buffer, so it is possible to use static array for this purpose.

High level interpreter algorithm:

  • Interpreter seeks for "execution order" metadata in model
    • if it is found - execute kernels in given order
    • if it is not found - execute using standard post order
  • According allocation plan interpreter asks memory manager to allocate memory for tensor.
    • static memory manager seeks into metadata stored in tensor and assigns actual memory address to a given tensor.

Rationale

  • Baremetal MCU has no OS, so we need to manage memory manually.
  • Even if we have OS (for example, MBED OS), it's memory subsystem is not optimal for neural networks domain.
    • Only dynamic allocations available (no way to plan ahead of time)
    • Poor utilization of different memory types (for example TCM on ARM-m7)
@binarman
Copy link
Contributor Author

+cc @BalyshevArtem

@BalyshevArtem
Copy link
Contributor

BalyshevArtem commented Sep 30, 2021

Brief explanation about circle-execution-plan tool

This tool takes circle file as input and returns modified circle file.
The output circle file contains "plan" (CircleNodeMemoryPlan) information for every node.

"plan" contains:

  • number which determines order in which nodes will be executed
  • memory offsets for node output tensors from the beginning of shared memory buffer

In order to record and read this metadata, we use CircleImportMetadata and CircleExportMetadata.
For this purpose we use std::map<uint32_t, std::vector<uint32_t>> _memory_plan_table which for each node with key ID contains encoded CircleNodeMemoryPlan data.

@binarman
Copy link
Contributor Author

binarman commented Nov 1, 2021

Functionality is merged, now we need to cover following code with tests:

  • luci-interpreter parts that uses static memory manager
  • circle-execution-plan tool

@seanshpark
Copy link
Contributor

1/ there is no necessities for luci-interpreter parts that uses static memory manager as onert-micro is used for MCU runtime.
2/ circle-execution-plan tool not sure what to do for this

@seanshpark
Copy link
Contributor

created left task and close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants