Web end deep learning framework test method based on constraint difference driving

By extracting and integrating the source code and documentation constraints of the Web platform and the native deep learning framework, test cases are generated, solving the problem of limited API coverage in the testing of deep learning frameworks on the Web platform, and realizing automated testing and defect discovery.

CN121050997APending Publication Date: 2025-12-02NAT UNIV OF DEFENSE TECH

Patent Information

Application Number
CN202511575758.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2025-12-02

AI Technical Summary

Technical Problem

Existing testing methods for deep learning frameworks on web platforms have limited API coverage, making it difficult to automatically generate valid inputs for APIs, and they also face challenges in terms of testing complexity due to the diversity and heterogeneity of browser environments.

Method used

By obtaining the source code and official documentation of the target APIs of native deep learning frameworks and web platform deep learning frameworks, we extract and merge source code constraints and documentation constraints, generate test cases using intersection and difference operations, identify boundary conditions, perform difference testing, and generate valid and boundary test cases.

Benefits of technology

It has enabled automated API testing of deep learning frameworks on web platforms, improving test coverage and effectiveness, and discovering potential implementation defects and abnormal behaviors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121050997A_ABST
    Figure CN121050997A_ABST
Patent Text Reader

Abstract

The invention provides a Web end deep learning framework test method based on constraint difference driving, and belongs to the technical field of network security. In the method, implementation source codes and official document information of target APIs in a native deep learning framework and a Web platform deep learning framework are obtained, source code constraints and document constraints of the target APIs in the native deep learning framework and the Web platform deep learning framework are extracted respectively, and constraint fusion is carried out; wherein the constraint fusion refers to execution of intersection and difference set operation; and determining a legal range of test input based on the constraints in the intersection set, identifying boundary conditions which may trigger abnormal behaviors based on the constraints in the difference set, further generating a test case and executing a test so as to mine defects existing in the Web platform deep learning framework. According to the method, through automatic extraction and analysis of the constraint difference between the frameworks, automatic API testing for the Web platform deep learning framework is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of network security technology, and in particular relates to a test method for web-based deep learning frameworks driven by constraint differences. Background Technology

[0002] Deep learning framework testing refers to the systematic verification of a framework's functionality to ensure the stability and correctness of the upper-layer deep learning system. Currently, commonly used testing techniques for deep learning frameworks mainly include differential testing and fuzz testing. Depending on the test cases, testing can be divided into model-level testing and API-level testing. Model-level testing involves building a complete deep learning model code as input and running the framework to test its core functions such as gradient calculation and model training, and to discover potential defects. API-level testing, on the other hand, targets a single API, generating compliant call code snippets and using methods such as mutation to discover vulnerabilities in the framework's interface design and implementation. Currently, testing research on native deep learning frameworks (such as TensorFlow and PyTorch) is relatively mature and has achieved significant results; in contrast, testing deep learning frameworks for web platforms is still in its early stages, facing many technical challenges and room for development.

[0003] Web browsers are among the most widely used application platforms today. To provide users with intelligent functionalities on these platforms, the deployment of deep learning models has become a critical requirement, driving the rise of deep learning frameworks for web platforms such as TensorFlow.js and Paddle.js. Deploying models directly in the browser not only avoids data interaction with servers, significantly reducing inference latency, but also enables real-time intelligent applications. For example, tasks such as human pose recognition can process video streams captured by cameras directly in the browser without uploading data to a server. Once the model and its dependencies are loaded, the application can continue to run even offline.

[0004] The quality and reliability of deep learning frameworks for web platforms are crucial, directly impacting the performance and stability of models and applications in browser environments. Compared to native deep learning frameworks, web platform deep learning frameworks are subject to numerous limitations imposed by the browser environment, such as limited memory access capabilities and incomplete support for hardware accelerators (e.g., GPUs). To address these limitations, web platform deep learning frameworks typically introduce acceleration mechanisms such as WebAssembly and WebGL to improve operational efficiency. However, these optimizations also introduce entirely new testing challenges. Compared to native deep learning frameworks, testing web platform deep learning frameworks not only requires verifying functional correctness but also must address highly heterogeneous execution environments: including the language characteristics of JavaScript and Node.js, implementation differences between different browsers, the diversity of hardware devices, and the inherent complexity of WebAssembly itself. These factors significantly increase the complexity and difficulty of the testing process. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention proposes a constraint-difference-driven testing method for Web deep learning frameworks; aiming to solve the problems of limited API coverage and difficulty in automatically generating valid inputs for APIs in existing Web platform deep learning framework testing.

