Deep learning framework adaptation method and apparatus, computer device, and storage medium

By acquiring the operational information and requirements of heterogeneous accelerators, modifying the source code of the deep learning framework and third-party library code, and conducting evaluation and verification, the compatibility issues between the deep learning framework and heterogeneous accelerators were resolved, and stable operation on heterogeneous accelerators was achieved.

CN117273171BActive Publication Date: 2026-06-02DAWNING INT INFORMATION IND CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DAWNING INT INFORMATION IND CO LTD
Filing Date
2023-09-25
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

There is a poor compatibility issue between deep learning frameworks and heterogeneous accelerators, which prevents deep learning frameworks from running stably on heterogeneous accelerators.

Method used

By obtaining the operational information and requirements of heterogeneous accelerators, we modified the source code of the deep learning framework and the code of third-party libraries, and conducted evaluation and verification to ensure compatibility and correctness.

Benefits of technology

It improves the compatibility and stability between deep learning frameworks and heterogeneous accelerators, ensuring the correct operation of deep learning frameworks on heterogeneous accelerators.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117273171B_ABST
    Figure CN117273171B_ABST
Patent Text Reader

Abstract

The application relates to a deep learning framework adaptation method and device, computer equipment and a storage medium. The method comprises the following steps: obtaining running information and running requirements of a heterogeneous accelerator; wherein the running information and the running requirements both represent information when the heterogeneous accelerator executes a target deep learning framework to perform a calculation task; modifying source code of the target deep learning framework according to the running information, modifying three-party library code of the target deep learning framework according to the running requirements, and then evaluating and verifying the modified deep learning framework; if the modified deep learning framework passes the evaluation and verification, the modified deep learning framework is determined as a deep learning framework adapted to the heterogeneous accelerator. The method improves the compatibility between the deep learning framework and the heterogeneous accelerator, so that the deep learning can stably run on the heterogeneous accelerator.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computing technology, and in particular to a method, apparatus, computer device, and storage medium for adapting deep learning frameworks. Background Technology

[0002] With the rapid development of deep learning models, higher requirements have been placed on the training and inference speed of deep learning frameworks.

[0003] In related technologies, in order to improve the training and inference speed of deep learning models, deep learning frameworks can be developed and adapted to heterogeneous accelerators, and the computational tasks in the deep learning framework can be executed in parallel through heterogeneous accelerators.

[0004] However, there is a poor compatibility issue between deep learning frameworks in related technologies and heterogeneous accelerators, which prevents deep learning frameworks from running stably on heterogeneous accelerators. Summary of the Invention

[0005] Therefore, it is necessary to provide a method, apparatus, computer device, and storage medium for adapting deep learning frameworks to address the aforementioned technical problems. This would improve the compatibility between deep learning frameworks and heterogeneous accelerators, enabling deep learning frameworks to run stably on heterogeneous accelerators.

[0006] Firstly, this application provides a method for adapting to deep learning frameworks, including:

[0007] Obtain the operation information and operation requirements of the heterogeneous accelerator. Both operation information and operation requirements represent information about the heterogeneous accelerator when it executes the computational tasks of the target deep learning framework.

[0008] Modify the source code of the target deep learning framework based on the runtime information, and modify the third-party library code of the target deep learning framework according to the runtime requirements;

[0009] The modified deep learning framework was evaluated and validated.

[0010] If the modified deep learning framework passes the evaluation and verification, it will be determined as the deep learning framework adapted to heterogeneous accelerators.

[0011] In the technical solution of this application embodiment, the operation information and operation requirements of the heterogeneous accelerator are first obtained; wherein, the operation information and operation requirements both represent the information when the heterogeneous accelerator executes the computational task of the target deep learning framework; the source code of the target deep learning framework is modified according to the operation information, and the third-party library code of the target deep learning framework is modified according to the operation requirements, and then the modified deep learning framework is evaluated and verified; if the modified deep learning framework passes the evaluation and verification, the modified deep learning framework is determined as the deep learning framework adapted to the heterogeneous accelerator. In this embodiment, since the runtime information and runtime requirements are information that the heterogeneous accelerator uses to execute the computational tasks of the target deep learning framework, modifying the source code and third-party libraries of the target deep learning framework based on the runtime information and runtime requirements is equivalent to considering the runtime information and runtime requirements between the heterogeneous accelerator and the target deep learning framework when the target deep learning framework is executed on the heterogeneous accelerator during the adaptation process. This improves the compatibility between the target deep learning framework and the heterogeneous accelerator and ensures the stable operation of the target deep learning framework on the heterogeneous accelerator. Furthermore, evaluating and verifying the modified deep learning framework further ensures the correctness and reliability of the modified deep learning framework.

[0012] In one embodiment, the runtime information includes runtime interface information and dependency library files when the heterogeneous accelerator uses the math library; modifications are made to the source code of the target deep learning framework based on the runtime information, including:

[0013] Based on the runtime interface information, modify the corresponding interface code in the source code of the target deep learning framework; and based on the library files that the heterogeneous accelerator depends on when using the mathematical library, modify the corresponding library file paths in the source code of the target deep learning framework.

[0014] In the technical solution of this application embodiment, the corresponding interface code in the source code of the target deep learning framework is modified according to the runtime interface information; and the corresponding library file path in the source code of the target deep learning framework is modified according to the library files that the heterogeneous accelerator depends on when using the mathematical library. This is equivalent to modifying the interface code and library file paths for the target deep learning framework and the heterogeneous accelerator in advance, enabling the target deep learning framework to find the corresponding files during subsequent compilation and runtime, thus improving the compatibility between the target deep learning framework and the heterogeneous accelerator.

[0015] In one embodiment, the runtime requirements include the execution method; modifications are made to the third-party library code of the target deep learning framework based on the runtime requirements, including:

[0016] Based on the storage location of the third-party library code, obtain the third-party library code of the target deep learning framework;

[0017] Based on the execution method of heterogeneous accelerators, the instruction set code of the heterogeneous accelerators is obtained, and the third-party library code is modified according to the instruction set code.

[0018] In the technical solution of this application embodiment, the third-party library code of the target deep learning framework is obtained according to its storage location, and the instruction set code of the heterogeneous accelerator is obtained based on its execution mode. The third-party library code is then modified according to the instruction set code. Modifying the third-party library allows it to adapt to the instruction set of the heterogeneous accelerator, solving the usability problem of the code on the heterogeneous accelerator. Simultaneously, modifying the third-party library code of the target deep learning framework can also improve the execution efficiency of the code on the heterogeneous accelerator.

[0019] In one embodiment, the modified deep learning framework is evaluated and validated, including:

[0020] Compile the modified deep learning framework;

[0021] If compilation succeeds, then unit test the modified deep learning framework code.

