## 6 Conclusions and Future Work
By jointly applying uniform quantization and unstructured pruning to both the weights and activations of the DNN, we achieve a higher performance density (PD) with higher compression rates than existing solutions and comparable network performance. across a range of discriminative and generative networks. The resulting neural networks can be efficiently accelerated by resource-constrained hardware platforms such as edge GPUs and FPGAs. In future work, we aim to focus more closely on applying our framework to generative models and explore advanced quantization-aware training techniques to work jointly with our nonparametric greedy layerwise channel pruning algorithm. Software and experiments--X.Z. ; writing, formal analysis, and visualization--X.Z., I.C. and S.D. All authors have read and agreed to the published version of the manuscript. This research received no external funding. Not applicable. Publicly available datasets were analyzed in this study. These data can be found in [42; 45]. Pre-trained models and configuration files are provided at: [[https://github.com/mlzxy/mdpi2022](https://github.com/mlzxy/mdpi2022)]([https://github.com/mlzxy/mdpi2022](https://github.com/mlzxy/mdpi2022)) (accessed on 30 June 2022). This work was supported in part by NSF awards CNS1730158, ACI-1540112, ACI-1541349, OAC-1826967, the University of California Office of the President, and the California Institute for Telecommunications and Information Technology's Qualcomm Institute (Calit2-QI). The authors declare no conflict of interest. The code for each algorithm introduced in this paper can be found in our Python library, qsparse, at [[https://github.com/mlzxy/qsparse](https://github.com/mlzxy/qsparse)]([https://github.com/mlzxy/qsparse](https://github.com/mlzxy/qsparse)) (accessed on 30 June 2022). In Listing A1, we provide an example of how to use our algorithms for quantization and pruning as PyTorch modules [47]. Examples of our software interface for quantization and pruning on activations. ```
importtorch.nnasm fromqsparseimportprune,quantize ifactivationpruningandquantization nn.Sequential( nn.Conv2(10,30,3), prune(sparsity=0.5),#pruningmodule quantize(bits=5)#quantizationmodule )
```  
The majority of existing model compression Python libraries provide either quantization [62; 63; 64] or pruning [18] support. In contrast, the simplicity of our framework enables an efficient software interface that supports a wide range of neural network architectures for both pruning and quantization. To improve the library flexibility, we introduce a technique that directly transforms the weight attribute of the input layer into a pruned or quantized version at runtime, as shown in Listing A2. Thus, our library is layer-agnostic and can work with any PyTorch module as long as their parameters can be accessed from their weight attribute, as is standard practice [47]. Listing A2 An illustration of the technique we use to create weight-quantized modules without modifying the internal implementation of specific modules. By injecting the weight property, we are able to automatically apply quantization or pruning at each access of weight. By chaining transformations for both prune and quantize, we create modules with weights that are jointly pruned and quantized. ```
defcreate_general_quantized_module(mod:nm.Module): OriginClass=mod.__class__ classWrapper(OriginClass): @property defweight(self): returnquantize(getattr(OriginClass, \"weight\").__get__(self)) Wrapper.__name__=OriginClass.__name__ mod__class__=Wrapper returnmod
```  
Based on our custom modules and transformation technique, we provide the network conversion function, as shown in Listing A3, in which we traverse the entire network and automatically modify the computational graph to the aim of pruning and quantization. For each network in our experiments, we apply different conversions on top of the baseline network to the requirements of evaluation. **Listing A3**.