[0006] This invention proposes a constraint-difference-driven testing method for Web deep learning frameworks. The method includes: Step S1, obtaining the implementation source code and official documentation information of the target API in the native deep learning framework and the Web platform deep learning framework, and extracting the source code constraints and documentation constraints of the target API in the native deep learning framework and the Web platform deep learning framework, respectively; Step S2, performing constraint fusion on the source code constraints and documentation constraints of the target API in the native deep learning framework and the Web platform deep learning framework; wherein, constraint fusion refers to performing intersection and difference operations; Step S3, determining the legal range of test inputs based on the constraints in the intersection, identifying boundary conditions that may trigger abnormal behavior based on the constraints in the difference, further generating test cases and executing tests to uncover defects existing in the Web platform deep learning framework.

[0007] In the method described above, the native deep learning framework refers to TensorFlow, and the web platform deep learning framework refers to TensorFlow.js.

[0008] In step S1, document constraints of the target API in the native deep learning framework and the Web platform deep learning framework are extracted. Specifically, this includes using a large language model as a document constraint extractor to extract document constraints of the target API from official documentation information, including input constraints of parameters and dependencies between parameters. In this process, by combining the thought chain prompting strategy and the sample learning process, the large language model is guided to gradually parse the semantics, value range, type restrictions, and dependencies of each parameter in the official documentation information by inputting annotated API constraint examples, and the parsing results are integrated into a formal constraint set.

[0009] In step S1, the source code constraints of the target API in the native deep learning framework and the Web platform deep learning framework are extracted. Specifically, this includes: parsing the implementation source code of the target API using static analysis to extract source code constraints, including conditional branch constraints and checker constraints. Among them, conditional branch constraints are obtained by analyzing the conditional statements related to the input parameters in the control flow, and checker constraints are obtained by matching parameter validation statements with predefined templates.

[0010] In step S2, the source code constraints of the target API in the native deep learning framework are as follows: Document constraints are The source code constraints of the target API in the deep learning framework of the Web platform are as follows: Document constraints are Then the constrained universal set C is represented as: The intersection of source code constraints in constraint fusion Represented as: ; The intersection of constraints in the document fusion Represented as: The intersection of global constraints in constraint fusion Represented as: Among them, the overall constraint intersection in constraint fusion represents the constraints that are adopted at both the implementation source code and official documentation levels, and are used to guide the generation of test cases.

[0011] In step S2: the difference set of source code constraints in constraint fusion Represented as: The difference set of constraints in the constraint fusion document Represented as: Global constraint difference set in constraint fusion Represented as: Among them, the overall constraint difference set in constraint fusion covers constraints that are explicitly defined in the native deep learning framework but are missing or inconsistently expressed in the Web platform deep learning framework, and is used to guide the generation of test cases.

[0012] In step S3, the legal range of test inputs is determined based on constraints in the intersection set, and boundary conditions that may trigger abnormal behavior are identified based on constraints in the difference set, further generating test cases. Specifically: initial test cases are generated based on the legal range of test inputs and boundary conditions that may trigger abnormal behavior; diverse test cases are generated by performing constraint-based mutations on the initial test cases. These mutations include type mutation, shape mutation, and boundary value mutation. Type mutation is performed within the data types supported by the native deep learning framework and the Web platform deep learning framework. Shape mutation targets tensor dimensional structures and is performed by adding, compressing, or rearranging dimensions. Boundary value mutation is performed based on critical conditions and boundary conditions.

[0013] In the method described, the defects existing in the deep learning framework of the Web platform include framework crashes, numerical errors, and inconsistencies.

