Refactor, cleanup, add reference fallbacks for CMSIS_NN MAXIMUM_MINIMUM kernel

Abierto
#3,974 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
54/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
embedded-iot

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
C++
Estrellas
3.1k
Forks
1.1k
Merge medio
1 d 48 min
PR fusionados (30 d)
83

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tensorflow/tflite-micro

Todos los issues de tensorflow/tflite-micro

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.