Deep learning operator performance analysis method, electronic equipment and medium

By using function wrapping mechanisms and context managers, non-intrusive, cross-platform deep learning operator performance analysis is achieved, solving the framework binding and granular control problems of existing tools, and providing fine-grained performance testing and reliable cross-platform tools.

CN121833436APending Publication Date: 2026-04-10ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-18
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing deep learning performance analysis tools suffer from problems such as strong framework binding, strong code intrusion, difficulty in granular control, insufficient support for nested use, and lack of objectivity and accuracy in cross-platform performance comparisons, making it difficult to achieve unified performance testing and fine-grained performance analysis across platforms.

Method used

It employs a function wrapper mechanism to capture the function calls to be monitored in the deep learning model through the monitoring wrapper layer, records timestamps and accumulates statistical data, supports fine-grained control and nested monitoring, and uses a context manager to achieve non-intrusive monitoring. It is suitable for any Python-based deep learning framework.

Benefits of technology

It enables unified performance testing across platforms, provides accurate time measurement and flexible monitoring granularity control, reduces the barrier to entry and maintenance costs, supports complex testing scenarios, and ensures the reliability and accuracy of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833436A_ABST
    Figure CN121833436A_ABST
Patent Text Reader

Abstract

The invention discloses a deep learning operator performance analysis method, electronic equipment and a medium, and the method comprises the steps: determining a target module of a to-be-analyzed deep learning model, and traversing attributes in the target module to screen out a to-be-monitored function; establishing a monitoring packaging layer for the function to be monitored, generating a corresponding packaging function, and establishing a mapping relation between the function to be monitored and the packaging function; in the execution process of the deep learning model, capturing a call request for the to-be-monitored function through the monitoring packaging layer; in response to the calling request, recording a starting timestamp of calling, executing the function to be monitored, recording an ending timestamp, calculating execution duration, and accumulating statistical data into a global statistical storage structure; and after the analysis is finished, calculating the performance index of each to-be-monitored function based on the statistical data in the global statistical storage structure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of deep learning performance analysis, and more particularly to a method for analyzing the performance of deep learning operators, electronic devices, and media. Background Technology

[0002] With the rapid development of deep learning technology, the scale and complexity of neural network models are constantly increasing, making performance optimization a key issue in model deployment. In practical applications, fine-grained performance analysis of the inference or training process of deep learning models is needed to identify performance bottlenecks and perform targeted optimizations.

[0003] Existing deep learning performance analysis tools have the following main shortcomings: The issue of strong framework dependency is quite prominent. Most performance analysis tools are tightly bound to specific deep learning frameworks. For example, PyTorch's TensorBoard Profiler is powerful enough to measure operator latency, GPU utilization, and operator call order, but it cannot be applied to other deep learning frameworks or computing platforms such as SAS Viya. This makes it impossible to use a unified testing methodology in cross-platform performance comparison scenarios, resulting in poor comparability of test results and making it difficult to objectively assess performance differences between different platforms.

[0004] High code invasiveness is also a common problem. Some performance analysis methods require modifying the code under test to insert performance monitoring points at critical locations. This not only increases code complexity and maintenance costs, but may also affect the execution logic and performance of the original code, leading to distorted measurement results.

[0005] The difficulty in granular control limits the flexibility of tools. Existing tools often either provide a global monitoring mode to monitor all operations, resulting in a large amount of redundant data, or require manual specification of monitoring points one by one, which leads to a large workload and the risk of missing key operators. There is a lack of flexible granular control mechanisms to balance the monitoring scope and data simplification.

[0006] The limitations of statistical information affect the depth of analysis. Some simple tools can only provide statistics on the number of calls, but cannot accurately measure the actual execution time of each operator, or the accuracy of the time measurement is insufficient to identify performance differences at the microsecond level, making it difficult to locate fine-grained performance bottlenecks.

[0007] Insufficient support for nested monitoring limits its application in complex scenarios. In complex testing scenarios, it may be necessary to enable and disable monitoring in different code segments, or to perform nested monitoring to compare the performance of different levels. Existing tools do not support nested monitoring well, which can easily lead to runtime errors due to repeated decoration or error recovery.

[0008] In real-world projects, it's often necessary to compare the performance differences between different implementations, such as comparing the execution efficiency of PyTorch Triton operators versus SAS Viya operators. This requires the use of unified performance testing methods and scripts. However, existing tools cannot meet this need, resulting in a lack of objectivity and accuracy in performance comparisons, which affects technology selection and optimization decisions.