[0014] In summary, this invention introduces constraint differences as guiding information to automatically generate legitimate and boundary test cases for target APIs. Specifically, based on the differences in API constraint descriptions between web platform deep learning frameworks and native deep learning frameworks, this invention proposes to utilize the richer and more rigorous constraint information in native deep learning frameworks to complete the constraints of web platform deep learning frameworks, thereby constructing a more complete constraint set. This completion process can be formalized as a comparative analysis between two constraint sets: the intersection represents the parameter space supported by both frameworks, which can be used to generate legitimate test cases that efficiently cover the underlying logic; while the difference reveals potential semantic inconsistencies between the two frameworks. Boundary test cases generated in these areas are more likely to trigger abnormal behavior of the web platform deep learning framework or expose implementation defects, thereby improving the effectiveness and coverage of the tests. This invention achieves automated API testing for web platform deep learning frameworks through the automatic extraction and analysis of constraint differences between frameworks.

[0015] The present invention achieves the following technical effects: (1) Using the present invention, the document constraints and code constraints of the target API in the cross-platform deep learning framework can be automatically extracted to construct comprehensive constraint information; (2) Using the present invention, the constraint information of the cross-platform framework can be fused and analyzed to extract the intersection and difference of constraints, and to generate clear legal boundaries and potential exception triggering conditions for test cases; (3) Using the present invention, legal and boundary test cases of the target API of the Web platform deep learning framework can be automatically generated, and differential testing can be performed in various backend environments (such as CPU, WebGL, WASM, different browsers, etc.) to discover potential API behavior differences and implementation defects. Attached Figure Description

[0016] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0017] Figure 1 This is a flowchart illustrating a constraint-difference-driven testing method for a Web deep learning framework according to an embodiment of the present invention. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] This invention proposes a test method for Web deep learning frameworks based on constraint difference-driven methods, the method comprising (e.g.) Figure 1 (As shown): Step S1: Obtain the implementation source code and official documentation information of the target API in the native deep learning framework and the Web platform deep learning framework, and extract the source code constraints and documentation constraints of the target API in the native deep learning framework and the Web platform deep learning framework respectively; Step S2: Perform constraint fusion on the source code constraints and documentation constraints of the target API in the native deep learning framework and the source code constraints and documentation constraints of the target API in the Web platform deep learning framework; where constraint fusion refers to performing intersection and difference operations; Step S3: Determine the legal range of test input based on the constraints in the intersection, identify the boundary conditions that may trigger abnormal behavior based on the constraints in the difference, further generate test cases and execute tests to discover the defects existing in the Web platform deep learning framework.

[0020] In some embodiments, the constraint difference-driven deep learning framework differential testing method for web platforms mainly includes three steps: constraint information extraction, constraint information fusion, and constraint difference-driven test case generation.

[0021] First, the implementation code and documentation information of the target APIs in the native deep learning framework and the Web platform deep learning framework are obtained, and the documentation constraints and code constraints of the target APIs in the two types of frameworks are extracted respectively. Then, constraint fusion is performed on the four types of constraint information: native deep learning framework documentation constraints, native deep learning framework code constraints, Web platform deep learning framework documentation constraints, and Web platform deep learning framework code constraints, i.e., intersection and difference operations are performed. Finally, the constraints in the intersection are used to define the legal range of test inputs, and the constraints in the difference are used to identify boundary conditions that may trigger abnormal behavior, thereby generating test cases and carrying out differential testing to uncover potential implementation defects in the Web platform deep learning framework.

[0022] In the method described above, the native deep learning framework refers to TensorFlow, and the web platform deep learning framework refers to TensorFlow.js.

[0023] In step S1, document constraints of the target API in the native deep learning framework and the Web platform deep learning framework are extracted. Specifically, this includes using a large language model as a document constraint extractor to extract document constraints of the target API from official documentation information, including input constraints of parameters and dependencies between parameters. In this process, by combining the thought chain prompting strategy and the sample learning process, the large language model is guided to gradually parse the semantics, value range, type restrictions, and dependencies of each parameter in the official documentation information by inputting annotated API constraint examples, and the parsing results are integrated into a formal constraint set.

