Refactor, cleanup, add reference fallbacks for CMSIS_NN MAXIMUM_MINIMUM kernel

Aperta
#3,974 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
embedded-iot

Direzione di ricerca

Start with tensorflow/lite/micro/kernels/cmsis_nn/maximum_minimum.cc and compare its Eval functions with the reference and Xtensa implementations. Trace shape preparation through Init, Prepare, and OpData, then check the CMSIS-NN status handling. Run the maximum/minimum kernel tests, including Int8With5DBroadcastTest; done means the int8 fallback handles tensors above 4D and the requested refactor and checks are covered.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

type:cleanup

@tensorflow/micro,

Follow-up from review discussion on #3965.

Currently, tensorflow/lite/micro/kernels/cmsis_nn/maximum_minimum.cc has several limitations and cleanup opportunities:

  1. Missing reference fallback for >4D tensors:

    • FillVariableShape() unconditionally calls RuntimeShape::ExtendedShape(4, shape) at the top of Eval* (even before switching on tensor type), which triggers a TFLITE_DCHECK_LE failure when any input/output tensor has >4 dimensions (arm_maximum_s8 / arm_minimum_s8 only support up to 4D cmsis_nn_dims).
    • For >4D kTfLiteInt8 tensors, the kernel should fall back to TFLiteOperation<int8_t, OpType> (reference_ops::MaximumMinimumBroadcastSlow) instead of failing.
    • Once supported, remove the #if !defined(CMSIS_NN) guard around Int8With5DBroadcastTest in tensorflow/lite/micro/kernels/maximum_minimum_test.cc.
  2. Refactor duplicated Eval functions and redundant tensor lookups:

    • Deduplicate EvalMaximum, EvalMinimum, EvalMaximumInt8, and EvalMinimumInt8 using templates (OpType), matching the reference and Xtensa maximum_minimum.cc implementations.
    • Reuse tensors already fetched by OpContext instead of calling GetEvalInput / GetEvalOutput a second time.
  3. Move shape preparation to Prepare and check return status:

    • Precompute cmsis_nn_dims (and fallback flag) in Init / Prepare via OpData rather than recomputing shapes during Eval (and avoid computing cmsis_nn_dims for non-int8 types).
    • Check the arm_cmsis_nn_status return value of arm_maximum_s8 and arm_minimum_s8 instead of ignoring it.
    • Clean up unused #include headers.
Lingua principale
C++
Stelle
3.1k
Fork
1.1k
Merge medio
1g 48m
PR unite (30g)
83

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tensorflow/tflite-micro

Tutte le issue di tensorflow/tflite-micro

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.