[0009] Therefore, there is a need for a general, non-intrusive, and fine-grained method for automated performance analysis of deep learning operators, which can achieve cross-platform unified performance testing without modifying the original code, and provide accurate time measurement and flexible monitoring granularity control. Summary of the Invention

[0010] To address the shortcomings of existing technologies, embodiments of the present invention provide a method for analyzing the performance of deep learning operators, an electronic device, and a medium.

[0011] In a first aspect, embodiments of the present invention provide a method for performance analysis of deep learning operators, the method comprising: Identify the target module of the deep learning model to be analyzed, and traverse the attributes in the target module to filter out the functions to be monitored; A monitoring wrapper layer is established for the function to be monitored, a corresponding wrapper function is generated, and a mapping relationship is established between the function to be monitored and the wrapper function; During the execution of the deep learning model, the monitoring wrapper layer captures the call requests to the function to be monitored; in response to the call request, the start timestamp of the call is recorded, the function to be monitored is executed and the end timestamp is recorded, the execution time is calculated, and the statistical data is accumulated in the global statistical storage structure. After the analysis is completed, the performance metrics of each of the monitored functions are calculated based on the statistical data in the global statistical storage structure.

[0012] In a second aspect, embodiments of the present invention provide an electronic device, comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the deep learning operator performance analysis method described above.

[0013] Thirdly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the aforementioned deep learning operator performance analysis method.

[0014] Fourthly, embodiments of the present invention provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the aforementioned deep learning operator performance analysis method.

[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) Strong versatility and wide applicability: This invention is based on the function wrapping mechanism and is applicable to any deep learning framework based on Python. It can use a unified test script to compare the performance of operators in different frameworks, solves the problem of strong binding of existing tool frameworks, and provides a reliable tool for cross-platform performance comparison.

[0016] (2) Non-intrusive design and easy to use: No need to modify the code under test. Monitoring can be temporarily enabled through the context manager. After the test is completed, the original state will be automatically restored without affecting the subsequent code execution. This reduces the threshold for use and maintenance costs, and avoids logical interference and performance distortion caused by code intrusion.

[0017] (3) Supports nested monitoring and has strong scenario adaptability: The packaging state is managed through the reference counting mechanism, which supports multi-level nested monitoring scenarios and repeated monitoring. It will not cause runtime errors due to repeated packaging or error recovery, and meets the needs of complex testing scenarios. Attached Figure Description

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

[0019] Figure 1 A schematic diagram illustrating the deep learning operator performance analysis method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0020] 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.

[0021] It should be noted that, unless otherwise specified, the features in the following embodiments and implementation methods can be combined with each other.

[0022] like Figure 1 As shown in the figure, this embodiment of the invention provides a method for performance analysis of deep learning operators, the method comprising the following steps: Step S1: Determine the target module of the deep learning model to be analyzed, and traverse the attributes in the target module to filter out the functions to be monitored.

[0023] Furthermore, the process of traversing the attributes in the target module includes: Obtain all attributes of the target module and determine the type of each attribute; If the attribute type is a function, then add it to the set of functions to be monitored; If the attribute type is a submodule, the submodule is recursively traversed, and the functions obtained during the recursion are added to the set of functions to be monitored. For example, when traversing the torch module, the torch.nn submodule is recursively entered, and then the torch.nn.functional submodule is entered, and finally monitoring wrappers are built for underlying operator functions such as torch.nn.functional.linear.

[0024] If the attribute type is a class, then iterate through all the methods contained in that class and add those methods to the set of functions to be monitored.

[0025] Furthermore, the process of traversing all methods contained in the class and adding them to the set of functions to be monitored includes: Determine whether the name of the method exists in a preset set of operator overload method identifiers, wherein the set of operator overload method identifiers contains; add Addition operator, multiplication operator (mul), sub Subtraction operator, Truediv division operator, Matmul matrix multiplication operator, pow exponentiation operator mod Modulo operator; If such a method exists, it is marked as an operator overload and added to the set of functions to be monitored. By establishing a monitoring wrapper layer for operator overload methods, performance monitoring of tensor operations can be achieved. In this way, when tensor operation expressions (such as tensor_a + tensor_b or tensor_a @ tensor_b) are used in deep learning code, these operations can be automatically captured and performance statistics can be performed. This allows the present invention to trace the actual computation operations hidden behind the operator syntax, providing more complete performance analysis coverage.