[0024] In step S1, the source code constraints of the target API in the native deep learning framework and the Web platform deep learning framework are extracted. Specifically, this includes: parsing the implementation source code of the target API using static analysis to extract source code constraints, including conditional branch constraints and checker constraints. Among them, conditional branch constraints are obtained by analyzing the conditional statements related to the input parameters in the control flow, and checker constraints are obtained by matching parameter validation statements with predefined templates.

[0025] In some embodiments, the constraints of the web platform deep learning framework and native deep learning frameworks (such as TensorFlow.js and TensorFlow) are captured in their current APIs. The richer and more rigorous constraint information from native deep learning frameworks is used to complete the parameter constraints of the web platform deep learning framework, thereby addressing the difficulty of generating valid inputs on the web platform. This completion mechanism can be used to improve the generation of legitimate test cases and to help identify potential boundary defects.

[0026] TensorFlow.js's 2D convolution API does not explicitly describe the constraints of the `strides` parameter in its documentation, while native TensorFlow provides a detailed description of this parameter. Therefore, the documentation constraints of native deep learning frameworks can compensate for the lack of constraint information in web platform deep learning frameworks, thus building a more complete set of constraints. Furthermore, differences in constraint rules between web platform deep learning frameworks and native deep learning frameworks may reveal implementation flaws or design issues. These differences suggest that web platform frameworks may not cover certain boundary scenarios, requiring verification through difference-driven testing. Besides documentation constraints, the two types of frameworks also differ in parameter constraints in their API source code implementations. In the 2D convolution API, TensorFlow.js only checks the shape of the `filter` parameter, while native TensorFlow also verifies the validity of the input tensor and filter dimension information.

[0027] To capture these differences, this invention extracts constraint information from the corresponding APIs in the Web platform and the native deep learning framework from both official documentation and source code, providing support for subsequent differential testing of the Web platform's deep learning framework. Therefore, accurately extracting and integrating the API parameter constraints of cross-platform frameworks is crucial.

[0028] First, document constraints and code constraints are extracted from both the web platform and the native deep learning framework, forming four types of constraint information. Due to differences in the description styles and formats of the official documentation for the two frameworks, traditional template- or rule-based methods struggle to extract parameter constraints uniformly and accurately. To address this issue, this invention introduces a Large Language Model (LLM) as a general document constraint extractor. Leveraging its strong generalization ability in natural language understanding tasks, it extracts two types of constraint information from the complex framework document structure: first, input constraints of parameters (such as the type and shape requirements of kernel_size in a 2D convolution API); and second, dependencies between parameters (such as the dimensional compatibility constraints between kernel_size and the input tensor). In the specific implementation, combining a thought chain prompting strategy and few-shot learning, a small number of manually annotated API constraint examples are input to guide the LLM to gradually parse the semantics, value ranges, type restrictions, and dependencies of each parameter in the document, and the results are abstracted into a formalized set of constraint predicates. For code constraints, a static analysis method is used to parse the API implementation code to extract two types of code constraint information: first, conditional branch constraints, mainly obtained by analyzing conditional statements related to input parameters in the control flow; and second, checker constraints, implemented by matching typical parameter validation statements using predefined templates. Specifically, a control flow graph (CFG) is first constructed for each API's code. By traversing the conditional decision branches in the control path, logical decision statements related to input parameters are extracted, thereby obtaining the constraints of the API's input parameters. Furthermore, different deep learning frameworks on different platforms employ specialized parameter checking mechanisms for input validity verification, such as the OP_REQUIRE macro in TensorFlow and util.assert in TensorFlow.js. These mechanisms typically have a fixed format and contain rich parameter constraint information, which this invention extracts through template recognition and syntax matching.

[0029] In step S2, the source code constraints of the target API in the native deep learning framework are as follows: Document constraints are The source code constraints of the target API in the deep learning framework of the Web platform are as follows: Document constraints are Then the constrained universal set C is represented as: The intersection of source code constraints in constraint fusion Represented as: ; The intersection of constraints in the document fusion Represented as: The intersection of global constraints in constraint fusion Represented as: Among them, the overall constraint intersection in constraint fusion represents the constraints that are adopted at both the implementation source code and official documentation levels, and are used to guide the generation of test cases.

