[single] Refactor setting tensors info in ml_single_open_custom - #661
[single] Refactor setting tensors info in ml_single_open_custom#661songgot wants to merge 1 commit into
Conversation
c3d4dcb to
2d6a094
Compare
Improve ml_single_open_custom's framework-specific in/out tensors info settings handling to a table-based approach. Improve code readability. Signed-off-by: hyunil park <hyunil46.park@samsung.com>
2d6a094 to
fe11cbf
Compare
myungjoo-bot
left a comment
There was a problem hiding this comment.
Automated review (transcribed from an AI review agent's report; please verify before acting).
Summary: The PR replaces the if (nnfw == TF || SNAP || PYTORCH || TRIX || NCNN) ... else if (nnfw == ARMNN) block in ml_single_open_custom with a static const table (requires_in_info / requires_out_info) plus a lookup loop. I compared every path against upstream/main (whose copy of this block is identical to the PR base; git merge-tree is clean): required-group frameworks still fail with ML_ERROR_INVALID_PARAMETER before any property is set when either info is missing, in/out are still set in the same order via the same helper, ARMNN still treats both as optional, and the resolved local nnfw is used as before. Behavior is equivalent; only log text changes. Non-blocking comments below.
- [Low] gst-indent violations —
c/src/ml-api-inference-single.c:1154, 1157-1158, 1164, 1166-1168, 1173: over-longstatus = ml_single_set_inout_tensors_info (...)lines (original wrapped afterstatus =), continuation indented 14 instead of 12 spaces,_ml_error_report_continuemisaligned at 1166,_ml_logi("...")missing the GNU space before(and >100 columns, and two consecutive blank lines at 1043-1044. Noteindent.shin CI only emits warnings, so this must be fixed manually with the repo's indent flags. - [Low] New
_ml_logifires on the most common path —:1172-1174: every framework not in the table (tflite, nnfw, snpe, onnx, tvm, tensorrt, qnn, llama.cpp, custom, ...) now logs "not found in tensors info table, using default behavior" on every open, which reads as if something is missing. Drop theelsebranch (matches the original) or downgrade to_ml_logdwith wording like "no tensors-info requirement for '%s'". - [Low] ARMNN diagnostics lost specificity —
:1156-1158, 1166-1168: the old ARMNN branch mentioned that infos are optional and includedfw_name; both branches now share a generic message. Return codes are unchanged. Suggest includingfw_namein the shared message. - [Low] Naming / Doxygen —
:1018-1042: typedefnnfw_tensors_infolacks the repo's_ssuffix, and the struct doc uses@paramfor members (Doxygen will warn); document members inline with/**< ... */. - [Low] Readability gain is small — the table encodes only two cases (both required / both optional) with no asymmetric entries, yet adds a struct, 6 rows, three locals, a loop, and a
found_in_tableflag (+21 lines). A small helper returning an enum would achieve the same with less machinery; fine if asymmetric requirements are anticipated. - [Low] Overlap with #651 — your open #651 extracts this exact region into helpers; whichever merges second will conflict. Consider folding this change into #651 or rebasing one on the other explicitly.
- [Info] Test coverage gap (pre-existing) — no unit test reaches the "required info missing ->
ML_ERROR_INVALID_PARAMETER" path with a valid model, so a slip in this block would pass CI. Optional follow-up: a test opening a valid model with a required-info nnfw andNULLinfos, skipped when the framework is unavailable.
No back-door or suspicious behavior found.
Improve ml_single_open_custom's framework-specific in/out tensors info settings handling to a table-based approach.
Improve code readability.