[0026] Furthermore, the process of traversing the target modules also includes setting up a module filtering mechanism, specifically including: A predefined set of module filtering rules is provided, which includes module name patterns that need to be skipped. The module name patterns are strings or regular expressions used to match module paths. During the traversal of target modules, for each module to be processed, a filtering check is performed before the traversal operation: the complete path of the module is obtained, and the complete path is matched one by one with the module name patterns in the module filtering rule set. If the complete path matches any module name pattern, the module is determined to meet the filtering conditions. If a module meets the filtering criteria, skip that module and do not perform traversal or create a monitoring wrapper layer for it. For distributed training scenarios, the name patterns of distributed communication-related modules are pre-defined in the module filtering rule set to avoid communication blocking or system abnormalities caused by creating a monitoring wrapper layer for distributed communication primitives. When recursively traversing submodules, a filtering check is performed before entering each submodule. Submodules that meet the filtering conditions are skipped directly without recursive processing. By using a module filtering mechanism, modules that may cause system instability can be excluded, thereby improving the stability and compatibility of the performance analysis system.

[0027] Step S2: Establish a monitoring wrapper layer for the function to be monitored, generate the corresponding wrapper function, and establish a mapping relationship between the function to be monitored and the wrapper function.

[0028] Furthermore, the process of establishing a monitoring wrapper layer for the function to be monitored includes: A reference counting mapping table is established to record the packaging state of each function to be monitored. The reference counting mapping table uses the unique identifier of the function to be monitored as the key and the reference count value as the value. The reference counting mapping table is empty in the initial state. When a request is made to create a monitoring wrapper layer for a function to be monitored, the reference count mapping table is queried. If the reference count of the function to be monitored is zero, then the monitoring wrapper layer is created and the reference count is set to 1. If the reference count of the function to be monitored is greater than zero, then the reference count is simply incremented by 1, and the monitoring wrapper layer is not created again.

[0029] Step S3: During the execution of the deep learning model, the call request to the function to be monitored is captured through the monitoring wrapper layer; in response to the call request, the start timestamp of the call is recorded, the function to be monitored is executed and the end timestamp is recorded, the execution time is calculated, and the statistical data is accumulated in the global statistical storage structure.

[0030] Furthermore, the global statistical storage structure uses the unique identifier of the function as the key and statistical tuples as the value; The statistical tuples include at least: The cumulative call count field records the total number of times the corresponding function was called during the monitoring period; The cumulative execution time field records the total execution time of the corresponding function during the monitoring period.

[0031] Step S4: After the analysis is completed, calculate the performance index of each of the monitored functions based on the statistical data in the global statistical storage structure.

[0032] Furthermore, the process of calculating the performance metrics of each of the monitored functions includes: Traverse the global statistics mapping table, and for each unique function identifier, obtain the cumulative number of calls and the cumulative execution time from the statistics tuple, and calculate the average execution time, which is equal to the cumulative execution time divided by the cumulative number of calls; Construct performance metrics data that include unique function identifiers, call frequency, cumulative time consumption, and average time consumption; All performance metrics data are sorted according to the preset sorting dimensions. If the user specifies the number of outputs N, the first N records are extracted from the sorted result list as the final output. The final output is then formatted as a performance analysis report.

[0033] Furthermore, the method also includes: implementing temporary monitoring through a context manager, including: Define a monitoring context, which includes a set of functions to be monitored and a reset flag; the reset flag is a boolean value used to indicate whether to clear historical statistics when entering the context; When executing the monitoring context, if the reset flag is true, then it is determined whether to clear the global statistics storage structure based on the reset flag. Execute deep learning model code within the scope of the monitoring context, record performance data through the monitoring wrapper layer, and record it to the global statistical storage structure; Upon exiting the monitoring context, the function's recovery operation is executed, removing the monitoring wrapper layer.

[0034] The context manager mechanism enables precise performance analysis of a specified code scope. Monitoring is only effective within the scope of the context and does not affect the execution of code outside the context.