[0030] In step S2: the difference set of source code constraints in constraint fusion Represented as: The difference set of constraints in the constraint fusion document Represented as: Global constraint difference set in constraint fusion Represented as: Among them, the overall constraint difference set in constraint fusion covers constraints that are explicitly defined in the native deep learning framework but are missing or inconsistently expressed in the Web platform deep learning framework, and is used to guide the generation of test cases.

[0031] In some embodiments, all extracted parameter constraints are uniformly represented as a formalized set of constraint predicates, and constraints from different sources are fused to find the intersection and difference of the constraints. Specifically, the constraints for each API of the Web platform deep learning framework include four sets: the Web platform deep learning framework document constraint set WD, the Web platform deep learning framework code constraint set WC, the native deep learning framework document constraint set ND, and the native deep learning framework code constraint set NC. The complete set of constraints can then be represented as: .

[0032] To reveal the commonalities and differences between the two frameworks at the parameter constraint level, the following set operations are defined. First, the intersection represents the constraints shared by the two frameworks, including document-level intersection, code-level intersection, and overall constraint intersection. This part represents the parameter constraints that are consistently adopted at both the documentation and code implementation levels, and can be regarded as general, widely followed rules used to guide the generation of valid test cases by the deep learning framework API of the web platform.

[0033] On the other hand, the difference set is used to express the absence or inconsistency of one source relative to another. This invention particularly focuses on missing constraints in deep learning frameworks on web platforms, including missing web platform framework documentation, missing code, and missing overall constraints. This set covers parameter constraints that are clearly defined in native deep learning frameworks but are missing or inconsistently expressed in web platform frameworks. Targeted test cases generated based on this subset are used to uncover potential implementation defects in web platform frameworks.

[0034] In step S3, the legal range of test inputs is determined based on constraints in the intersection set, and boundary conditions that may trigger abnormal behavior are identified based on constraints in the difference set, further generating test cases. Specifically: initial test cases are generated based on the legal range of test inputs and boundary conditions that may trigger abnormal behavior; diverse test cases are generated by performing constraint-based mutations on the initial test cases. These mutations include type mutation, shape mutation, and boundary value mutation. Type mutation is performed within the data types supported by the native deep learning framework and the Web platform deep learning framework. Shape mutation targets tensor dimensional structures and is performed by adding, compressing, or rearranging dimensions. Boundary value mutation is performed based on critical conditions and boundary conditions.

[0035] In the method described, the defects existing in the deep learning framework of the Web platform include framework crashes, numerical errors, and inconsistencies.

[0036] In some embodiments, initial test cases are generated based on the intersection and difference of the constraint information obtained above, and the Web framework API is tested through mutation execution. It was observed that some parameters in the extracted constraints have obvious dependencies. Therefore, a dependency-aware combined mutation strategy is introduced for parameters with dependencies: during the mutation process, the constraint relationships between parameters are comprehensively considered, and the values ​​of multiple parameters are jointly adjusted to improve the effectiveness of the test, avoiding the generation of a large number of invalid test cases due to ignoring parameter dependencies, or the low test coverage efficiency due to independent mutation of single parameters. In the mutation operation design, three main strategies are adopted: type mutation, shape mutation, and boundary value mutation, to improve the diversity and coverage of test cases. Type mutation performs conversions within the data type range supported by the framework, for example, replacing the int32 type of the input parameter with the float32 type, to verify the framework's fault tolerance and processing consistency for different types of input. Shape mutation focuses on the dimensional structure of tensors, generating inputs with significant structural changes by adding, compressing, or rearranging dimensions, thereby examining the robustness of the framework when handling high-dimensional or non-standard inputs. Boundary value mutation generates input values ​​close to critical conditions or illegal boundaries based on pre-extracted constraint information, such as minimum or maximum values ​​exceeding the legal range, null inputs, negative values, or values ​​containing special values ​​(such as NaN or INF), aiming to trigger boundary handling defects in the framework implementation.