[0022] If the unit tests pass, continue benchmarking the code of the modified deep learning framework.

[0023] If the benchmark test is passed, the evaluation and verification of the modified deep learning framework is confirmed.

[0024] In the technical solution of this application embodiment, the modified deep learning framework is compiled. If the compilation is successful, unit tests are performed on the code of the modified deep learning framework. If the unit tests are successful, benchmark tests are then performed on the code of the modified deep learning framework. If the benchmark tests are successful, the evaluation and verification of the modified deep learning framework are deemed successful. Since unit tests can verify whether the modified deep learning framework functions correctly in each unit, and benchmark tests can evaluate the reliability of the modified deep learning framework in terms of performance, performing unit tests and benchmark tests on the code of the modified deep learning framework after successful compilation further improves the accuracy and reliability of the modified deep learning framework. Furthermore, performing unit tests only after successful compilation, and benchmark tests only after successful unit tests, ensures that testing is conducted in the correct code, thus improving the reliability of the evaluation and verification of the modified deep learning framework.

[0025] In one embodiment, compiling the modified deep learning framework includes:

[0026] Determine the compilation environment for the modified deep learning framework based on the configuration version of the target deep learning framework;

[0027] The modified deep learning framework is compiled according to the compilation environment and preset compilation commands;

[0028] If compilation fails, adjust the modified deep learning framework according to the error log information generated during compilation failure, until the modified deep learning framework compiles successfully.

[0029] In the technical solution of this application embodiment, the compilation environment of the modified deep learning framework is determined according to the configuration version of the target deep learning framework, and the modified deep learning framework is compiled according to the compilation environment and preset compilation commands. If the compilation fails, the modified deep learning framework is adjusted according to the log error information generated by the compilation failure until the modified deep learning framework is successfully compiled. By compiling the modified target deep learning framework and adjusting the modified deep learning framework when compilation fails, the accuracy and effectiveness of the target deep learning framework can be ensured, thereby improving the accuracy and efficiency of the adaptation of the target deep learning framework to heterogeneous accelerators.

[0030] In one embodiment, unit testing is performed on the code of the modified deep learning framework, including:

[0031] Perform at least one type of unit test on the modified deep learning framework;

[0032] If the test results based on each type of unit test all meet the test standard range, then the unit test of the modified deep learning framework code is deemed to have passed.

[0033] If any unit test results fail to meet the test standard range, the test failure cases and corresponding error messages are obtained based on the test results. The modified deep learning framework is then adjusted based on the error messages corresponding to the test failure cases until the test results of all unit tests meet the test standard range.

[0034] In the technical solution of this application embodiment, at least one type of unit test is performed on the modified deep learning framework. If the test results of each type of unit test all meet the test standard range, the unit test of the modified deep learning framework code is determined to be passed. If any test result of each type of unit test fails to meet the test standard range, test failure cases and corresponding error information are obtained based on the test results, and the modified deep learning framework is adjusted based on the error information corresponding to the test failure cases until the test results of each type of unit test all meet the test standard range. Setting a test standard range for the unit test results ensures that the corresponding unit test is considered passed only when the test results meet the test standard range. Furthermore, performing at least one type of unit test on the modified deep learning framework improves the comprehensiveness of the unit test for the modified deep learning framework, making the test results of the modified deep learning framework more accurate. And when the test results of the unit tests fail to meet the test standard range, the modified deep learning framework is adjusted based on the corresponding test failure cases, thereby improving the accuracy and efficiency of the adjustment of the modified deep learning framework.

[0035] In one embodiment, benchmarking is performed on the code of the modified deep learning framework, including:

[0036] Based on the preset binary packaging command, the modified deep learning framework code is packaged to generate binary files;

[0037] Based on binary files, a deep learning model is obtained by training the network model using a pre-set dataset.

[0038] Perform various types of performance tests on deep learning models;

[0039] If all performance tests of the deep learning model pass, then the modified deep learning framework is considered to have passed the benchmark test.

[0040] In the technical solution of this application embodiment, the code of the modified deep learning framework is packaged according to a preset binary packaging command to generate a binary file. Based on the binary file, the network model is trained using a preset dataset to obtain a deep learning model. Then, various types of performance tests are performed on the deep learning model. If all performance tests of the deep learning model pass, the modified deep learning framework is deemed to have passed the benchmark test. By training the network model of the modified deep learning framework with a preset dataset and performing performance tests on the trained deep learning model, the modified deep learning framework is further made adaptable to heterogeneous accelerators while also possessing high accuracy.

[0041] Secondly, this application also provides a deep learning framework adapter, comprising:

[0042] The acquisition module is used to acquire the operation information and operation requirements of the heterogeneous accelerator. Both the operation information and operation requirements represent the information when the heterogeneous accelerator executes the computational tasks of the target deep learning framework.

[0043] The modification module is used to modify the source code of the target deep learning framework based on the runtime information, and to modify the third-party library code of the target deep learning framework according to the runtime requirements.

[0044] The evaluation module is used to evaluate and verify the modified deep learning framework.

[0045] The determination module is used to determine the modified deep learning framework as a deep learning framework that is compatible with heterogeneous accelerators if the evaluation and verification of the modified deep learning framework is successful.

[0046] Thirdly, embodiments of this application provide a computer device including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the method provided in any of the embodiments of the first aspect described above.

[0047] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method provided in any of the embodiments of the first aspect described above.

[0048] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method provided in any of the embodiments of the first aspect described above. Attached Figure Description

[0049] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0050] Figure 1 This is an internal structural diagram of a computer device in one embodiment;

[0051] Figure 2 This is a flowchart illustrating a deep learning framework adaptation method in one embodiment.

[0052] Figure 3 This is a flowchart illustrating the deep learning framework adaptation method in another embodiment;

[0053] Figure 4 This is a flowchart illustrating the deep learning framework adaptation method in another embodiment;

[0054] Figure 5 This is a flowchart illustrating the deep learning framework adaptation method in another embodiment;

[0055] Figure 6 This is a flowchart illustrating the deep learning framework adaptation method in another embodiment;

[0056] Figure 7 This is a flowchart illustrating the deep learning framework adaptation method in another embodiment;

[0057] Figure 8 This is a flowchart illustrating the deep learning framework adaptation method in another embodiment;

[0058] Figure 9 This is a structural block diagram of a deep learning framework adapter in one embodiment. Detailed Implementation

[0059] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0060] The deep learning framework adaptation method provided in this application can be applied to computer devices. The computer device can be a server, which can be implemented using a standalone server or a server cluster composed of multiple servers. The internal structure diagram of the computer device can be as follows: Figure 1 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores deep learning framework adaptation data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a deep learning framework adaptation method.