[0035] Furthermore, the monitoring context supports nested use, and the processing in nested scenarios includes: In a nested monitoring scenario, there are an outer monitoring context and an inner monitoring context. The outer monitoring context enters first and exits last, while the inner monitoring context enters last and exits last. At the wrapper level: Due to the use of reference counting management mechanism, when entering the outer monitoring context, a monitoring wrapper layer is created for the original function and the reference count value is set to 1; when entering the inner monitoring context, if the inner layer contains the same function to be monitored, the reference count value of the function to be monitored is incremented by 1, and the monitoring wrapper layer is not created again. At the statistical data level: if the reset flags of both the outer and inner monitoring contexts are false, the two contexts share the same global statistics mapping table, and the statistical data accumulates throughout the nesting process; if the reset flag of the inner monitoring context is true, the global statistics mapping table is cleared when entering the inner context, and the statistical data accumulated in the outer context is cleared. At the recovery level: when exiting the inner monitoring context, the reference count of the function to be monitored is decremented by 1. If the reference count is greater than zero after decrementing by 1, no actual recovery operation is performed. When exiting the outer monitoring context, the reference count is decremented by 1 again. If the reference count is zero at this time, the actual recovery operation is performed, and the reference of the wrapper function is restored to the reference of the function to be monitored.

[0036] Example 1: Performance Analysis of Feedforward Neural Network Suppose we need to analyze the performance characteristics of a simple feedforward neural network model. This model contains two fully connected layers: the first layer maps a 10-dimensional input to a 5-dimensional hidden layer, and the second layer maps the hidden layer to a 1-dimensional output, using the ReLU activation function in between.

[0037] The complete process for performance monitoring using the method of this invention is as follows: The process begins with preparation. A monitoring context is created, specifying the target module as the `torch` module, and a reset flag is set to true to clear old data. The system then iterates through the `torch` module, identifying attributes of all function types and establishing monitoring wrapper layers. The iteration recursively enters the `torch.nn.functional` submodule, creating monitoring wrappers for functions such as `linear` and `ReLU`. Simultaneously, it iterates through the `torch.Tensor` class, creating monitoring wrappers for its operator overload methods. During this iteration, the `torch.distributed` module is skipped by filtering rules. For each wrapped function, the system saves its original version to a backup map and sets the reference count to 1.

[0038] Then the execution phase begins. The model's forward propagation is performed within the monitoring context, passing the input tensor to the model object. When the code inside the model calls `self.fc1(x)`, it actually triggers the `torch.nn.functional.linear` function. Since the `linear` function is wrapped, the call is entered into the monitoring wrapper layer. The wrapper layer first generates the function identifier "torch.nn.functional.linear", then records the start timestamp, then calls the original `linear` function to perform matrix operations, and finally records the end timestamp and calculates the execution duration. The wrapper layer updates the statistics for the `linear` function in the global statistics map, increasing the call count from 0 to 1 and adding the execution duration to the cumulative time. Similarly, when the `torch.relu` activation function and the second `linear` operation are executed, the corresponding monitoring wrapper layers capture these calls and update the statistics. Ultimately, the call count for the `linear` function becomes 2, and the call count for the `relu` function becomes 1.

[0039] Finally, the analysis phase begins. Upon exiting the monitoring context, a recovery operation is performed, restoring all wrapped functions to their original state. Then, the performance metric calculation function is invoked, specifying sorting by cumulative time in descending order. The system traverses the global statistics mapping table. For linear functions, it extracts the call count (2) and cumulative time (e.g., 0.0012 seconds), calculating the average time as 0.0006 seconds; for ReLU functions, it extracts the call count (1) and cumulative time (0.0005 seconds), calculating the average time as 0.0005 seconds. The system sorts these records by cumulative time and generates a performance analysis report. The report shows that linear operations are the primary source of time consumption, providing direction for subsequent optimization.

[0040] Example 2: Cumulative Statistical Analysis In deep learning model training or long-duration inference scenarios, it is sometimes necessary to perform cumulative statistical analysis and comparative analysis of performance across multiple stages. This invention achieves the cumulative statistical function by controlling the reset flag parameter of the monitoring context.

[0041] Suppose we need to compare the overall performance characteristics of 10 inferences and 30 inferences. First, create an initial monitoring context, set the reset flag to true, and perform 10 model inferences within that context. Function calls triggered by each inference are captured by the monitoring wrapper layer, and statistics are continuously accumulated. After 10 iterations, call the statistics output function to display the number of calls and cumulative time for each function across the 10 inferences; for example, the linear function was called 20 times, with a cumulative time of 0.012 seconds.