[0037] Considering the diversity of web browser runtime environments, differential testing is performed on the API. By comparing the output results under different environments, various types of potential defects can be identified. First, there are crash errors, which refer to serious anomalies such as assertion failures and illegal memory accesses during the test, causing the framework to interrupt or crash. Additionally, there are other crash errors, such as the appearance of illegal values ​​like NaN and INF in the output, reflecting numerical stability issues in the calculation process. Finally, there are inconsistency defects, where the API's output results differ across different backend execution environments (such as CPU, WebGL, and WASM) or different browser platforms, and this difference exceeds a set threshold.

[0038] In summary, the objective of this invention is to: given a target API of a Web platform deep learning framework, obtain the documentation and code constraints of the corresponding Web platform deep learning framework and the native deep learning framework, perform intersection and difference operations, utilize the differences between constraints to generate and mutate test cases, and perform differential testing to check for potential defects in the Web platform deep learning framework.

[0039] Regarding the constraint information fusion design, the first step is to extract document and code constraints for the target API from both the web platform deep learning framework and the native deep learning framework. Document constraints are extracted using LLM (Limited Least Meaning) techniques, while code constraints are extracted using static analysis. Then, intersection and difference operations are performed on the four types of constraint information—native deep learning framework document constraints, native deep learning framework code constraints, web platform deep learning framework document constraints, and web platform deep learning framework code constraints—to reveal the commonalities and differences between the two frameworks at the parameter constraint level.

[0040] This paper discusses the design of constraint-driven test case generation. Based on the extracted constraint intersection and difference, initial test cases are generated, and mutation operations are performed on the deep learning framework API of the web platform to execute differential tests. To address the dependencies between parameters, a dependency-aware combined mutation strategy is introduced to jointly adjust the values ​​of multiple parameters to improve test effectiveness. Mutation operations include type mutation, shape mutation, and boundary value mutation to enhance input diversity and coverage depth. Finally, differential tests are executed in multiple backend environments to check for framework defects such as crashes, numerical errors, and inconsistent outputs.

[0041] This invention introduces constraint differences as guiding information to automatically generate legitimate and boundary test cases for target APIs. Specifically, based on the differences in API constraint descriptions between web platform deep learning frameworks and native deep learning frameworks, this invention proposes to supplement the constraints of web platform deep learning frameworks using the richer and more rigorous constraint information in native deep learning frameworks, thereby constructing a more complete constraint set. This supplementation process can be formalized as a comparative analysis between two constraint sets: the intersection represents the parameter space supported by both frameworks, which can be used to generate legitimate test cases that efficiently cover the underlying logic; while the difference reveals potential semantic inconsistencies between the two frameworks. Boundary test cases generated in these areas are more likely to trigger abnormal behavior of the web platform deep learning framework or expose implementation defects, thereby improving the effectiveness and coverage of the tests. This invention achieves automated API testing for web platform deep learning frameworks through the automatic extraction and analysis of constraint differences between frameworks.

[0042] The present invention achieves the following technical effects: (1) Using the present invention, the document constraints and code constraints of the target API in the cross-platform deep learning framework can be automatically extracted to construct comprehensive constraint information; (2) Using the present invention, the constraint information of the cross-platform framework can be fused and analyzed to extract the intersection and difference of constraints, and to generate clear legal boundaries and potential exception triggering conditions for test cases; (3) Using the present invention, legal and boundary test cases of the target API of the Web platform deep learning framework can be automatically generated, and differential testing can be performed in various backend environments (such as CPU, WebGL, WASM, different browsers, etc.) to discover potential API behavior differences and implementation defects.

[0043] Please note that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. The above embodiments only illustrate several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be pointed out that for those skilled in the art, several modifications and improvements can be made 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 patent application should be determined by the appended claims.

Claims

1. A test method for web-based deep learning frameworks based on constraint difference-driven approaches, characterized in that, The method includes: Step S1: Obtain the implementation source code and official documentation information of the target API in the native deep learning framework and the Web platform deep learning framework, and extract the source code constraints and documentation constraints of the target API in the native deep learning framework and the Web platform deep learning framework respectively. Step S2: Perform constraint fusion on the source code constraints and documentation constraints of the target API in the native deep learning framework and the source code constraints and documentation constraints of the target API in the Web platform deep learning framework; Among them, constraint fusion refers to performing intersection and difference operations; Step S3: Determine the legal range of test inputs based on the constraints in the intersection set, identify boundary conditions that may trigger abnormal behavior based on the constraints in the difference set, further generate test cases and execute tests to uncover defects in the deep learning framework of the Web platform.

