Nowadays, most DL frameworks (DLFs) use multilingual programming of Python and C/C++, facilitating the flexibility and performance of the DLF. However, inappropriate interlanguage interaction may introduce design smells involving multiple programming languages (PLs), i.e., Inter-Language Design Smells (ILDS). Despite the negative impact of ILDS on multi-language DLFs, there is a lack of an automated approach for detecting ILDS in multi-language DLFs and a comprehensive understanding on ILDS in such DLFs. This work automatically detects ILDS in multi-language DLFs written in the combination of Python and C/C++, and to obtain a understanding on such ILDS in DLFs. We first developed an approach to automatically detecting ILDS in the multi-language DLFs written in the combination of Python and C/C++, including a number of ILDS and their detection rules defined based on inter-language communication mechanisms and code analysis. We then developed the CPSMELL tool that implements detection rules for automatically detecting such ILDS, and manually validated the accuracy of the tool. Finally, we performed a study to evaluate the ILDS in multi-language DLFs. We proposed seven ILDS and achieved an accuracy of 98.17% in the manual validation of CPSMELL in 5 popular multi-language DLFs. The study results revealed that among the 5 DLFs, TensorFlow, PyTorch, and PaddlePaddle exhibit relatively high prevalence of ILDS; each smelly file contains around 5 ILDS instances on average, with ILDS Long Lambda Function For Inter-language Binding and Unused Native Entity being relatively prominent; throughout the evolution process of the 5 DLFs, some ILDS were resolved to a certain extent, but the overall count of ILDS instances shows an upward trend. The automated detection of the proposed ILDS achieved a high accuracy, and the study provides a comprehensive understanding on ILDS in the multi-language DLFs.
翻译:当前,大多数深度学习框架采用Python与C/C++的多语言编程模式,以兼顾灵活性与性能。然而,不恰当的跨语言交互可能引入涉及多种编程语言的设计缺陷,即跨语言设计坏味。尽管ILDS对多语言DLF存在负面影响,目前仍缺乏针对多语言DLF中ILDS的自动化检测方法,且对此类框架中的ILDS缺乏系统性认知。本研究旨在自动检测采用Python与C/C++组合编写的多语言DLF中的ILDS,并深入理解此类框架中的ILDS特征。我们首先构建了面向Python/C/C++多语言DLF的ILDS自动检测方法,基于跨语言通信机制与代码分析定义了若干ILDS及其检测规则。随后开发了实现这些检测规则的CPSMELL工具,并通过人工验证评估了工具的准确性。最后,我们对多语言DLF中的ILDS进行了实证研究。本研究提出了七类ILDS,在5个主流多语言DLF中对CPSMELL工具进行人工验证的准确率达到98.17%。研究结果表明:在5个DLF中,TensorFlow、PyTorch和PaddlePaddle的ILDS出现频率较高;每个存在坏味的文件平均包含约5个ILDS实例,其中"跨语言绑定的长lambda函数"与"未使用的本地实体"两类ILDS尤为突出;在5个DLF的演进过程中,部分ILDS得到一定程度的修复,但ILDS实例总数仍呈上升趋势。所提出的ILDS自动检测方法具有较高准确性,该研究为理解多语言DLF中的ILDS提供了全面视角。