[0042] Then, a second monitoring context is created. Crucially, the reset flag is set to false to prevent clearing previous statistics. Within this second context, 20 more model inferences are executed. Due to the reference counting mechanism, wrapping operations of the same function are handled correctly, preventing duplicate wrapping. Function calls during these 20 iterations continue to update the global statistics map, accumulating new call counts and execution times into the existing data. After the second context exits, the statistics output function is called again, displaying the cumulative results of the 30 inferences, for example, 60 linear function calls and a cumulative execution time of 0.036 seconds.

[0043] By comparing the average execution time of two outputs, we can determine whether the performance of a deep learning model is stable. If the average execution time is basically the same, it indicates that there is no performance fluctuation; if the average execution time decreases later, there may be a caching warm-up effect; if the average execution time increases later, there may be a resource contention problem. This cumulative statistical mode is particularly suitable for analyzing performance trends throughout the entire training process.

[0044] Example 3: Module-Specific Analysis When analyzing large-scale deep learning frameworks, global monitoring generates a large amount of data. This invention supports selective monitoring of specific modules, enabling fine-grained, specialized analysis.

[0045] Assuming we only care about the performance of the neural network functions and not the underlying tensor operations, when creating the monitoring context, we set the target module set to contain only the `torch.nn.functional` module. The system only performs traversal and wrapping operations on this module; other modules such as `torch.tensor` are unaffected. After model inference, the statistical results only include functions within the `torch.nn.functional` module, such as linear, ReLU, and dropout, resulting in a more concise and focused output.

[0046] The target module set also supports multiple modules; for example, setting both `torch.nn.functional` and `torch.cuda` simultaneously allows for joint analysis of the performance of neural network functions and CUDA synchronization operations. This flexible granular control mechanism adapts to various needs, from macro-level global analysis to micro-level specific analysis.

[0047] Example 4: Cross-platform performance comparison One important application of this invention is comparing the performance differences between different deep learning frameworks. By employing a unified monitoring mechanism and statistical methods, directly comparable performance data can be generated for different platforms.

[0048] Define a standard test function that takes the model, input data, and number of iterations as parameters. Internally, the function performs a specified number of model inferences using a monitoring context and then returns the statistical results. Test the equivalent model on the PyTorch platform and another platform using the exact same test function, obtaining two sets of statistical data. For identical operators in both sets of data (based on function semantics, such as linear layer operators on the two platforms), extract their cumulative execution time and calculate the performance ratio. Output the comparison results, for example, showing that linear layer operations are 1.5 times faster on the other platform.

[0049] Because the same time measurement methods and statistical algorithms are used, the test results of the two platforms are comparable, eliminating measurement biases introduced by different tools. This standardized comparison method provides an objective basis for technology selection and optimization decisions.

[0050] In summary, this invention, based on a function wrapping mechanism, is applicable to any Python-based deep learning framework. It allows for the comparison of operator performance across different frameworks using a unified test script, resolving the issue of strong framework binding in existing tools and providing a reliable tool for cross-platform performance comparison. Furthermore, this invention requires no modification to the code under test; monitoring can be temporarily enabled via a context manager, and the original state is automatically restored after testing, without affecting subsequent code execution. This lowers the barrier to entry and maintenance costs, avoiding logical interference and performance distortion caused by code intrusion. This invention manages the wrapping state through a reference counting mechanism, supporting multi-level nested monitoring scenarios and repeated monitoring without runtime errors due to duplicate wrapping or error recovery, meeting the needs of complex testing scenarios.

[0051] Accordingly, this application also provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; and, when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the deep learning operator performance analysis method as described above. Figure 2 The diagram shown is a hardware structure diagram of any device with data processing capabilities where the deep learning operator performance analysis method provided in this embodiment of the invention is located, except... Figure 2 In addition to the processor, memory, and network interface shown, any data processing device in the embodiment may also include other hardware depending on the actual function of the data processing device, which will not be described in detail here.

[0052] Accordingly, this application also provides a computer-readable storage medium storing computer instructions thereon, which, when executed by a processor, implement the deep learning operator performance analysis method described above. The computer-readable storage medium can be an internal storage unit of any data processing device as described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be an external storage device, such as a plug-in hard disk, smart media card (SMC), SD card, flash card, etc., equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units of any data processing device and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the data processing device, and can also be used to temporarily store data that has been output or will be output.