[0061] Those skilled in the art will understand that Figure 1The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0062] Deep learning frameworks are open-source frameworks for machine learning that can be used to quickly build neural network models and rapidly train, evaluate, and save them. Heterogeneous accelerators, also known as computing cards, are hardware specifically designed for computational tasks, providing cost-effective high-performance computing capabilities with strong scalability. However, because heterogeneous accelerators are still in their early stages of development, there are currently no complete adaptation methods for deep learning frameworks to them. This results in incompatibility or poor compatibility between heterogeneous accelerators and deep learning frameworks, and incomplete support for deep learning frameworks' model training, inference, and saving functions. Consequently, a robust software ecosystem for heterogeneous accelerators cannot be established, which will hinder the development of the domestic heterogeneous accelerator ecosystem.

[0063] Based on this, in order to solve the problem that heterogeneous accelerators do not support or do not fully support deep learning frameworks, this application provides a deep learning framework adaptation method. This method can standardize and correctly assist heterogeneous accelerators in completing the adaptation, testing and development work on deep learning frameworks, effectively supporting the rapid, stable and correct operation of deep learning frameworks on heterogeneous accelerators, thereby improving the core competitiveness of heterogeneous accelerators.

[0064] In one exemplary embodiment, such as Figure 2 As shown, a method for adapting to deep learning frameworks is provided, which can be applied to... Figure 1 Taking a computer device as an example, the explanation includes the following steps:

[0065] S201, Obtain the operation information and operation requirements of the heterogeneous accelerator. Both the operation information and operation requirements represent information about the heterogeneous accelerator when it executes the computational tasks of the target deep learning framework.

[0066] A heterogeneous accelerator is a hardware device that enhances computing performance. It works in conjunction with the main processor to accelerate specific types of computational tasks; for example, a heterogeneous accelerator can accelerate computational tasks within a deep learning framework. Optionally, a heterogeneous accelerator can be a Graphics Processing Unit (GPU), a Field Programmable Gate Array (FPGA), a Tensor Processing Unit (TPU), or a Non-Volatile Memory (NVM) accelerator, etc. The target deep learning framework can be any deep learning framework that requires acceleration of computational tasks by a heterogeneous accelerator; for example, the target deep learning framework can be TensorFlow, PyTorch, and OneFlow.

[0067] The way to obtain the runtime information and runtime requirements of a heterogeneous accelerator when executing computational tasks of a target deep learning framework is as follows: First, obtain the attribute information of the target deep learning framework, such as the version of the target deep learning framework, supported hardware platforms, and operating systems; then, based on the attribute information of the target deep learning framework and the correspondence between the attribute information and the runtime information and runtime requirements of the heterogeneous accelerator, determine the runtime information and runtime requirements of the heterogeneous accelerator.

[0068] Specifically, the correspondence includes: the correspondence between the attribute information of deep learning frameworks and the operation information of heterogeneous accelerators, and the correspondence between the attribute information of deep learning frameworks and the operation requirements of heterogeneous accelerators. The correspondence may include attribute information of multiple different deep learning frameworks. The operation information and operation requirements of the heterogeneous accelerators corresponding to the attribute information of each deep learning framework may be the same or different, and can be determined according to the actual situation.

[0069] Therefore, the operational information and requirements of the heterogeneous accelerators corresponding to the target deep learning framework can be obtained from the correspondence.

[0070] In an alternative embodiment, the target deep learning framework can also be tested on a heterogeneous accelerator to determine the runtime information and requirements generated by the heterogeneous accelerator when executing the computational tasks of the target deep learning framework.

[0071] The operational information may include the heterogeneous accelerator's driver, software development kit version, hardware specifications, computing power, memory bandwidth, etc.; operational requirements may include storage requirements, operating system, driver requirements, etc.

[0072] S202, Modify the source code of the target deep learning framework according to the runtime information, and modify the third-party library code of the target deep learning framework according to the runtime requirements.

[0073] In one embodiment, the code that needs to be modified in the target deep learning framework can be determined according to a preset code modification model. For example, the runtime information is input into the code modification model, which analyzes the runtime information of the heterogeneous accelerator to obtain the modification method of the source code of the target deep learning framework, and modifies the source code of the target deep learning framework based on the modification method. The runtime requirements are input into the code modification model, which analyzes the runtime requirements of the heterogeneous accelerator to obtain the modification method of the third-party library of the target deep learning framework, and modifies the third-party library code of the target deep learning framework based on the modification method of the third-party library.

[0074] Alternatively, modifying the source code of the target deep learning framework based on runtime information can also be done by determining the modification method for the target deep learning framework's source code based on the runtime information of the heterogeneous accelerator and the type of the target deep learning framework, and then modifying the source code of the target deep learning framework according to the modification method. Similarly, modifying the third-party libraries of the target deep learning framework based on runtime requirements can also be done by determining the modification method for the third-party libraries of the target deep learning framework based on the runtime requirements of the heterogeneous accelerator and the type of the target deep learning framework, and then modifying the third-party library code of the target deep learning framework according to the modification method.

[0075] Both methods for modifying source code and methods for modifying third-party libraries can include the location of the code to be modified and the correct code to be replaced at that location.

[0076] S203 evaluates and validates the modified deep learning framework.

[0077] Among these, evaluating and verifying the modified deep learning framework can ensure its functional correctness, performance optimization, compatibility, robustness, and reliability.

[0078] Therefore, the methods for evaluating and verifying the modified deep learning framework may include at least one of the following: performance evaluation of the modified deep learning framework, functional verification of the modified deep learning framework, compatibility testing of the modified deep learning framework, and robustness testing of the modified deep learning framework.

[0079] Performance testing of the modified deep learning framework allows for comparison of its performance with the original target deep learning framework under the same heterogeneous accelerator and other hardware environments. Performance evaluation of the modified deep learning framework can be conducted using standard deep learning benchmark databases (e.g., ImageNet) and common evaluation metrics (e.g., accuracy, training time, inference time). By comparing different evaluation data, the performance of the modified deep learning framework on heterogeneous accelerators can be assessed.

[0080] Functional verification of the modified deep learning framework ensures that it functions correctly in various deep learning tasks (e.g., image classification, object detection, speech recognition, etc.). This verification can be achieved by using pre-defined standard test datasets and test cases to test the modified framework, verifying its ability to correctly process input data, generate accurate output results, and maintain stable performance across various scenarios.

[0081] Compatibility testing of the modified deep learning framework ensures that it can be integrated with common deep learning models. One method for compatibility testing is to use common deep learning models (e.g., ResNet, YOLO series) to test the modified framework and verify that it can correctly load and run these models.

[0082] Robustness testing of the modified deep learning framework can confirm its performance under various abnormal conditions. One way to perform robustness testing is to simulate some common abnormal situations, such as missing input data, noise interference, and incorrect model parameters, to check whether the modified deep learning framework can correctly handle these abnormal situations and whether it has good robustness and fault tolerance.

