ONE icon indicating copy to clipboard operation
ONE copied to clipboard

[onert] Investigate runtime config

Open hseok-oh opened this issue 3 years ago • 2 comments

Let's check current implementation for runtime config and find better way.

How to set runtime config?

  • Using nnfw API
    • nnfw_set_available_backends: set backend
    • nnfw_set_config: Internal API for debugging (define in nnfw_internal.h)
  • NNPackage's config file: metadata's config field
  • Setting environment variable

When runtime get config value?

  • Before model loading
    • Get from nnfw API: nnfw_set_config and nnfw_set_config
    • Read from NNPackage's config file (on model loading API)
  • Get value any time
    • Read environment variable

How to pass config to each runtime module?

  • Config util function set config string map to global variable
  • Each module read config from global variable

Why we are using environment variable?

  • For test environment
    • To maintain NNAPI test
    • To maintain easy general test
    • For easy debugging

Why we are using global variable?

  • Read configuration on backend
    • We don't have backend API to pass config value for backend
    • ex. ACL_LAYOUT, EXECUTOR
  • Configuration for compiler and executor
    • We don't have struct and interface for them

Environment variable is optional

  • When we start runtime project, we support environment variable only
  • Now environment variable is for testing and debugging
    • Runtime user may apps, and they will use nnfw API
  • Security issue - tizen release runtime is not using environment variable

hseok-oh avatar Jun 10 '22 02:06 hseok-oh

Can we remove environment variable config on runtime?

  • On most test, possible
    • Move config reading from environment variable to test binary from runtime
    • After reading environment variable, use internal API
  • Issue: NNAPI test - cannot use nnfw API

Can we remove NNAPI test?

  • Coverage issue - many operation are tested by NNAPI test

Move environment variable reading to frontend

  • Use same phase for all config method
    • Before model loading (graph construction)
    • For NNAPI
      • Read environment variable on model create?
      • Howto set config value
        • Set global variable on NNAPI frontend?
        • Pass config struct to compilation struct and compile?

hseok-oh avatar Jun 10 '22 02:06 hseok-oh

Used on CI Test

  • General test
    • DISABLE_COMPILE
    • BACKEND
    • EXECUTOR
  • Mixed test
    • OP_BACKEND_XXXX (Operator-Backend mapping)
    • ACL_LAYOUT
    • RUY_THREADS

Using modules

  • Frontend
    • USE_MMAPED_DATA
  • Core
    • GRAPH_DOT_DUMP
    • BACKENDS
    • OP_BACKEND_ALLOPS
    • OP_BACKEND_MAP
    • DISABLE_COMPILE
    • ONERT_LOG_ENABLE
    • CPU_MEMORY_PLANNER
    • EXECUTOR
    • PROFILING_MODE
    • USE_SCHEDULER
    • TRACE_FILEPATH
    • FP16_ENABLE
    • RUY_THREADS (builtin backend)
  • Backend
    • EXECUTOR
    • ACL_LAYOUT
    • RUY_THREADS
    • XNNPACK_THREADS

Appendix

  • EXECUTOR is used both core and backend
  • NCNN_LAYOUT is not used any more

hseok-oh avatar Jul 21 '22 08:07 hseok-oh