Page 105 - 《软件学报》2026年第2期
P. 105

软件学报 ISSN 1000-9825, CODEN RUXUEW                                        E-mail: jos@iscas.ac.cn
                 2026,37(2):584−600 [doi: 10.13328/j.cnki.jos.007451] [CSTR: 32375.14.jos.007451]  http://www.jos.org.cn
                 ©中国科学院软件研究所版权所有.                                                          Tel: +86-10-62562563



                                                                        *
                 基于领域知识图谱的框架间                      AI 源码自动迁移

                 丁    嵘  1 ,    刘屹洲  2 ,    王雨倩  2 ,    李一錡  1


                 1
                  (北京航空航天大学 人工智能研究院, 北京 100191)
                 2
                  (北京航空航天大学 计算机学院, 北京 100191)
                 通信作者: 丁嵘, E-mail: dingr@buaa.edu.cn

                 摘 要: 作为人工智能的基础设施, 深度学习框架已经成为人工智能实现跨越发展的重要突破口. 但是由于缺乏统
                 一标准, 不同框架的兼容水平较差. 忠实模型转换通过将源模型迁移为另一种目标框架下的等价模型, 来增强框架
                 间的互操作性. 然而, 深度学习框架数量较多且相互间差异较大, 并且自主框架的需求逐渐增多, 互相转换成本较
                 高. 因此, 提出基于领域知识图谱的框架间            AI 源码自动迁移方法. 该方法基于领域知识图谱和抽象语法树来系统
                 地处理迁移挑战, 首先将源代码转换为特定的抽象语法树, 提取通用依赖信息和特定算子信息, 然后再利用存储在
                 领域知识图谱中的框架间算子及参数映射关系来迁移到目标框架下, 形成目标框架下的目标模型代码, 大大降低
                 了工程复杂度. 对比同类型的代码迁移工具, 所提方法可以在国内外流行深度学习框架如                            PyTorch、PaddlePaddle
                 和  MindSpore 之间进行互相迁移, 达到了较好的成熟度和质量, 部分成果已经开源到百度官方迁移工具                        PaConvert 中.
                 关键词: 深度学习框架; 代码迁移; 知识图谱; 抽象语法树
                 中图法分类号: TP311

                 中文引用格式: 丁嵘, 刘屹洲, 王雨倩, 李一錡. 基于领域知识图谱的框架间AI源码自动迁移. 软件学报, 2026, 37(2): 584–600. http://
                 www.jos.org.cn/1000-9825/7451.htm
                 英文引用格式: Ding R, Liu YZ, Wang YQ, Li YQ. Automatic Migration of AI Source Code Between Frameworks Based on Domain
                 Knowledge Graph. Ruan Jian Xue Bao/Journal of Software, 2026, 37(2): 584–600 (in Chinese). http://www.jos.org.cn/1000-9825/7451.
                 htm

                 Automatic Migration of AI Source Code Between Frameworks Based on Domain Knowledge
                 Graph
                                                  2
                                     2
                          1
                 DING Rong , LIU Yi-Zhou , WANG Yu-Qian , LI Yi-Qi 1
                 1
                 (Institute of Artificial Intelligence, Beihang University, Beijing 100191, China)
                 2
                 (School of Computer Science and Engineering, Beihang University, Beijing 100191, China)
                 Abstract:  As  the  foundation  of  AI,  deep  learning  frameworks  play  a  vital  role  in  driving  the  rapid  progress  of  AI  technologies.  However,
                 due  to  the  lack  of  unified  standards,  compatibility  across  different  frameworks  remains  limited.  Faithful  model  transformation  enhances
                 interoperability  by  converting  a  source  model  into  an  equivalent  model  in  the  target  framework.  However,  the  large  number  and  diversity
                 of  deep  learning  frameworks,  combined  with  the  increasing  demand  for  custom  frameworks,  lead  to  high  conversion  costs.  To  address  this
                 issue,  this  study  proposes  an  automatic  AI  source  code  migration  method  between  frameworks  based  on  a  domain  knowledge  graph.  The
                 method integrates domain knowledge graphs and abstract syntax trees to systematically manage migration challenges. First, the source code
                 is  transformed  into  a  framework-specific  abstract  syntax  tree,  from  which  general  dependency  information  and  operator-specific  details  are
                 extracted.  By  applying  the  operator  and  parameter  mappings  stored  in  the  domain  knowledge  graph,  the  code  is  migrated  to  the  target
                 framework,  generating  equivalent  target  model  code  while  significantly  reducing  engineering  complexity.  Compared  with  existing  code
                 migration  tools,  the  proposed  method  supports  mutual  migration  among  widely  used  deep  learning  frameworks,  such  as  PyTorch,


                 *    基金项目: 科技创新  2030—“新一代人工智能”重大项目    (2021ZD0110600); 百度合作项目  (Z231100010323007); 华为合作项目
                  (22081500805582B)
                  收稿时间: 2024-06-06; 修改时间: 2024-08-07, 2024-10-19, 2025-03-25; 采用时间: 2025-04-23; jos 在线出版时间: 2025-09-24
                  CNKI 网络首发时间: 2025-09-25
   100   101   102   103   104   105   106   107   108   109   110