[0083] It should be noted that the evaluation and verification methods for the modified deep learning framework can be determined based on specific needs and application scenarios, and should be combined with actual test data and test cases. Optionally, the repeatability and scalability of the modified deep learning framework test can also be considered, so that the modified deep learning framework can be repeatedly tested and extended for verification under different environments and configurations.

[0084] S204. If the modified deep learning framework passes the evaluation and verification, then the modified deep learning framework will be determined as the deep learning framework adapted to heterogeneous accelerators.

[0085] Based on the above evaluation and verification of the modified deep learning framework, if the evaluation and verification of the modified deep learning framework are passed, it can be determined that the performance verification of the modified deep learning framework is passed, and the modified deep learning framework can be identified as a deep learning framework adapted to heterogeneous accelerators.

[0086] If the evaluation and verification of the modified deep learning framework includes multiple verification methods, then the condition for the modified deep learning framework to pass the evaluation and verification can be that all verification methods of the modified deep learning framework pass the verification.

[0087] In this embodiment, the operation information and operation requirements of the heterogeneous accelerator are first obtained; wherein, the operation information and operation requirements both represent information when the heterogeneous accelerator executes the computational task of the target deep learning framework; the source code of the target deep learning framework is modified according to the operation information, and the third-party library code of the target deep learning framework is modified according to the operation requirements, and then the modified deep learning framework is evaluated and verified; if the modified deep learning framework passes the evaluation and verification, the modified deep learning framework is determined as the deep learning framework adapted to the heterogeneous accelerator. In this embodiment, since the runtime information and runtime requirements are information that the heterogeneous accelerator uses to execute the computational tasks of the target deep learning framework, modifying the source code and third-party libraries of the target deep learning framework based on the runtime information and runtime requirements is equivalent to considering the runtime information and runtime requirements between the heterogeneous accelerator and the target deep learning framework when the target deep learning framework is executed on the heterogeneous accelerator during the adaptation process. This improves the compatibility between the target deep learning framework and the heterogeneous accelerator and ensures the stable operation of the target deep learning framework on the heterogeneous accelerator. Furthermore, evaluating and verifying the modified deep learning framework further ensures the correctness and reliability of the modified deep learning framework.

[0088] The runtime information includes runtime interface information and dependent library files when the heterogeneous accelerator uses the math library. In an exemplary embodiment, the source code of the target deep learning framework is modified according to the runtime information, including: modifying the corresponding interface code in the source code of the target deep learning framework according to the runtime interface information; and modifying the corresponding library file path in the source code of the target deep learning framework according to the dependent library files when the heterogeneous accelerator uses the math library.

[0089] The runtime interface information can be the interfaces that the heterogeneous accelerator needs to call when executing the computational tasks of the target deep learning framework. Therefore, when adapting the target deep learning framework to the heterogeneous accelerator, the corresponding interface code in the source code of the target deep learning framework can be modified according to the runtime interface information.

[0090] Optionally, based on the interfaces in the runtime interface information, the corresponding interfaces in the source code of the target deep learning framework are determined, wherein the interfaces in the runtime interface information are consistent with the corresponding interfaces in the source code of the target deep learning framework; based on the function and parameters of the interfaces in the runtime interface information, the modification method of the interfaces is determined, and then the corresponding interface code in the source code of the target deep learning framework is modified according to the modification method. The modification method of the interfaces may include interface calling methods, data transmission methods, computation logic, and algorithms, etc.

[0091] Among them, the dependency library files when the heterogeneous accelerator uses the mathematical library can be the related dependencies of various databases used by the target deep learning framework when performing various computing tasks on the heterogeneous accelerator; therefore, when adapting the target deep learning framework to the heterogeneous accelerator, the corresponding library file paths in the source code of the target deep learning framework can be modified according to the dependency library files when the heterogeneous accelerator uses the mathematical library.

[0092] Optionally, first, obtain the dependencies between library files, that is, all library files that the math library file depends on; then, obtain the paths of the dependent library files when the heterogeneous accelerator uses the math library, and modify the paths of the corresponding library files in the source code of the target deep learning framework according to the paths of the dependent library files when the heterogeneous accelerator uses the math library.

[0093] Modifying the library file paths in the source code of the target deep learning framework can be achieved by: modifying the library file search path; finding the part in the source code that loads the mathematical library file and modifying the corresponding library file search path; this can usually be done by modifying environment variables, configuration files, or path strings in the code.

[0094] Alternatively, the kernel function and other functions of the target deep learning framework can be modified according to the characteristics of the heterogeneous accelerator.

[0095] In this embodiment, the corresponding interface code in the source code of the target deep learning framework is modified according to the runtime interface information; and the corresponding library file path in the source code of the target deep learning framework is modified according to the library files that the heterogeneous accelerator depends on when using the mathematical library. This is equivalent to modifying the interface code and library file paths for the target deep learning framework and the heterogeneous accelerator in advance, ensuring that the target deep learning framework can find the corresponding files during subsequent compilation and runtime, thus improving the compatibility between the target deep learning framework and the heterogeneous accelerator.

[0096] Operational requirements include the execution method; in an exemplary embodiment, such as Figure 3As shown, the third-party library code of the target deep learning framework needs to be modified according to the operational requirements, including the following steps:

[0097] S301: Obtain the third-party library code of the target deep learning framework based on the storage location of the third-party library code.

[0098] The execution method can be the underlying execution method of a heterogeneous accelerator. For example, the execution method can be the execution method of the Compute Unified Device Architecture (CUDA) development platform or the execution method of the Radeon Open Compute (ROCm) development platform.

[0099] The storage location of the third-party library code can be obtained from the source code of the target deep learning framework. Then, the third-party library code of the target deep learning framework can be obtained directly based on the storage location of the third-party library code.

[0100] Optionally, obtaining some third-party libraries may require an external network connection. In this case, you can first pull some library packages to your local machine or a self-built Git server, and then modify the location of the third-party library acquisition in the code of the target deep learning framework to ensure the correct download and compilation of the third-party libraries in the future.

[0101] S302, based on the execution method of heterogeneous accelerator, obtains the instruction set code of heterogeneous accelerator and modifies the third-party library code according to the instruction set code.

[0102] The instruction set code of a heterogeneous accelerator can be determined based on the correspondence between the execution method and the instruction set code. Specifically, the instruction set code corresponding to the execution method of the heterogeneous accelerator when executing the computational task of the target deep learning framework is determined as the instruction set code of the heterogeneous accelerator, and then the third-party library code is modified according to the instruction set code.

[0103] One way to modify the third-party library code is to add the instruction set code to the third-party library code, or to replace the instruction set code of the original heterogeneous accelerator in the third-party library with the instruction set code.

[0104] For example, if the third-party library file is an LLVM library file, the relevant instruction set code corresponding to the heterogeneous accelerator can be added to the LLVM library file, so that the program of the target deep learning framework can run correctly and stably on the corresponding heterogeneous accelerator.

[0105] In this embodiment, the third-party library code of the target deep learning framework is obtained based on its storage location, and the instruction set code of the heterogeneous accelerator is obtained based on its execution method. The third-party library code is then modified according to the instruction set code. Modifying the third-party library allows for adaptation to the instruction set of the heterogeneous accelerator, resolving the usability issue on the heterogeneous accelerator. Furthermore, modifying the third-party library code of the target deep learning framework can improve the execution efficiency of the code on the heterogeneous accelerator.

[0106] In one exemplary embodiment, such as Figure 4 As shown, the modified deep learning framework is evaluated and validated, including the following steps:

[0107] S401 compiles the modified deep learning framework.

[0108] Among these features, compilation can improve execution efficiency and detect syntax errors, type errors, and some common logical errors in the code. Therefore, it is possible to compile modified deep learning frameworks.

[0109] In one exemplary embodiment, such as Figure 5 As shown, compiling the modified deep learning framework includes the following steps:

[0110] S501, based on the configuration version of the target deep learning framework, determines the compilation environment for the modified deep learning framework.

[0111] Before compiling the modified deep learning framework, you need to configure the relevant compilation environment.

[0112] Specifically, the compilation environment corresponding to the configuration version of the target deep learning framework can be obtained from the correspondence between deep learning framework versions and compilation environments. Then, the compilation environment corresponding to the configuration version of the target deep learning framework can be determined as the compilation environment of the modified deep learning framework.

[0113] In one embodiment, taking TensorFlow as the target deep learning framework, the corresponding Python package type can be determined based on the TensorFlow configuration version and Python version, and then the corresponding Python package can be installed.

[0114] S502 compiles the modified deep learning framework according to the compilation environment and preset compilation commands.

[0115] The compilation command is used to compile the modified deep learning framework. Optionally, after configuring the above compilation environment, the modified deep learning framework can be compiled according to the preset compilation command.

[0116] The modified deep learning framework can be compiled using a compilation tool based on a preset compilation command; for example, the compilation tool can be Bazel, CMake, etc.; if the compilation tool is Bazel, the compilation command can be the bazelbuild compilation command.

[0117] Optionally, the modified deep learning framework can be compiled on the CUDA development platform, the ROCm development platform, or a custom software platform; the platform for compiling the modified deep learning framework can be determined according to actual needs.

[0118] Optionally, the modified deep learning framework can be compiled, which essentially involves compiling the source code of the modified deep learning framework, and the modified source code can be compiled into an executable file or a library file.

[0119] S503 If compilation fails, the modified deep learning framework will be adjusted based on the error log information generated during compilation failure until the modified deep learning framework compiles successfully.

[0120] After the modified deep learning framework is compiled, the compilation results can be output, which can include compilation success and compilation failure.

[0121] If compilation fails, a corresponding log error message will be output. Therefore, the reason for the compilation failure can be located based on the log error message. Then, the modified deep learning framework can be adjusted, and the source code of the modified deep learning framework (adjusted deep learning framework) can be recompiled until the modified deep learning framework is successfully compiled. Otherwise, the modified deep learning framework can be readjusted based on the log error message generated by the compilation failure.

[0122] Optionally, adjustments to the modified deep learning framework can be made by modifying the source code of the modified deep learning framework, modifying the third-party library code, or modifying the compilation environment.

[0123] In this embodiment, the compilation environment for the modified deep learning framework is determined based on the configuration version of the target deep learning framework. The modified deep learning framework is then compiled according to the compilation environment and preset compilation commands. If compilation fails, the modified deep learning framework is adjusted based on the error logs generated during the compilation failure, until the modified deep learning framework compiles successfully. By compiling the modified target deep learning framework and adjusting it when compilation fails, the accuracy and effectiveness of the target deep learning framework can be ensured, thereby improving the accuracy and efficiency of adapting the target deep learning framework to heterogeneous accelerators.

[0124] S402. If compilation succeeds, then perform unit tests on the modified deep learning framework code.

[0125] Unit testing is an important step in ensuring code quality and functional correctness. Therefore, if the modified deep learning framework compiles successfully, unit testing can be performed on the code of the modified deep learning framework.

[0126] One way to perform unit testing on the modified deep learning framework code is to divide the code into multiple small test units. Each test unit can test a specific function or behavior. Test cases for each test unit are obtained, and then each test case is run according to a pre-defined unit testing framework to test each unit. The test result for each test case is then determined. If a test case fails, the corresponding test unit fails, indicating that the modified deep learning framework code's unit test fails. If all test cases pass, the modified deep learning framework code's unit test passes.

[0127] The test cases for each test unit can be obtained in one of the following ways: either by writing test cases for each test unit based on its function, or by directly retrieving the test cases corresponding to the function of each test unit from the database. Test cases can include input data, expected output, and assertion statements, and can cover as many code paths and boundary conditions as possible.

[0128] S403. If the unit test passes, continue benchmarking the code of the modified deep learning framework.

[0129] Benchmarking can evaluate the performance and efficiency of a modified deep learning framework. Therefore, if the code of the modified deep learning framework passes the unit tests, benchmarking can be performed on the code of the modified deep learning framework.

[0130] Benchmarking the modified deep learning framework can be done by obtaining benchmark tasks and benchmark datasets for the modified deep learning framework; the benchmark tasks can be determined based on the application domain and usage scenario, and the benchmark datasets include various samples and scenarios; based on the benchmark tasks and benchmark datasets, various benchmark experiments are determined; the benchmark experiments include training and inference, etc.; based on the modified deep learning framework and configuration environment, the benchmark experiments are run to obtain the benchmark experiment results.

[0131] Optionally, benchmark results may include whether the modified deep learning framework's code passes or fails the benchmark test.

[0132] If a benchmark test fails, the modified deep learning framework can be adjusted, and then recompiled, unit-tested, and benchmarked until all three tests pass. Adjustments can be made to the modified deep learning framework by modifying its source code, third-party library code, or the compilation environment.

[0133] S404. If the benchmark test is passed, the evaluation and verification of the modified deep learning framework is confirmed to be successful.

[0134] If the modified deep learning framework passes the code benchmark tests, it means that the modified deep learning framework has passed the compilation, unit tests, and benchmark tests, and the evaluation and verification of the modified deep learning framework is deemed successful. The evaluation and verification of the modified deep learning framework includes compilation, unit tests, and benchmark tests.

[0135] In this embodiment, the modified deep learning framework is compiled. If compilation succeeds, unit tests are performed on the modified deep learning framework code. If the unit tests pass, benchmark tests are then performed on the modified deep learning framework code. If the benchmark tests pass, the evaluation and verification of the modified deep learning framework are deemed successful. Since unit tests can verify whether the modified deep learning framework functions correctly in each unit, and benchmark tests can evaluate the reliability of the modified deep learning framework in terms of performance, performing unit tests and benchmark tests on the modified deep learning framework code after compilation succeeds further improves the accuracy and reliability of the modified deep learning framework. Furthermore, performing unit tests only after compilation succeeds, and benchmark tests only after unit tests pass, ensures that testing is conducted on the correct code, thus improving the reliability of the evaluation and verification of the modified deep learning framework.

[0136] The following example illustrates in detail how to perform unit testing on the code of a modified deep learning framework. In one exemplary embodiment, such as... Figure 6 As shown, unit testing is performed on the modified deep learning framework code, including the following steps:

[0137] S601, perform unit tests on the modified deep learning framework based on at least one type.

[0138] Unit testing is a functional verification test that includes a large number of test cases. The types of unit tests can include unit tests based on the C++ programming language (ctest) and unit tests based on the Python programming language (pytest). Therefore, the modified deep learning framework can be tested using both ctest and pytest.

[0139] At least one type of unit test can be executed according to the preset unit test instructions to obtain the unit test results of each type of unit test. The unit test results can include test results in multiple states such as pass, fail, timeout, and flake. Among them, the timeout test result can include how long the timeout is, and the flake test result can include how many test cases failed.

[0140] Optionally, the unit test instructions can perform unit tests on the code of the modified deep learning framework on the Compute Unified Device Architecture (CUDA) development platform, the Radeon Open Compute (ROCm) open source computing platform, or a custom software platform; the platform for performing unit tests on the modified deep learning framework can be determined according to actual needs.

[0141] S602, if the test results based on each type of unit test all meet the test standard range, then the code unit test of the modified deep learning framework is deemed to have passed.

[0142] The test standard range can be a pre-defined standard for evaluating whether the test results of the unit test pass or fail.

[0143] For example, test results include pass, failure, timeout, and instability. If the test result is "pass", the test standard range includes the test result being pass. Therefore, if the test results of all types of unit tests are "pass", then the code unit tests of the modified deep learning framework are determined to be passable; otherwise, the code unit tests of the modified deep learning framework are determined to be failable.

[0144] S603 If any unit test results of each type fail to meet the test standard range, obtain the test failure cases and corresponding error information based on the test results, and adjust the modified deep learning framework based on the reward information corresponding to the test failure cases until the test results of each type of unit test meet the test standard range.

[0145] If the unit test result is not passed, it is determined that the test result of the corresponding unit test does not meet the test standard range. Then, the test cases that failed (test failure cases) and the corresponding error messages can be obtained. Based on the error messages corresponding to the test failure cases, the modified deep learning framework can be adjusted until the test results of all types of unit tests meet the test standard range.

[0146] One way to adjust the modified deep learning framework based on the error messages corresponding to failed test cases is to analyze the code of the failed test cases according to the error messages, determine the reason for the unit test failure of the failed test cases, and then adjust the modified deep learning framework according to the reason for the test failure.

[0147] The methods for adjusting the modified deep learning framework include: modifying the source code of the modified deep learning framework, modifying the code of third-party libraries, or modifying the compilation environment.

[0148] After adjusting the modified deep learning framework, compile it sequentially. If the compilation is successful, perform unit tests on the modified deep learning framework using ctest and pytest until the test results all meet the test standard range. Otherwise, continue to adjust the modified deep learning framework based on the error messages.

[0149] In this embodiment, the modified deep learning framework is subjected to unit tests based on at least one type. If the test results of each type of unit test all meet the test standard range, the unit tests of the modified deep learning framework are deemed to have passed. If any unit test result fails to meet the test standard range, test failure cases and corresponding error messages are obtained based on the test results. The modified deep learning framework is then adjusted based on the error messages of the test failure cases until the test results of each type of unit test all meet the test standard range. Setting test standard ranges for the unit test results ensures that each unit test is considered passed only if its result meets the standard range. Furthermore, performing unit tests based on at least one type on the modified deep learning framework improves the comprehensiveness of the unit tests, making the test results more accurate. In cases where the unit test results fail to meet the test standard range, the modified deep learning framework is adjusted based on the error messages of the corresponding test failure cases, thereby improving the accuracy and efficiency of the adjustments made to the modified deep learning framework.

[0150] The following example illustrates in detail how to benchmark the code of a modified deep learning framework. In an exemplary embodiment, such as... Figure 7 As shown, benchmarking is performed on the modified deep learning framework code, including the following steps:

[0151] S701 packages the modified deep learning framework code according to a preset binary packaging command, generating a binary file.

[0152] After the modified deep learning framework compiles successfully and the test results for all types of unit tests meet the test standards, a binary packaging command is executed to package the modified deep learning framework into a binary file. The binary packaging command can be `build_pip_package`, and the binary file is a .whl package.

[0153] Optionally, execute the build_pip_package command to package the modified deep learning framework into a whl package.

[0154] It should be noted that if you need to change the name of the binary file, you can modify the package name of the binary file within the binary file itself.

[0155] Simultaneously, preset build instructions can be executed on the modified deep learning framework to build the libTensorFlow.so library file (the application programming interface, API) for the C language and the libTensorFlow_cc.so library file (the advanced packaging tools, APT) for the C++ language. The build instructions can be executed on the modified deep learning framework on the ComputeUnified Device Architecture (CUDA) development platform, the Radeon Open Compute (ROCm) open-source computing platform, or a custom software platform. The platform for building the library files of the modified deep learning framework can be determined according to actual needs.

[0156] S702, based on binary files, trains network models using pre-set datasets to obtain deep learning models.

[0157] The pre-configured dataset can be ImageNet or CoCo dataset, and the network model can be ResNet50, VggNet, InceptionNet, or other network models.

[0158] Optionally, the training of the network model using a pre-set dataset can be carried out over a long period of 90 iterations based on a binary file to obtain a deep learning model.

[0159] S703 performs various types of performance tests on deep learning models.

[0160] The deep learning model trained above is subjected to various types of performance tests, including performance benchmark tests, accuracy tests, memory usage tests, stability tests, single-process single-card tests, single-process multi-card tests, and multi-process multi-card tests.

[0161] The test results of each performance test can be compared with publicly available data from various heterogeneous accelerators or with performance test results obtained by running the test on relevant heterogeneous accelerators. The performance test results are then used to determine whether the deep learning model has passed the test.