[0053] The above embodiments are only used to illustrate the design concept and features of the present invention, and their purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly. The protection scope of the present invention is not limited to the above embodiments. Therefore, all equivalent changes or modifications made based on the principles and design ideas disclosed in the present invention are within the protection scope of the present invention.

Claims

1. A method for performance analysis of deep learning operators, characterized in that, The method includes: Identify the target module of the deep learning model to be analyzed, and traverse the attributes in the target module to filter out the functions to be monitored; A monitoring wrapper layer is established for the function to be monitored, a corresponding wrapper function is generated, and a mapping relationship is established between the function to be monitored and the wrapper function; During the execution of the deep learning model, the monitoring wrapper layer captures the call requests to the function to be monitored; in response to the call request, the start timestamp of the call is recorded, the function to be monitored is executed and the end timestamp is recorded, the execution time is calculated, and the statistical data is accumulated in the global statistical storage structure. After the analysis is completed, the performance metrics of each of the monitored functions are calculated based on the statistical data in the global statistical storage structure.

2. The deep learning operator performance analysis method according to claim 1, characterized in that, The process of traversing the attributes in the target module includes: Obtain all attributes of the target module and determine the type of each attribute; If the attribute type is a function, then add it to the set of functions to be monitored; If the attribute type is a submodule, then recursively traverse the submodule and add the functions obtained during the recursion to the set of functions to be monitored; If the attribute type is a class, then iterate through all the methods contained in that class and add those methods to the set of functions to be monitored.

3. The method for performance analysis of deep learning operators according to claim 2, characterized in that, The process of traversing all methods contained in a class and adding them to the set of functions to be monitored includes: Determine whether the name of the method exists in a preset set of operator overloaded method identifiers, wherein the set of operator overloaded method identifiers includes: addition operator, multiplication operator, subtraction operator, division operator, matrix multiplication operator, exponentiation operator, and modulo operator; If it exists, the method is marked as an operator overload method and added to the set of functions to be monitored. By establishing a monitoring wrapper layer for operator overload methods, the performance monitoring of tensor operations can be achieved.

4. The deep learning operator performance analysis method according to claim 1, characterized in that, The process of establishing a monitoring wrapper layer for the function to be monitored includes: A reference counting mapping table is established to record the packaging state of each function to be monitored. The reference counting mapping table uses the unique identifier of the function to be monitored as the key and the reference count value as the value. The reference counting mapping table is empty in the initial state. When a request is made to create a monitoring wrapper layer for a function to be monitored, the reference count mapping table is queried. If the reference count of the function to be monitored is zero, then the monitoring wrapper layer is created and the reference count is set to 1. If the reference count of the function to be monitored is greater than zero, then the reference count is simply incremented by 1, and the monitoring wrapper layer is not created again.

5. The deep learning operator performance analysis method according to claim 1, characterized in that, The global statistical storage structure uses the unique identifier of the function as the key and statistical tuples as the value; The statistical tuples include at least: The cumulative call count field records the total number of times the corresponding function was called during the monitoring period; The cumulative execution time field records the total execution time of the corresponding function during the monitoring period.

6. The method for performance analysis of deep learning operators according to claim 1, characterized in that, The process of calculating the performance metrics of each of the monitored functions includes: Traverse the global statistics mapping table, and for each unique function identifier, obtain the cumulative number of calls and the cumulative execution time from the statistics tuple, and calculate the average execution time, which is equal to the cumulative execution time divided by the cumulative number of calls; Construct performance metrics data that include unique function identifiers, call frequency, cumulative time consumption, and average time consumption; All performance metric data are sorted according to a preset sorting dimension, and the top N records are extracted and output from the sorting results.

7. The method for performance analysis of deep learning operators according to claim 1, characterized in that, The method also includes: implementing temporary monitoring through a context manager, including: Define a monitoring context, which includes a set of functions to be monitored and a reset flag; When executing the monitoring context, if the reset flag is true, then it is determined whether to clear the global statistics storage structure based on the reset flag. Execute deep learning model code within the scope of the monitoring context, record performance data through the monitoring wrapper layer, and record it to the global statistical storage structure; Upon exiting the monitoring context, the function's recovery operation is executed, removing the monitoring wrapper layer.

8. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the deep learning operator performance analysis method as described in any one of claims 1-7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the deep learning operator performance analysis method as described in any one of claims 1-7.

10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the deep learning operator performance analysis method according to any one of claims 1-7.