2. The test method for a web-based deep learning framework based on constraint difference driving according to claim 1, characterized in that, In the method described above, the native deep learning framework refers to TensorFlow, and the web platform deep learning framework refers to TensorFlow.js.

3. The test method for a web-based deep learning framework based on constraint difference driving according to claim 2, characterized in that, In step S1, the document constraints of the target API in the native deep learning framework and the Web platform deep learning framework are extracted; specifically, this includes: Using a large language model as a document constraint extractor, document constraints of the target API are extracted from official documentation information, including input constraints of parameters and dependencies between parameters. Specifically, by combining the thought chain prompting strategy with the sample learning process, the large language model is guided to gradually parse the semantics, value range, type restrictions, and dependencies of each parameter in the official documentation information by inputting labeled API constraint examples, and the parsing results are integrated into a formal constraint set.

4. The test method for a web-based deep learning framework based on constraint difference driving according to claim 1, characterized in that, In step S1, the source code constraints of the target API in the native deep learning framework and the Web platform deep learning framework are extracted; specifically, this includes: Static analysis is used to parse the source code of the target API implementation in order to extract source code constraints, including conditional branch constraints and checker constraints. Specifically, conditional branch constraints are obtained by analyzing conditional statements related to input parameters in the control flow, and checker constraints are obtained by matching parameter validation statements with predefined templates.

5. The test method for a web-based deep learning framework based on constraint difference driving according to claim 4, characterized in that, In step S2, the source code constraints of the target API in the native deep learning framework are as follows: Document constraints are The source code constraints of the target API in the deep learning framework of the Web platform are as follows: Document constraints are Then the constraint universal set C is represented as: , Intersection of source code constraints in constraint fusion Represented as: , The intersection of constraints in the constraint fusion document Represented as: , Global constraint intersection in constraint fusion Represented as: , In constraint fusion, the overall constraint intersection represents the constraints that are adopted at both the implementation source code and official documentation levels, and are used to guide the generation of test cases.

6. The test method for a web-based deep learning framework based on constraint difference driving according to claim 5, characterized in that, In step S2: Difference of source code constraints in constraint fusion Represented as: , Difference of constraints in constraint fusion document Represented as: , Global constraint difference set in constraint fusion Represented as: , Among them, the overall constraint difference set in constraint fusion covers constraints that are clearly defined in the native deep learning framework but are missing or inconsistently expressed in the Web platform deep learning framework, and is used to guide the generation of test cases.

7. The test method for a web-based deep learning framework based on constraint difference driving according to claim 6, characterized in that, In step S3, the legal range of test inputs is determined based on constraints in the intersection set, and boundary conditions that may trigger abnormal behavior are identified based on constraints in the difference set, further generating test cases; wherein: Initial test cases are generated based on the legal range of test inputs and boundary conditions that may trigger abnormal behavior. Diverse test cases are generated by mutating the initial test cases based on constraint association. The mutations include type mutation, shape mutation, and boundary value mutation. Type mutation is performed within the data types supported by the native deep learning framework and the Web platform deep learning framework. Shape mutation is performed on tensor dimensional structures by adding, compressing, or rearranging dimensions. Boundary value mutation is performed based on critical conditions and boundary conditions.

8. The test method for a web-based deep learning framework based on constraint difference driving according to claim 7, characterized in that, In the method described, the defects existing in the deep learning framework of the Web platform include framework crashes, numerical errors, and inconsistencies.

Citation Information

Patent Citations

  • Security test method and device, equipment and storage medium

    CN116127464A

  • Large-model-assisted program function automatic sensing fuzzy testing method and large-model-assisted program function automatic sensing fuzzy testing system

    CN119690854A

  • Test case determination method and device, storage medium and electronic equipment

    CN119690858A

Cited By

  • Directional fuzzy testing method and device for deep learning library

    CN121326771A