[0162] Optionally, the test results of each performance test on the deep learning model can be compared with the standard test results of each performance test. For any performance test, if the test result of the deep learning model's performance test is the same as the corresponding standard test result, then the performance test of the deep learning model is determined to have passed; if the test result of the deep learning model's performance test is inconsistent with the corresponding standard test result, then the performance test of the deep learning model is determined to have failed. Based on this, the test results of each performance test of the deep learning model can be determined.

[0163] S704. If all performance tests of the deep learning model pass, then the modified deep learning framework benchmark test is considered passed.

[0164] If all performance tests of the deep learning model pass, it indicates that the deep learning model performs well, and the modified deep learning framework passes the benchmark test.

[0165] If any performance tests of the deep learning model fail, the modified deep learning framework can be adjusted based on the failed performance tests and the errors that occurred in the corresponding tests.

[0166] Specifically, the modified deep learning framework can be adjusted by compiling and debugging its source code. The methods for adjusting the modified deep learning framework include modifying its source code, modifying third-party library code, or modifying the compilation environment.

[0167] The source code of the modified deep learning framework can be compiled and debugged on the Compute Unified Device Architecture (CUDA) development platform, the Radeon OpenCompute (ROCm) open source computing platform, or a custom software platform; the platform for compiling and debugging the modified deep learning framework can be determined according to actual needs.

[0168] By examining the modified deep learning framework's source code, performance testing issues can be located, debugged, and resolved. Then, various performance tests can be performed until all tests pass. Otherwise, it is necessary to continuously locate the cause of the errors and adjust the modified deep learning framework accordingly.

[0169] In this embodiment, the code of the modified deep learning framework is packaged according to a preset binary packaging command to generate a binary file. Based on the binary file, the network model is trained using a preset dataset to obtain a deep learning model. Then, various types of performance tests are performed on the deep learning model. If all performance tests of the deep learning model pass, the modified deep learning framework is deemed to have passed the benchmark test. By training the network model of the modified deep learning framework using a preset dataset and performing performance tests on the trained deep learning model, the modified deep learning framework is further improved to adapt to heterogeneous accelerators while also possessing high accuracy.

[0170] In one exemplary embodiment, this application also provides a deep learning framework adaptation method, taking TensorFlow as an example, as follows: Figure 8 As shown, this embodiment includes the following steps:

[0171] S801 modifies the API interfaces and dependency paths between programs in TensorFlow based on the runtime interfaces of the heterogeneous accelerators available in TensorFlow and various database-related dependencies.

[0172] S802 modifies the third-party library code to meet the requirements of heterogeneous accelerators.

[0173] One way to modify third-party library code is to modify the instructions and optimizations of the third-party library code; for example, if the third-party library is an LLVM library file, the relevant instruction set code of the heterogeneous accelerator can be added to the LLVM library file.

[0174] S803 configures the compilation environment for the modified TensorFlow.

[0175] Configuring the compilation environment may include installing the corresponding Python packages based on the TensorFlow configuration version and the Python version.

[0176] S804, compile the modified TensorFlow source code; if compilation fails, proceed to step S805; if compilation succeeds, proceed to step S806.

[0177] The modified TensorFlow source code is compiled according to the preset compilation command to obtain the compilation result, which includes whether the compilation is successful or not.

[0178] S805 adjusts the source code, third-party libraries, or compilation environment of modified TensorFlow.

[0179] If compilation fails, the cause of the failure is located based on the error log information, and then adjustments are made to the source code, third-party libraries, or compilation environment until compilation is successful.

[0180] S806, Perform unit tests on the modified TensorFlow; if the unit tests fail, proceed to step S805; if the unit tests pass, proceed to step S807.

[0181] If a unit test fails, the source code, third-party libraries, or compilation environment of the modified TensorFlow can be adjusted based on the test failure cases corresponding to the unit test failure, and then the modified TensorFlow can be compiled and unit tested.

[0182] S807 packages the source code according to the preset packaging command to obtain a whl package.

[0183] S808, Perform benchmark testing on the whl package; if the benchmark test passes, proceed to step S809; if the benchmark test fails, proceed to step S805.

[0184] The benchmarking process includes: training a deep learning model using a dataset based on the whl package; if training succeeds, the process is successful; if training fails, the modified TensorFlow source code can be used for debugging, and the modified TensorFlow source code can be modified, then the modified TensorFlow can be compiled, unit tested, and benchmarked until the benchmarking test succeeds.

[0185] S809, releases whl package.

[0186] The released whl package can be used by relevant users of this heterogeneous accelerator.

[0187] In this embodiment of the application, by adapting and testing the TensorFlow framework on heterogeneous accelerators, the related model training, testing, and model saving functions of the TensorFlow framework can run accurately and stably on heterogeneous accelerators. This also helps to promote the development of artificial intelligence technology, promote the construction of the heterogeneous accelerator ecosystem, promote the construction and development of heterogeneous accelerators, effectively enhance the core competitiveness of heterogeneous accelerators, and improve the development strength of the chip industry.

[0188] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0189] Based on the same inventive concept, this application also provides a deep learning framework adaptation device for implementing the deep learning framework adaptation method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more deep learning framework adaptation device embodiments provided below can be found in the limitations of the deep learning framework adaptation method described above, and will not be repeated here.

[0190] In one exemplary embodiment, such as Figure 9 As shown, a deep learning framework adaptation device 900 is provided, including: an acquisition module 901, a modification module 902, an evaluation module 903, and a determination module 904, wherein:

[0191] The acquisition module 901 is used to acquire the operation information and operation requirements of the heterogeneous accelerator. The operation information and operation requirements both represent the information when the heterogeneous accelerator executes the computational task of the target deep learning framework.

[0192] Modification module 902 is used to modify the source code of the target deep learning framework according to the runtime information, and to modify the third-party library code of the target deep learning framework according to the runtime requirements.

[0193] Evaluation module 903 is used to evaluate and verify the modified deep learning framework;

[0194] Module 904 is used to determine the modified deep learning framework as a deep learning framework adapted to heterogeneous accelerators if the evaluation and verification of the modified deep learning framework passes.

[0195] In one embodiment, runtime information includes runtime interface information and dependency library files when the heterogeneous accelerator uses the math library; the modification module 902 includes:

[0196] The first modification unit is used to modify the corresponding interface code in the source code of the target deep learning framework according to the runtime interface information; and to modify the corresponding library file path in the source code of the target deep learning framework according to the library files that the heterogeneous accelerator depends on when using the mathematical library.

[0197] In one embodiment, the operational requirements include the execution method; the modification module 902 includes:

[0198] The acquisition unit is used to retrieve the third-party library code of the target deep learning framework based on the storage location of the third-party library code.

[0199] The second modification unit is used to obtain the instruction set code of the heterogeneous accelerator based on the execution mode of the heterogeneous accelerator, and modify the third-party library code according to the instruction set code.

[0200] In one embodiment, the evaluation module 903 includes:

[0201] The compilation unit is used to compile the modified deep learning framework;

[0202] The first test unit is used to perform unit tests on the modified deep learning framework code if compilation passes.

[0203] The second test unit is used to continue benchmarking the code of the modified deep learning framework if the unit test passes.

[0204] The evaluation unit is used to determine whether the evaluation and verification of the modified deep learning framework has passed if the benchmark test is passed.

[0205] In one embodiment, the compilation unit includes:

[0206] The first determining subunit is used to determine the compilation environment of the modified deep learning framework based on the configuration version of the target deep learning framework.

[0207] The compilation subunit is used to compile the modified deep learning framework according to the compilation environment and preset compilation commands;

[0208] The first adjustment subunit is used to adjust the modified deep learning framework based on the log error information generated by the compilation failure if the compilation fails, until the modified deep learning framework can be compiled successfully.

[0209] In one embodiment, the first test unit includes:

[0210] The first test subunit is used to perform unit tests on the modified deep learning framework based on at least one type.

[0211] The second determining subunit is used to determine that the code unit test of the modified deep learning framework has passed if the test results based on each type of unit test all meet the test standard range.

[0212] The second adjustment subunit is used to obtain test failure cases and corresponding error information based on the test results of each type of unit test if there are any cases that do not meet the test standard range. The modified deep learning framework is then adjusted based on the error information corresponding to the test failure cases until the test results of each type of unit test meet the test standard range.

[0213] In one embodiment, the second test unit includes:

[0214] The generation subunit is used to package the modified deep learning framework code according to the preset binary packaging command and generate binary files.

[0215] The training subunit is used to train the network model based on binary files and a pre-defined dataset to obtain a deep learning model.

[0216] The second testing subunit is used to perform various types of performance tests on deep learning models.

[0217] The third determining subunit is used to determine whether the modified deep learning framework has passed the benchmark test if all performance tests of the deep learning model have passed.

[0218] Each module in the aforementioned deep learning framework adapter can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0219] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0220] The implementation principles and technical effects of each step in this embodiment are similar to those of the deep learning framework adaptation method described above, and will not be repeated here.

[0221] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0222] The implementation principles and technical effects of each step when the computer program is executed by the processor in this embodiment are similar to those of the deep learning framework adaptation method described above, and will not be repeated here.

[0223] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0224] The implementation principles and technical effects of each step when the computer program is executed by the processor in this embodiment are similar to those of the deep learning framework adaptation method described above, and will not be repeated here.

[0225] It should be noted that the data involved in this application (including but not limited to data used for analysis, data stored, data displayed, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0226] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0227] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0228] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for adapting to deep learning frameworks, characterized in that, The method includes: Obtain the operation information and operation requirements of the heterogeneous accelerator. The operation information includes the runtime interface information of the heterogeneous accelerator when executing the computational tasks of the target deep learning framework and the dependency library files of the heterogeneous accelerator when using the mathematical library. The operation requirements include the operation mode of the heterogeneous accelerator when executing the computational tasks of the target deep learning framework. Based on the runtime interface information, the corresponding interface code in the source code of the target deep learning framework is modified; based on the library files that the heterogeneous accelerator depends on when using the math library, the corresponding library file path in the source code of the target deep learning framework is modified; and based on the storage location of the third-party library code, the third-party library code of the target deep learning framework is obtained; based on the execution mode of the heterogeneous accelerator, the instruction set code of the heterogeneous accelerator is obtained, and the third-party library code is modified based on the instruction set code. The modified deep learning framework was evaluated and validated. If the modified deep learning framework passes the evaluation and verification, then the modified deep learning framework will be determined as the deep learning framework adapted to the heterogeneous accelerator.

2. The method according to claim 1, characterized in that, The modification of the third-party library code based on the instruction set code includes: Add the instruction set code to the third-party library code.

3. The method according to claim 1, characterized in that, The modification of the third-party library code based on the instruction set code includes: The instruction set replaces the original instruction set code of the heterogeneous accelerator in the third-party library.

4. The method according to any one of claims 1-3, characterized in that, The evaluation and verification of the modified deep learning framework includes: The modified deep learning framework is compiled. If compilation succeeds, then unit tests will be performed on the code of the modified deep learning framework. If the unit test passes, then benchmark testing will continue on the code of the modified deep learning framework. If the benchmark test is passed, the evaluation and verification of the modified deep learning framework is deemed successful.

5. The method according to claim 4, characterized in that, The process of compiling the modified deep learning framework includes: The compilation environment of the modified deep learning framework is determined based on the configuration version of the target deep learning framework. The modified deep learning framework is compiled according to the compilation environment and preset compilation commands. If compilation fails, the modified deep learning framework is adjusted based on the error log information generated during compilation failure until the modified deep learning framework compiles successfully.

6. The method according to claim 4, characterized in that, The unit testing of the modified deep learning framework code includes: Perform at least one type of unit test on the modified deep learning framework; If the test results of each type of unit test meet the test standard range, then the code unit test of the modified deep learning framework is deemed to have passed. If any of the test results for the unit tests of each type fail to meet the test standard range, then the test failure cases and corresponding error messages are obtained based on the test results, and the modified deep learning framework is adjusted based on the error messages corresponding to the test failure cases until the test results for all types of unit tests meet the test standard range.

7. The method according to claim 4, characterized in that, The benchmarking of the modified deep learning framework code includes: According to the preset binary packaging command, the code of the modified deep learning framework is packaged to generate a binary file; Based on the binary file, a deep learning model is obtained by training the network model using a pre-set dataset. The deep learning model was subjected to various types of performance tests; If all the performance tests of the deep learning model pass, then the modified deep learning framework is determined to have passed the benchmark test.

8. A deep learning framework adaptation device, characterized in that, The device includes: The acquisition module is used to acquire the operation information and operation requirements of the heterogeneous accelerator. The operation information includes the runtime interface information of the heterogeneous accelerator when executing the computational task of the target deep learning framework and the dependency library files of the heterogeneous accelerator when using the mathematical library. The operation requirements include the operation mode of the heterogeneous accelerator when executing the computational task of the target deep learning framework. The modification module is used to modify the corresponding interface code in the source code of the target deep learning framework according to the runtime interface information, modify the corresponding library file path in the source code of the target deep learning framework according to the library files that the heterogeneous accelerator depends on when using the math library, and obtain the third-party library code of the target deep learning framework according to the storage location of the third-party library code; obtain the instruction set code of the heterogeneous accelerator based on the execution mode of the heterogeneous accelerator, and modify the third-party library code according to the instruction set code; The evaluation module is used to evaluate and verify the modified deep learning framework. The determination module is used to determine the modified deep learning framework as a deep learning framework adapted to the heterogeneous accelerator if the evaluation and verification of the modified deep learning framework passes.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.