Manuscript Offprint
arXiv:2610.29617TernScope: Model-Hardware Co-Design for Efficient Ternary Endoscopic Segmentation
Zhuoyu Wu, Wenhui Ou, Qiawei Zheng, Xuhong Qiu, Wenqi Fang, Raphael C.-W. Phan
CyPhi AI Research Lab, School of Information Technology, Monash University Malaysia, Malaysia
Department of Electronic and Computer Engineering, The Hong Kong University of Science and Technology, Hong Kong
Shenzhen Institutes of Advanced Technology, Chinese Academy of Sciences, Shenzhen, China
School of Computer Science and Engineering, Southeast University, Nanjing, China
*Corresponding author: Zhuoyu Wu (zhuoyu.wu@monash.edu)
Code and experiments: https://github.com/ReaganWu/TernScope
Abstract—Edge medical segmentation must reconcile small model size, high accuracy, and fast inference. TernScope addresses this tradeoff through model–hardware co-design, learning a compact segmentation network whose low-bit operators also simplify hardware execution. Split-channel large-kernel blocks preserve spatial context with limited computation, while branch fusion removes redundant inference paths. Ternary Progressive Quantization-aware Training (TPQ) then adapts the fused network from deep to shallow layers, through the decoder, and finally to the input and prediction layers. All 25 convolutions use ternary weights and 8-bit activations, enabling packed storage and multiplier-free computation. The resulting model uses 0.2483M parameters and 0.0949 GMACs while retaining competitive segmentation accuracy on in-domain and external datasets. Under the same 45 nm technology, TernScope reduces compute-array area by 88.46% compared with the original Gemmini, a systolic-array accelerator with 8-bit × 8-bit multipliers. These results demonstrate a path from accurate lightweight medical segmentation to compact low-bit hardware.
Index Terms—Model–hardware co-design, endoscopic segmentation, ternary neural networks, structural re-parameterization.
I. INTRODUCTION
Medical image segmentation at the edge faces a model size–accuracy–inference speed trilemma: a deployable model must fit limited memory, delineate lesions accurately, and deliver predictions promptly [1]–[3]. Reducing network width or spatial processing can save resources, but also restrict the contextual information available for segmentation [4], [5]. The goal is therefore to retain strong segmentation capacity within a small, fast model. For endoscopic applications, this requires treating predictive quality and deployment cost as joint design objectives.
A compact network does not automatically translate into fast inference or a small accelerator. Execution also depends on memory access, operator organization, and the target architecture [6]–[8]. Structural re-parameterization helps by merging expressive training branches into efficient inference operators [9], [10]. Numerical precision provides a complementary design dimension: low-bit operands reduce tensor storage and simplify arithmetic [11]–[13]. Combining these choices makes full-network ternary weight quantization an opportunity to address the trilemma at both model and circuit levels, provided segmentation accuracy can be retained.
TPQ (Ternary Progressive QAT)
Stage I: Lightweighting
Step 1: BN Fusion with CNN
Step 2: Merge CNN Branches

TernScope-Net
[Training-Mode]
(FP32-Trained)
SRP
TernScope-Net
[Efficient-Mode]
(FP32-Trained)
Stage II: Progressive Ternary QAT

Fig. 1. TernScope training-to-deployment pipeline. Branch fusion removes redundant inference paths; TPQ adapts the fused graph to W2A8, including the stem and head.
The central challenge is to make a compact segmentation graph learn effectively under ternary constraints. Learned quantization scales and incremental conversion provide complementary ways to adapt networks to reduced precision [14], [15]. Branch fusion changes the effective kernels, so quantizing separate training branches need not yield the same operator as quantizing their sum. Leaving the stem or prediction head at higher weight precision also retains heterogeneous convolution requirements. We instead adapt the fused deployment graph through Ternary Progressive QAT (TPQ), extending ternary weights to every convolution while retaining 8-bit activations.
TernScope realizes this model-led co-design in three connected steps (Fig. 1). SplitLK allocates large-kernel processing to a channel subset, and a narrow decoder fuses multi-scale

Fig. 2. TernScope-Net and its main components. SplitLK combines a split-channel large-kernel path with a bypass and pointwise mixing. RepLK training branches are fused into a single deployment convolution. The Nearest Unifier combines projected features from four encoder scales.
features. Branch fusion removes redundant execution paths before TPQ learns the final low-bit operators. A corresponding ternary array then translates the model's numerical representation into simpler computation.
We present TernScope, a fully ternary-weight segmentation framework that jointly addresses model complexity, segmentation accuracy, and hardware efficiency. With 0.2483 M parameters and 0.0949 GMACs, TernScope outperforms its FP32 reference across all three datasets. Using ternary PEs and shared arithmetic resources, it reduces compute-array area, synthesized standard-cell area, and estimated logic power by 88.46%, 70.28%, and 62.82%, respectively, compared with the original Gemmini [7].
A. SplitLK: Spatial Context at Low Cost
Large kernels expand spatial context [16]. TernScope-Net separates spatial coverage from channel width (Fig. 2). Its four encoder stages use 32/64/96/128 channels, while spatial convolutions process only 16/16/16/32 channels. The remaining channels bypass spatial processing and rejoin the transformed features before a pointwise mixer. For input width C and processed width , the dense spatial term falls from to ; pointwise mixing then exchanges information across all channels. For example, processing 32 of 128 channels reduces this spatial term to 1/16 of its full-width counterpart; the pointwise cost remains. Large kernels of size 5, 7, and 9 operate at resolution or below, where wider context is less expensive.
B. Nearest Unifier: Narrow Multi-Scale Fusion
The Nearest Unifier projects all four encoder scales to 16 channels. Nearest-neighbor resizing aligns the features for addition and convolutional refinement. The three deeper features are combined and refined before fusion with the shallow feature, so the decoder introduces semantic context before recovering fine detail. Addition keeps the fused width at 16 channels instead of growing it through concatenation. Nearest-neighbor resizing requires no learned upsampling weights. Convolutions learn spatial refinement, while dense kernels and channel widths aligned to 16 suit a common array.
C. Fuse First, Then Learn Ternary Execution
The FP32 model is first converted to its deployment topology. Batch normalization is folded into each RepLK branch, giving , and the branches are merged as
where center-pads kernels and represents the identity by a centered identity kernel. Nonlinearities remain outside the merged branches. Fusion preserves the linear operation and removes intermediate branch execution. Since quantization is nonlinear, TPQ adapts the merged kernels rather than independently quantizing branches that disappear at deployment.
For output channel c, the ternary weight quantizer is
FP master weights and channel scales use fake quantization with straight-through gradients. Activations remain A8, while bias, scaling, and accumulation use wider precision. Feature additions preserve rounding and saturation boundaries.
TPQ follows three phases (Fig. 1). The first 5% adapts the fused model in W8A8. Over the next 35%, weights transition to ternary from deep to shallow encoder stages, then skip projections, decoder, input convolution, and segmentation head.
TABLE I
SEGMENTATION QUALITY AND CROSS-DATASET TRANSFER AFTER TRAINING ON KVASIR-SEG (256 × 256).
| Model | Year | Complexity | W/A | Kvasir-SEG | K → ClinicDB | K → ColonDB | ||||
|---|---|---|---|---|---|---|---|---|---|---|
| Params (M)↓ | GMACs↓ | Dice↑ | IoU↑ | Dice↑ | IoU↑ | Dice↑ | IoU↑ | |||
| U-Net [17] | 2015 | 31.0317 | 48.1670 | 32/32 | 0.8208 | 0.7303 | 0.6791 | 0.5849 | 0.5360 | 0.4471 |
| UNeXt [1] | 2022 | 1.4719 | 0.5620 | 32/32 | 0.7385 | 0.6435 | 0.5207 | 0.4274 | 0.3785 | 0.2999 |
| Mobile-PolypNet [2] | 2022 | 0.2239 | 1.1380 | 32/32 | 0.5974 | 0.4720 | 0.4390 | 0.3269 | 0.2711 | 0.1887 |
| EGE-UNet [18] | 2023 | 0.0534 | 0.0720 | 32/32 | 0.5882 | 0.4611 | 0.4464 | 0.3276 | 0.2804 | 0.1950 |
| CMUNeXt-S [4] | 2024 | 0.4175 | 1.0120 | 32/32 | 0.7120 | 0.6076 | 0.5029 | 0.3954 | 0.3148 | 0.2436 |
| TinyU-Net [5] | 2024 | 0.4811 | 1.5610 | 32/32 | 0.7329 | 0.6286 | 0.5201 | 0.4329 | 0.2768 | 0.2194 |
| U-RWKV-s [19] | 2025 | 0.4704 | 32/32 | 0.6727 | 0.5608 | 0.4895 | 0.3795 | 0.2752 | 0.2035 | |
| DAG-UNet [20] | 2025 | 0.7358 | 0.7760 | 32/32 | 0.6785 | 0.5565 | 0.4908 | 0.3781 | 0.2484 | 0.1778 |
| ESEUNet-ESK [21] | 2026 | 0.1789 | 3.5190 | 32/32 | 0.7693 | 0.6775 | 0.5776 | 0.4759 | 0.4113 | 0.3333 |
| TernScope-Net (Ours) | — | 0.2483 | 0.0949 | 2/8 | 0.8158 | 0.7247 | 0.7291 | 0.6290 | 0.5945 | 0.5015 |
K: Kvasir-SEG, the only training dataset. target: external evaluation without fine-tuning. Test sizes: 200 / 612 / 380. Scores are per-image means at threshold 0.5; bold/underline denote best/second-best. Ours uses progressive W2A8 QAT without distillation; its parameter count excludes quantization scales. MACs count convolution, linear layers, and matrix multiplication at batch 1, excluding normalization, activation, and interpolation. WKV operators are excluded; 0.974 GMACs is partial.

Fig. 3. Qualitative transfer from Kvasir-SEG to ClinicDB (top) and ColonDB (bottom), without target-domain fine-tuning. Green and blue overlays indicate ground truth and predictions, respectively. Boxed regions are enlarged in the insets.
TABLE II
RE-PARAMETERIZATION AND TERNARY QUANTIZATION ABLATION.
| Configuration | Params (M) | GMACs | Metric | Perf. (A / B / C)↑ |
|---|---|---|---|---|
| Multi-branch FP32 | 0.3233 | 0.1064 | Dice IoU | (0.8102/0.7142/0.5532)(0.7218/0.6161/0.4630) |
| Re-parameterized FP32 | 0.2483 | 0.0949 | Dice IoU | (0.8102/0.7142/0.5532)(0.7218/0.6161/0.4630) |
| Ternary PTQ | 0.2483 | 0.0949 | Dice IoU | (0.0002/0.0004/0.0007)(0.0002/0.0004/0.0007) |
| Direct ternary QAT | 0.2483 | 0.0949 | Dice IoU | (0.8075/0.7029/0.5636)(0.7148/0.5998/0.4717) |
| Ternary Progressive QAT (TPQ, Ours) | 0.2483 | 0.0949 | Dice IoU | (0.8158/0.7291/0.5945)(0.7247/0.6290/0.5015) |
A: Kvasir-SEG test (200); B: CVC-ClinicDB (612); C: CVC-ColonDB (380). K: Kvasir-SEG; training on K only, no target fine-tuning. W/A bits: FP32 (32/32), ternary (2/8). Costs: input; Params exclude quantization scales; bold: ours.
All 25 convolutions are ternary by , with the remaining training the W2A8 graph. Transitions use scale recalibration and brief reduced-learning-rate adaptation. Activation scales are frozen after final adaptation, and validation Dice selects checkpoints only from the fully W2A8 phase.
III. MODEL-TO-HARDWARE MAPPING
TernScope adopts a Gemmini-based architecture comprising a ternary PE array, an accumulator buffer, and a shared Affine & Quantization Engine, as shown in Fig. 4. Weights and activations are loaded into on-chip buffers. The PE array performs convolution, while the shared engine handles post-processing and multi-scale feature addition.
The model exposes two forms of efficiency: fewer operations after fusion and simpler arithmetic after ternarization. Each ternary weight selects , zero, or for accumulation, eliminating general multipliers from the PE product path. Wider partial sums preserve the convolution range, followed by per-channel scaling and bias addition.
Packed W2 weights use 1/4 of W8 payload, while A8 keeps feature storage and transfers narrow. The Affine & Quantization Engine performs output post-processing. Operand selection feeds shared multipliers, followed by bias addition for convolution or summation of scaled features for two-source Add. Round-to-nearest-even and saturation produce 8-bit outputs, preserving quantization boundaries. Sparse accelerators exploit zero operands to reduce computation and transfers [22], motivating further use of ternary weight sparsity.

Fig. 4. Hardware mapping of the W2A8 deployment graph. A ternary array executes sign selection and accumulation, while the shared affine and quantization path supports convolution outputs and multi-scale feature addition.
IV. EXPERIMENTAL RESULTS
A. Evaluation Protocol
Training uses Kvasir-SEG [23] only, split into 720/80/200 training/validation/test images. ClinicDB (612) [24] and ColonDB (380) [25] evaluate transfer without fine-tuning. RGB inputs are , normalized to ; augmentation includes flips, right-angle rotations, color adjustment, and Gaussian blur. Images and masks use bilinear and nearest-neighbor resizing, respectively. Baselines use Adam, batch 16, learning rate , and binary cross-entropy plus soft Dice loss for 200 epochs. TPQ uses FP32 initialization, AdamW, batch 2, a base learning rate of , and 200 epochs without distillation. Validation Dice selects checkpoints. Metrics average per-image scores at threshold 0.5. MACs count convolution, linear layers, and matrix multiplication at batch 1; Table I notes the partial WKV count.
B. Segmentation Quality and Quantization Ablation
Table I shows a favorable accuracy–cost tradeoff. TernScope uses approximately 1/125 of U-Net's parameters and 1/508 of its MACs, with in-domain Dice within 0.51 percentage points and external Dice higher by 5.00 and 5.85 points. Smaller parameter count alone does not explain this result: EGE-UNet and Mobile-PolypNet have fewer parameters, yet lower overlap scores. TernScope retains spatial context within a compact W2A8 graph, with the strongest cross-dataset Dice and IoU among the evaluated models. Fig. 3 provides matched examples and enlarged boundary regions.
Table II separates structural simplification from low-bit adaptation. Fusion removes 23.21% of parameters and 10.78% of MACs while preserving FP32 overlap scores. The resulting model does not tolerate ternary PTQ: segmentation collapses despite unchanged topology. QAT restores useful predictions, and TPQ improves external Dice over direct QAT by 2.62 and 3.09 points. It also exceeds the FP32 reference on all three datasets. Low-bit adaptation is therefore essential to exploiting the fused topology.
C. From Low-Bit Features to Implementation Cost
Table III compares TernScope with Gemmini [7], a systolic-array accelerator configured with INT8 weights and activations. The comparison uses the same 25-convolution workload and a PE array for each design. Both designs are synthesized using Yosys/ABC with the Nangate45 45-nm standard-cell library. Compared with Gemmini, TernScope reduces compute-array area and synthesized standard-cell area by and , respectively. These reductions stem from ternary arithmetic, reduced accumulator width, and simplified control logic.
TABLE III IMPLEMENTATION COST FOR THE SAME 25-CONVOLUTION GRAPH.
| Metric | Original Gemmini | TernScope |
|---|---|---|
| Weight/Activation bitwidth (bits) | 8/8 | 2/8 |
| PE array | 16 × 16 | 16 × 16 |
| Library | Nangate45 | Nangate45 |
| Standard-cell area (mm2) | 1.816 | 0.540 |
| Compute-array area (mm2) | 0.685 | 0.079 |
| SRAM (KiB) | 320 | 344 |
| Frequency (MHz) | 100 | 100 |
| FPS | 11.902 | 102.701 |
| Logic Energy Cost (mJ/image) | 14.019 | 0.604 |
Both designs use TT, 1.1 V, 25 °C and a matched Yosys/ABC flow. Logic energy is estimated from OpenSTA vectorless power analysis.
At 100 MHz, TernScope delivers 102.701 FPS for the evaluated workload, compared with 11.902 FPS for Gemmini, an throughput improvement. Ternary weights reduce the packed weight footprint to one quarter of the INT8 representation, shrinking model storage and easing weight-transfer pressure. The ternary array also replaces general multiplications with sign selection and accumulation, reducing the logic cost of convolution.
The shared Affine & Quantization Engine further contributes to throughput by performing per-channel scaling, bias addition, multi-scale feature addition, and requantization on the accelerator. This reduces the CPU post-processing overhead present in the evaluated Gemmini mapping. For this workload, logic energy cost decreases from 14.019 to 0.604 mJ per image, a 95.690% reduction. This co-design translates ternary model compression into high throughput and low logic energy cost.
V. CONCLUSION
TernScope couples SplitLK, branch fusion, and TPQ to retain segmentation quality in a compact W2A8 graph. Cross-dataset evaluation and matched synthesis connect low-bit learning to a smaller compute array for edge endoscopy. A promising next step is to exploit zero-valued ternary weights through sparsity-aware execution and compressed storage, targeting lower computation and data-movement costs.
REFERENCES
[1] J. M. J. Valanarasu and V. M. Patel, “UNeXt: MLP-based rapid medical image segmentation network,” in Proc. MICCAI, 2022.
[2] R. Karmakar and S. Nooshabadi, “Mobile-PolypNet: Lightweight colon polyp segmentation network for low-resource settings,” J. Imaging, vol. 8, no. 6, p. 169, 2022.
[3] Z. Wu, W. Ou, L. Zhang, P.-S. Tan, D. Wu, J. Zhao, W. Fang, and R. C.-W. Phan, “DepthPolyp: Pseudo-depth guided lightweight segmentation for real-time colonoscopy,” in Pattern Recognition (ICPR 2026), ser. Lecture Notes in Computer Science, vol. 16818, 2027, pp. 357–373.
[4] F. Tang, J. Ding, Q. Quan, L. Wang, C. Ning, and S. K. Zhou, "CMUNeXt: An efficient medical image segmentation network based on large kernel and skip fusion," in Proc. IEEE Int. Symp. Biomed. Imaging (ISBI), 2024, pp. 1–5.
[5] J. Chen, R. Chen, W. Wang, J. Cheng, L. Zhang, and L. Chen, "TinyU-Net: Lighter yet better U-Net with cascaded multi-receptive fields," in Proc. MICCAI, 2024, pp. 626–635.
[6] J. Chen, S. hong Kao, H. He, W. Zhuo, S. Wen, C.-H. Lee, and S.-H. G. Chan, "Run, don't walk: Chasing higher FLOPS for faster neural networks," in Proc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit. (CVPR), 2023. [Online]. Available: https://arxiv.org/abs/2303.03667
[7] H. Genc, S. Kim, A. Amid, A. Haj-Ali, V. Iyer, P. Prakash, J. Zhao, D. Grubb, H. Liew, H. Mao, A. Ou, C. Schmidt, S. Steffl, J. Wright, I. Stoica, J. Ragan-Kelley, K. Asanovic, B. Nikolic, and Y. S. Shao, "Gemmini: Enabling systematic deep-learning architecture evaluation via full-stack integration," in Proc. Design Autom. Conf. (DAC), 2021.
[8] Y.-H. Chen, J. Emer, and V. Sze, “Eyeriss: A spatial architecture for energy-efficient dataflow for convolutional neural networks,” in Proc. ACM/IEEE Int. Symp. Comput. Archit. (ISCA), 2016, pp. 367–379.
[9] X. Ding, X. Zhang, N. Ma, J. Han, G. Ding, and J. Sun, “RepVGG: Making VGG-style ConvNets great again,” in Proc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit. (CVPR), 2021, pp. 13733–13742.
[10] Z. Wu, W. Ou, Q. Zheng, Q. Wu, D. Gao, W. Fang, C. Chen, Y. Yang, and Z. Wang, “Edge-SegStar: When bidirectional adaptive self-distillation meets biomedical segmentation on edge devices,” Biomed. Signal Process. Control, vol. 125, p. 110751, 2026.
[11] F. Li, B. Zhang, and B. Liu, “Ternary weight networks,” arXiv preprint arXiv:1605.04711, 2016.
[12] C. Zhu, S. Han, H. Mao, and W. J. Dally, “Trained ternary quantization,” in International Conference on Learning Representations, 2017. [Online]. Available: https://arxiv.org/abs/1612.01064
[13] B. Jacob, S. Kligys, B. Chen, M. Zhu, M. Tang, A. Howard, H. Adam, and D. Kalenichenko, “Quantization and training of neural networks for efficient integer-arithmetic-only inference,” in Proc. IEEE Conf. Comput. Vis. Pattern Recognit. (CVPR), 2018, pp. 2704–2713.
[14] S. K. Esser, J. L. McKinstry, D. Bablani, R. Appuswamy, and D. S. Modha, “Learned step size quantization,” in Proc. Int. Conf. Learn. Represent. (ICLR), 2020.
[15] A. Zhou, A. Yao, Y. Guo, L. Xu, and Y. Chen, “Incremental network quantization: Towards lossless CNNs with low-precision weights,” in Proc. Int. Conf. Learn. Represent. (ICLR), 2017.
[16] X. Ding, X. Zhang, Y. Zhou, J. Han, G. Ding, and J. Sun, “Scaling up your kernels to 31x31: Revisiting large kernel design in CNNs,” in Proc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit. (CVPR), 2022.
[17] O. Ronneberger, P. Fischer, and T. Brox, “U-Net: Convolutional networks for biomedical image segmentation,” in Proc. MICCAI, 2015, pp. 234–241.
[18] J. Ruan, M. Xie, J. Gao, T. Liu, and Y. Fu, “EGE-UNet: An efficient group enhanced UNet for skin lesion segmentation,” in Proc. MICCAI, 2023.
[19] H. Ye, F. Tang, P. Zhao, Z. Huang, D. Zhao, M. Bian, and S. K. Zhou, "U-RWKV: Lightweight medical image segmentation with direction-adaptive RWKV," arXiv preprint arXiv:2507.11415, 2025.
[20] Y. He, Q. Zhang, and M. E. Miquel, “DAG-UNet: Dissimilarity-aware global context guided lightweight UNet for medical image segmentation,” in Proc. IEEE Int. Symp. Biomed. Imaging (ISBI), 2025.
[21] X. Yu, M. Liang, Q. Zeng, Z. Ren, C. Kang, C. Jiang, G. Chen, B. Liang, B. Pu, N. Zhu, G. Tan, F. Liu, Y. Zhao, S. Ouyang, S. Li, and Y. Yuan, "ESE-UNet: An extremely simple yet efficient UNet for medical image segmentation," Biomed. Signal Process. Control, vol. 112, p. 108634, 2026.
[22] A. Parashar, M. Rhu, A. Mukkara, A. Puglielli, R. Venkatesan, B. Khailany, J. Emer, S. W. Keckler, and W. J. Dally, “SCNN: An accelerator for compressed-sparse convolutional neural networks,” in Proc. ACM/IEEE Int. Symp. Comput. Archit. (ISCA), 2017.
[23] D. Jha, P. H. Smedsrud, M. A. Riegler, P. Halvorsen, T. de Lange, D. Johansen, and H. D. Johansen, “Kvasir-SEG: A segmented polyp dataset,” in Proc. MultiMedia Modeling (MMM), 2020, pp. 451–462.
[24] J. Bernal, F. J. Sánchez, G. Fernández-Esparrach, D. Gil, C. Rodríguez, and F. Vilariño, “WM-DOVA maps for accurate polyp highlighting in colonoscopy: Validation vs. saliency maps from physicians,” Comput. Med. Imaging Graph., vol. 43, pp. 99–111, 2015.
[25] J. Bernal, J. Sánchez, and F. Vilariño, “Towards automatic polyp detection with a polyp appearance model,” Pattern Recognit., vol. 45, no. 9, pp. 3166–3182, 2012.