Skip to content

chore: remove unused sam3_bbox_mlp, sam3_params::seed, SAM3_VISUAL enum - #21

Merged
PABannier merged 1 commit into
mainfrom
cleanup/remove-unused-code
Sep 16, 2026
Merged

PABannier merged 1 commit into
mainfrom
cleanup/remove-unused-code

Conversation

@PABannier

@PABannier PABannier commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

Removes code with no callers:

Symbol Why it's dead
sam3_bbox_mlp (static) never called
sam3_params::seed never read (tc.seed in tests/test_metal_conv_transpose_2d.cpp is an unrelated local struct)
SAM3_MODEL_SAM3_VISUAL never assigned, so sam3_get_model_type() never returns it. Visual-only SAM3 still reports SAM3_MODEL_SAM3, and sam3_is_visual_only() returns true. The other enum values keep their explicit numbers.

Kept: sam3_state_set_orig_dims. An earlier revision of this PR removed it, which was only safe on top of #20 (remove tests/). #20 is closed, so tests/test_sam2_pvs_compare.cpp still calls the function through an extern declaration and it has to stay.

Rebased onto main; no longer stacked on anything.

Verification: a Release build with -DSAM3_BUILD_TESTS=ON builds the library, all examples and all 43 test targets with no errors or new warnings.

Output is unchanged: a parity tool runs encode, PVS point + box, and a 3-frame visual track, then compares byte for byte against main.

PARITY OK   edgetam_f16 gpu0
PARITY OK   edgetam_f16 gpu1
PARITY OK   sam2.1_hiera_tiny_q8_0 gpu0
PARITY OK   sam2.1_hiera_tiny_q8_0 gpu1

git diff --shortstat main: 2 files changed, 15 deletions(-).

Part of an over-engineering cleanup series.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M2qLmQ9ag49hT61V6i9qAq

Comment thread sam3.cpp
__func__, eis, hp.img_size, state->encode_feat_size, hp.feat_size());
}

return state;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase on main, and check the change is still useful.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased onto main (base retargeted from the closed cleanup/remove-test-api), and you were right to ask — one of the four removals is no longer valid.

Since #20 was closed, tests/ stays on main, and tests/test_sam2_pvs_compare.cpp:15 declares sam3_state_set_orig_dims via extern and calls it at line 49. I've kept that function; removing it would break the tests build.

The other three are still dead on current main:

Symbol Check
sam3_bbox_mlp git grep -w sam3_bbox_mlp → only its own definition
sam3_params::seed only the field declaration; tc.seed in test_metal_conv_transpose_2d.cpp is a different local struct
SAM3_MODEL_SAM3_VISUAL only the enumerator; never assigned, so sam3_get_model_type() never returns it

Now 15 deletions across 2 files, down from 20.

Verified: a Release build with -DSAM3_BUILD_TESTS=ON builds the library, all examples and all 43 test targets with no errors or new warnings. Output is unchanged too — encode, PVS point + box, and a 3-frame visual track match main byte for byte on EdgeTAM f16 and SAM2.1-tiny q8_0, CPU and Metal (PARITY OK ×4).

- sam3_bbox_mlp: static, never called.
- sam3_params::seed: never read.
- SAM3_MODEL_SAM3_VISUAL: never assigned, so sam3_get_model_type can't
  return it. Visual-only SAM3 still reports SAM3_MODEL_SAM3 +
  sam3_is_visual_only(). Remaining enum values keep their numbers.

sam3_state_set_orig_dims is kept: tests/test_sam2_pvs_compare.cpp calls
it through an extern declaration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M2qLmQ9ag49hT61V6i9qAq
@PABannier
PABannier force-pushed the cleanup/remove-unused-code branch from 20b938a to 6b653a5 Compare September 16, 2026 19:08
@PABannier PABannier changed the title chore: remove unused sam3_bbox_mlp, set_orig_dims, seed, SAM3_VISUAL enum chore: remove unused sam3_bbox_mlp, sam3_params::seed, SAM3_VISUAL enum Sep 16, 2026
@PABannier
PABannier changed the base branch from cleanup/remove-test-api to main September 16, 2026 19:08
@PABannier
PABannier merged commit d173aa9 into main Sep 16, 2026
3 checks passed
@PABannier
PABannier deleted the cleanup/remove-unused-code branch September 16, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant