arXiv:2609.04881cs.LGSep 2026

Manuscript Offprint

arXiv:2609.04881

From Deep to Shallow: Unconstrained and Efficient Layer Merging Strategy

Petro Shulzhenko, Gabriele Spadaro, Enzo Tartaglione

Petro Shulzhenko¹[0009-0001-6278-5881], Gabriele Spadaro¹,²[0009-0008-4786-1074], and Enzo Tartaglione¹[0000-0003-4274-8298]

¹ LTCI, Télécom Paris, Institut Polytechnique de Paris, Palaiseau, France {name.surname}@telecom-paris.fr ² University of Turin, Italy gabriele.spadaro@unito.it

Abstract. Although Deep Neural Networks have become foundational in many areas of Machine Learning, high computational demands limit their application in resource-constrained environments. To address this issue, depth compression methods have been proposed to identify and linearize redundant activation functions, thereby allowing for the merging of layers without intermediate non-linearities. However, these methods face two key challenges: they cannot be directly applied to convolutions with padding due to the absence of an analytical solution for merging these layers, and they typically increase the kernel size of merged layers, thus limiting speed-up gains. To overcome these limitations, we propose an efficient strategy that enables merging of layers without an existing analytical solution, and also without increasing kernel size. We validate our approach across multiple architectures and datasets, and measure inference speed-up gains on real embedded platforms. We publicly released the code at https://github.com/ShulzhenkoPetr/deep-to-shallow.

Keywords: Deep learning · model compression · layer merging · efficiency.

1 Introduction

Deep Neural Networks (DNNs) have become a cornerstone of progress in computer vision, natural language processing, robotics, bioinformatics, and other fields. Their remarkable capabilities in approximating complex non-linear functions are primarily attributed to the models' depth and size [7,14,27,28]. However, these same properties make training and inference computationally demanding, increasing latency, hardware costs, energy consumption, and environmental impact. This limits the deployment of DNNs in resource-constrained settings [3,11,23], motivating a broad line of work on model compression and efficient inference [1,5,10,19,26,31].

This article has been accepted for publication at the ITEM Workshop of the European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECML PKDD 2026).

P. Shulzhenko, G. Spadaro, and E. Tartaglione

Figure

Fig. 1. Accuracy vs. speed-up for ResNet18 on ImageNet-1k. Unlike the Reference model, the proposed Shrunk model converts additional linearized activations into actual speed-up while preserving accuracy.

Among compression strategies, depth compression reduces model depth by identifying redundant non-linear activations, replacing them with identity mappings, and merging the resulting consecutive linear operations [16, 17, 22]. Yet, existing approaches face two practical limitations. First, analytical solutions for merged weights are unavailable for several common convolutional configurations, such as when the second convolution uses non-zero padding. Second, even when analytical merging is possible, the equivalent convolution may require a larger kernel, which can reduce or cancel the expected inference speed-up [21]. As shown in Figure 1, simply increasing the number of linearized activations does not improve inference time unless the corresponding blocks are effectively merged.

In this paper, we address this limitation with a loss-based layer merging strategy guided by the original linearized model, referred to as the Reference model. Instead of relying on input-independent analytical formulas, our method learns compact replacement layers that approximate both local activations and global predictions. This enables layer merging under arbitrary configurations, including padding, stride, dilation, and different kernel sizes, while avoiding the kernel growth that can limit speed-up. The resulting Shrunk model achieves increasing inference acceleration as more activations are linearized, with minimal, and in some cases no, accuracy degradation.

The contributions of this work can be summarized as follows.

– We introduce a generic merging strategy that applies independently of the activation linearization method, supports cases where no closed-form analytical solution is available, and avoids kernel-size growth (Table 3).

– We show that our method achieves performance close to analytical merging when such a solution exists, even with smaller and more efficient kernels (subsection 4.2).

– We validate the approach across architectures, datasets, and hardware platforms, showing inference speed-ups on NVIDIA GeForce RTX 2080 Ti, NVIDIA Jetson Orin, and Raspberry Pi 5 with marginal or no accuracy loss (subsection 4.3).

References (32)