An event-based method for NPU resource modeling

By employing an event-driven white-box modeling approach for NPUs, combined with automatic loop partitioning and pipeline overlap optimization, the problem of balancing simulation efficiency and accuracy in NPU modeling is solved, achieving efficient and accurate simulation and resource utilization.

CN123114728APending Publication Date: 2026-11-17NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611145211.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-30
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing NPU modeling methods struggle to balance simulation efficiency and accuracy. Traditional periodic precision models are slow to simulate, while pure functional models lack sufficient accuracy, making it difficult to meet the design requirements of rapid iteration.

Method used

An event-driven white-box modeling method for neural network processing units is adopted. Through a hybrid modeling strategy, the deterministic operations inside the NPU core are performed in an event-driven manner, while non-deterministic operations retain cycle-based accurate simulation. Combined with automatic loop partitioning algorithm and pipeline overlap optimization, efficient simulation is achieved.

Benefits of technology

While ensuring modeling accuracy, it significantly improves simulation speed and optimizes simulation efficiency, supports fast and accurate AI chip architecture design and neural network deployment optimization, and reduces the waste of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114728A_ABST
    Figure CN123114728A_ABST
Patent Text Reader

Abstract

This invention discloses an event-driven white-box modeling method for neural network processing units (NPUs). The method includes: constructing a directed acyclic graph (DAG) of the target neural network model; decomposing graph nodes into task blocks using an automatic cyclic block partitioning algorithm; dynamically identifying the data dimension consuming the most memory when the memory requirements of neural network operations exceed a preset threshold, and adopting different adjustment strategies based on the dimension type (channel dimension or non-channel dimension), iteratively verifying until the memory constraints are met; and implementing event-based computational core simulation, driving the simulation process through a global event queue, directly calculating the completion time point and generating events for deterministic delayed operations, replacing traditional cycle-by-cycle micro-simulation, while also supporting pipeline overlap optimization. This invention significantly improves simulation speed while ensuring modeling accuracy, achieving an optimized balance between simulation efficiency and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence hardware acceleration technology, specifically involving an event-driven white-box modeling method for neural processing units (NPUs), which is applicable to AI chip architecture simulation, performance prediction and optimization design, especially for fine-grained modeling and analysis of computing resource utilization and data throughput bottlenecks in deep learning inference. Background Technology

[0002] With the widespread application of neural networks in fields such as image recognition, natural language processing, and autonomous driving, accurately predicting the inference latency of deep neural network models on target hardware platforms has become a crucial step in optimizing network architecture design, improving hardware resource scheduling efficiency, and ensuring end-user experience. In this process, high-precision NPU performance simulation models play an irreplaceable role in chip architecture iteration and algorithm-hardware co-optimization.

[0003] However, current NPU modeling methods are mainly divided into two categories: black-box and white-box. Black-box modeling methods primarily involve running large-scale neural network test sets on actual NPU hardware to collect performance data such as latency and power consumption to construct training samples, and then using machine learning algorithms to fit a predictive model. This method has the following limitations: it relies on physical hardware testing, has a long model building cycle, high cost, and its generalization ability is limited by the distribution of training data, making it difficult to adapt to new network architectures or untested hardware configurations.

[0004] White-box modeling methods are based on a precise abstraction of the NPU microarchitecture (including compute array topology, storage hierarchy, data paths, etc.) and predict performance through behavioral-level simulation. However, existing white-box models still face the following challenges: traditional cycle-accurate models, while highly accurate, are slow in simulation and cannot meet the needs of rapid iterative design space exploration; pure functional models, while fast, lack characterization of key timing characteristics such as hardware resource contention and data dependencies, resulting in insufficient accuracy.

[0005] Therefore, there is an urgent need for a white-box modeling method for NPUs that can achieve an optimal balance between simulation efficiency and modeling accuracy, in order to support fast and accurate AI chip architecture design and neural network deployment optimization. Summary of the Invention

[0006] This invention aims to propose a white-box modeling method for event-driven neural network processing units, which solves the technical problem of difficulty in balancing simulation efficiency and accuracy in existing technologies through a hybrid modeling strategy.

[0007] The technical solution adopted by this invention to solve its technical problem is as follows: An event-driven white-box modeling method for neural network processing units includes the following steps: S1: Construct a directed acyclic graph for the target neural network model; S2: Use the automatic cyclic block decomposition algorithm to decompose graph nodes into task blocks; S3: Event-based computational core simulation.

[0008] Step S1 includes the following steps: S11: Receives neural network model files in the Open Neural Network Exchange (ONNX) format, parses the model metadata using Protocol Buffers deserialization technology, and extracts the computation graph topology, node operation types, tensor dimension information, and weight initializer data. S12: Traverse all nodes of the computation graph, instantiate the corresponding hardware operation objects (such as convolution, matrix multiplication, attention mechanism) based on the Operation Factory pattern, and construct a Directed Acyclic Graph (DAG) between operation nodes according to the producer-consumer relationship of tensors, and explicitly mark data dependencies and execution order.

[0009] Step S2 includes the following steps: S21: When the memory requirement of the target neural network operation exceeds a preset threshold, the algorithm initiates an automatic block-segmentation process. The memory requirement includes the total storage space requirement for input tensors, weight data, and intermediate results, and the preset threshold is determined based on the on-chip storage capacity of the NPU hardware architecture. S22: The algorithm traverses all dimensional parameters of the operation, identifies and locates the dimensional index with the largest memory usage; wherein, the neural network operation has multiple dimensional parameters, including but not limited to batch size, spatial height, spatial width and number of channels; for convolution operation, the dimensional parameters may also include convolution kernel size, stride and other parameters; S23: The algorithm determines whether the maximum dimension is a channel dimension. If the dimension is a channel dimension, an adjustment strategy based on hardware computing unit granularity is adopted; if the dimension is not a channel dimension (such as a spatial dimension), a unit step size adjustment strategy is adopted. S24: After the dimension parameters are adjusted, the algorithm recalculates the memory requirements of the operation based on the adjusted dimension parameters; S25: The algorithm verifies whether the adjusted memory requirement meets the preset threshold. If the memory requirement still exceeds the threshold, it returns to continue executing the dimension identification, type judgment, parameter adjustment and memory requirement calculation process. If the memory requirement meets the threshold constraint, the iteration terminates and the final dimension parameter configuration scheme is output. S26: The algorithm decomposes the original operation into multiple tiles based on the finally determined dimension parameters.

[0010] Preferably, the adjustment strategy based on hardware computing unit granularity in step S23 is as follows: the channel dimension parameter is reduced by a multiple of the size of the NPU hardware computing unit (such as a systolic array) to ensure that the adjusted number of channels can be divided by the hardware computing unit, thus avoiding waste of computing resources.

[0011] Preferably, the unit step size adjustment strategy in step S23 is to reduce the dimension parameter by 1 to ensure the continuity of the spatial dimension and the integrity of the data.

[0012] Preferably, the memory requirement calculation formula in step S24 is: Memory requirement = Batch size × Height × Width × Number of channels × Data precision The accuracy of the data is determined by the model configuration parameters.

[0013] Preferably, when the tile partitioning result is generated in step S26, the dimensional parameters of each tile satisfy the memory constraint conditions, and the tile partitioning scheme considers both computational efficiency and data locality to ensure that the operation after partitioning can efficiently utilize NPU hardware resources.

[0014] Step S3 includes the following steps: S31: Instruction Scheduling and Dependency Checking: The NPU core model obtains the tile operation instruction sequence from the task queue and verifies the data readiness status through a dependency checking mechanism (such as scoreboard technology). For example, a computation instruction can only be executed after the input data and weights have been completely transferred to the on-chip memory through a data loading instruction. S32: For systolic array computation instructions, the total execution cycle (including the weight preloading stage and the computation stage) is calculated based on the operand dimension and hardware physical parameters using a preset timing model formula, and the corresponding completion event is registered in the global event queue; for vector unit operations (such as activation functions), the execution time is calculated based on the operand size, vector width and inherent hardware latency parameters, and the corresponding event is generated. S33: Perform pipeline overlap optimization. When subsequent instructions can reuse the current weight and the data is ready, they are allowed to be triggered in the middle of the execution of the preceding instructions. By dynamically adjusting the event timestamp offset, the pipeline parallel efficiency is accurately simulated and the bubble cycle is reduced. S34: The simulator traverses the global event queue with timestamp as the priority, selects the earliest event each time and jumps the global simulation time to that moment; after executing the event association logic (such as updating resource status and releasing dependencies), it dynamically triggers the generation of new events, forming a closed-loop driving process.

[0015] Preferably, the formula for calculating the total execution cycle using the preset timing model in step S32 is: Total execution cycle = core_h + core_w + max(compute_size, 4) Where core_h and core_w represent the physical dimensions of the computing unit, compute_size is the product of the height blocks and the width blocks of the output feature map.

[0016] Preferably, the event association logic described in step S34 is responsible for updating resource status and releasing dependencies during task execution, and dynamically triggering new events based on these changes to form a closed-loop driving process. This process ensures the efficient use of computing resources and the orderly execution of tasks.

[0017] Preferably, the closed-loop driving process after the event association logic is executed is as follows: S41 initial state: compute unit idle, buffer empty, memory ready, instruction queue empty; S42, Tile data delivery (Event 1): The scheduler delivers tile data to the core, the core creates a load instruction, triggers a memory request event, and the compute unit status changes to "busy"; S43, Memory Request (Event 2): The memory controller processes the request, reads data from DRAM, and triggers a memory response event; S44, Memory Response (Event 3): Data is loaded into SPAD, the Buffer state changes to "Ready", triggering the Buffer fill complete event; S45, Buffer filling complete (Event 4): Check computation instruction dependencies. If the dependencies are satisfied, trigger the computation start event. S46, Calculation Start (Event 5): The calculation unit performs a calculation (such as GEMM) operation, triggering the calculation completion event; S47, Calculation complete (Event 6): The computing unit status changes to "idle", releasing computing resources and checking if there are any new tiles or instructions. If so, a new tile issuance or instruction execution event is triggered.

[0018] Preferably, after the tile is issued, completed instructions are removed from the instruction queue, new instructions are added to the queue, and the dependencies of instructions in the queue are checked. Dynamic triggering is performed: if there are instructions in the queue whose dependencies have been satisfied, and if there are ready instructions and resources are available, a new execution event is triggered; at the same time, the occupancy status of the instruction queue is checked, and if the queue is not full, new instructions can be received.

[0019] Preferably, after a memory request event, once the memory controller has processed a memory request, the memory bus bandwidth is released, allowing it to process new memory requests. This is dynamically triggered by: checking if there are new memory access requests in the memory instruction queues (ld_inst_queue, st_inst_queue); if there are ready memory requests and the memory bus is available, triggering a new memory request event; and simultaneously checking if there are any computation instructions waiting for memory data, and if so, updating their dependency status.

[0020] Preferably, after the memory response event, the data in memory is loaded into SPAD or ACC_SPAD, the Buffer switches from a "waiting" state to a "ready" state, the usage of the Buffer increases, the occupied space is updated, and dynamic triggering occurs: checking if there are any calculation instructions waiting for this Buffer data; checking if other dependencies of these instructions are ready; if all dependencies are satisfied, triggering a new calculation event, starting to execute instructions that use this Buffer data, and simultaneously checking if the Buffer is full; if full, triggering a storage instruction to write the data back to memory.

[0021] Preferably, after the computation completion event, the computation unit (Core) switches from a "busy" state to an "idle" state, the computation pipeline is released, the PE array (Processing Element Array) becomes available, and dynamically triggers: checking if there are any instructions pending in the computation pipeline; checking if there are any new computation instructions in the instruction queue (ex_inst_queue); if there are ready computation instructions and the computation unit is available, triggering a new computation start event; and simultaneously checking the vector pipeline to see if there are any vector operations that can be executed.

[0022] The advantages of this invention compared to the prior art are: (1) The present invention adopts a hybrid modeling strategy. For computational operations with deterministic delays within the NPU core, an event-driven approach is used for abstract modeling. For non-deterministic operations, a periodic accurate simulation mechanism is retained. This significantly improves the simulation speed while ensuring modeling accuracy, and achieves an optimized balance between simulation efficiency and accuracy. (2) The automatic cyclic block partitioning algorithm of the present invention can automatically adjust the partitioning strategy according to the NPU hardware storage capacity. By distinguishing between channel dimension and non-channel dimension and adopting different adjustment strategies, it can ensure the full utilization of computing resources and maintain the continuity and integrity of data processing. (3) The event-driven mechanism of the present invention avoids the huge overhead of traditional cycle-by-cycle simulation by directly calculating the completion time of deterministic operations, and at the same time, it accurately simulates the hardware parallel efficiency through pipeline overlap optimization. (4) The present invention can accurately predict the running time and resource utilization of deep learning models on hardware devices, reduce unnecessary waste of computing resources, and support the pre-drilling of NPU basic software version iteration, thereby accelerating the iteration speed. Attached Figure Description

[0023] Figure 1 This is a flowchart of the automatic cyclic block division algorithm of the present invention.

[0024] Figure 2 This is a schematic diagram of the initial state of the event simulation of the computing unit of the present invention.

[0025] Figure 3 This is a schematic diagram of the intermediate state of the event simulation of the computing unit of the present invention.

[0026] Figure 4 This is a schematic diagram of the completed event simulation state of the computing unit of the present invention.

[0027] No line filled box 1: Idle computing unit PE; Vertical line filled box 2: Valid data 1, representing a tile data unit; Horizontal line filled box 3: Valid data 2, representing another different tile data unit. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be described in more detail below with reference to the accompanying drawings. In the drawings, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The described embodiments are some, but not all, embodiments of this invention. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this invention, and should not be construed as limiting this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention. The technical solutions of this invention will be further described in detail below with reference to the accompanying drawings, and embodiments of this invention will be given.

[0029] Example 1: Complete Simulation Process of ResNet-18 Model This embodiment provides a specific implementation of an event-driven white-box modeling method for neural network processing units.

[0030] The first part is model loading and the construction of the directed acyclic graph.

[0031] The simulation system loads the target deep neural network model via a protocol buffer interface. This model is a commonly used convolutional neural network architecture, such as ResNet-18, and its model file is stored in the Open Neural Network Exchange Format (ONNX) for normalization. The loading process includes opening the model file stream, performing deserialization operations, and constructing the model representation in memory.

[0032] After model loading is complete, the system extracts the dimensional parameters of the model's input tensor. Taking ResNet-18 as an example, its standard input tensor dimensions are [1, 224, 224, 3]. The first dimension, batch_size=1, represents the batch size, i.e., the number of samples processed in a single inference iteration; the fourth dimension, channel_num=3, represents the number of channels in the input data; the second dimension, height=224, and the third dimension, width=224, represent the spatial dimensions of the input image in the vertical and horizontal directions, respectively. Simultaneously, the system analyzes the model's computational graph topology, identifying that the model contains 44 computational nodes, including 20 convolutional operation nodes, 4 max-pooling operation nodes, 18 residual connection structures, 1 global average pooling layer node, and 1 fully connected layer node.

[0033] Subsequently, the system traverses all nodes in the computation graph, identifying the operation type and configuration parameters of each node. For convolution operations, it extracts attributes such as stride, padding, dilation, number of groups, number of input channels, number of output channels, kernel size, data memory layout (e.g., NCHW or NHWC), and weight layout. For pooling operations, it extracts parameters such as pooling window size, stride, and padding mode. For other operation types, it similarly extracts their corresponding feature parameters. The system calculates the precise dimensions of the input and output tensors for each operation based on the extracted parameters and instantiates the corresponding hardware operation object class based on the operation type.

[0034] Furthermore, the system traverses the computation graph and models each convolution operation node as a seven-dimensional tensor computation problem [B,P,Q,M,S,R,C], where B represents the batch size, i.e., the number of input samples processed simultaneously in a single inference or training process; P represents the spatial width of the output feature map; Q represents the spatial height of the output feature map; M represents the number of output channels, which also corresponds to the number of convolution kernels; S represents the number of input channels; R represents the height dimension of the convolution kernel; and C represents the width dimension of the convolution kernel.

[0035] The convolution operation can be represented as: for r = (0, R): for s = (0, S): for p = (0, P): for q = (0, Q): for c = (0, C): for m = (0, M): for b = (0, B): Output[p][q][m][b]+= Weight[r][s][m][b]* Input[p+r][q+s][c][b] The key parameters for an NPU configuration are shown in the table below: Parameter name size significance core_size 16*16 The physical dimension of the computing unit determines the number of matrix multiplication and addition operations that can be processed in parallel in a single run. vector_size 2048 The bit width of a vector processing unit represents the number of data elements that can be processed simultaneously by a single instruction, and supports non-matrix operations such as activation functions. spad_size 32768 On-chip scratchpad memory capacity (in bytes), used to store input tensor and weight data. accum_spad_size 4096 Accumulator dedicated storage capacity (unit: B), caching intermediate results of matrix multiplication core_freq 500M The core operating frequency (500 MHz) determines the number of clock cycles that the computing unit can execute per second. The second part is the implementation of the automatic cyclic block division algorithm.

[0036] For convolution operations in the ResNet-18 convolutional neural network, this invention adopts a fixed-weight execution mode, that is, the convolution kernel parameters are pre-loaded into the computation unit, and then the input tensor data flows through the computation unit to complete the operation. Considering that the complete input tensor [1,224,224,3] cannot be stored in a limited-capacity on-chip cache at once, this invention applies an automatic cyclic block decomposition algorithm to decompose the computation task into manageable tile units.

[0037] Specifically, for the first-layer convolution operation with input dimension [1,224,224,3] and kernel size [64,3,7,7], its seven-dimensional tensor representation is [1,3,64,112,112,7,7].

[0038] In this embodiment, the total on-chip cache capacity is 32768B. To implement a double buffering strategy to improve the utilization of computing units, the memory usage of each tile is constrained to half of the total on-chip cache capacity, i.e., 16384B.

[0039] like Figure 1 As shown, the execution flow of the automatic cyclic block partitioning algorithm is as follows: The first step is algorithm startup and initial condition judgment. The system detects that the memory requirement of the convolution operation exceeds the preset threshold, and the algorithm starts the automatic block segmentation process.

[0040] The second step is dimension identification and maximum dimension determination. The algorithm iterates through the seven-dimensional parameters [1,3,64,112,112,7,7], calculating the contribution of each dimension to memory usage. The memory usage calculation formula is: in_channels_per_bank * batches * ih * iw Where in_channels_per_bank represents the average number of memory rows occupied by the channel dimension, batches represents the number of data samples, and ih and iw are the input tensor sizes.

[0041] Calculations show that the height dimension of the output feature map, 112, is the current maximum dimension.

[0042] The third step is to determine the dimension type and select the adjustment strategy. Since the maximum dimension 112 is a spatial dimension (not a channel dimension), the algorithm adopts a unit step adjustment strategy to reduce the dimension value by 1 and generate a new configuration [1,3,64,111,112,7,7].

[0043] Fourth step: Recalculate memory requirements. Based on the adjusted dimensional parameters, recalculate the memory requirements.

[0044] Step 5: Constraint verification and iterative execution. If the memory requirement still exceeds the threshold of 16384B, return to step 2 to continue iterating. After multiple iterations and adjustments (112→111→...→90), the algorithm determines that the block configuration that satisfies the memory constraint is [1,3,64,90,91,7,7].

[0045] Step 6: Generating the tile partitioning results. To maximize hardware resource utilization, the algorithm further attempts to expand the parameters of each dimension while satisfying memory constraints, and finally determines the optimal partitioning strategy. The outer loop dimension corresponding to this strategy is [1,1,1,2,2,1,1], indicating that the complete convolution operation requires 4 matrix multiplication operations of size T1, that is, partitioning into 4 tiles.

[0046] Figure 1 The process ensures that the dimensional parameters of each tile meet memory constraints, while balancing computational efficiency and data locality by aligning the channel dimension with hardware granularity and maintaining the continuity of the spatial dimension.

[0047] The third part is the core simulation of event-based computation.

[0048] In the event-based simulation engine, the four matrix multiplication operations mentioned above each generate independent computation events. To accurately simulate the computation process, this invention calculates the completion time of each event using a pre-set timing model, rather than using traditional cycle-by-cycle simulation.

[0049] Figure 2 This illustrates the initial state (time T0) of the computation unit event simulation. The large white box represents the NPU computation unit, with a physical size of 16×16 (W=16, H=16). Box 1 without lines represents an idle computation unit, and box 2 with vertical lines represents computation data for a single tile entering the computation unit. The system clock is in cycle T0 when data for the first tile (90×91) begins entering the computation unit. At this stage, the computation unit's input ports begin receiving data, and the weight preloading process begins. Simultaneously, a weight loading completion event is registered in the global event queue with a timestamp of T0 + preload_cycles.

[0050] Figure 3 This illustrates the intermediate state (time T0+L) of the computation unit event simulation. The horizontally filled box 3 represents the computation data of another tile. As the tile data flows through the computation unit, the system clock advances to cycle T0+L (L is the data stream length). In this state, a stable computation stream has formed within the computation unit, and data is transferred between processing units according to a preset computation timing. At this time, the global event queue contains multiple events: the computation completion event for the current tile (timestamp T0+total_cycles), the data readiness event for the next tile (if dependencies are satisfied), etc.

[0051] Figure 4 This demonstrates the completion status of the computational unit event simulation. When the last data calculation for the current tile is completed, the NPU clock cycle advances to T0+(L-1)+H+W. This invention calculates the total execution cycle using a preset hardware timing model formula: total_cycles = core_h + core_w + max(compute_size, 4) = 16 + 16 + max(90 × 91, 4) = 32 + 8190 = 8222 cycles Where core_h and core_w represent the physical size of the computation unit, and compute_size is the height block multiplied by the width block of the output feature map, which is 90×91 in the above 7-dimensional tensor.

[0052] The completion time point is directly registered as an event, replacing the traditional periodic precise simulation method. At this time, the system updates the resource status, releases the computing unit occupied by the tile, and checks whether there are any ready successor instructions.

[0053] The four tiles of the first convolutional layer are scheduled and executed sequentially through an event queue. Due to the double-buffering strategy and pipeline overlap optimization, the actual execution time is less than 4 × 8222 cycles. After full scheduling by the event-driven simulation engine, the first convolutional layer contributes approximately 6000 microseconds of latency.

[0054] Similarly, the system performs block partitioning and event scheduling on the remaining 43 computing nodes (including 19 convolutional layers, 4 pooling layers, 18 residual connections, etc.). The number of tiles, computation cycle, and dependencies of each node are managed uniformly through a global event queue, forming a complete simulation timeline.

[0055] Through complete end-to-end simulation verification, the present invention achieved the following technical indicators on the ResNet-18 model: total inference time per sample was 19564 microseconds; the system successfully scheduled 72928 systolic array computation instructions and 46384 data preloading instructions; the overall utilization rate of the systolic array reached 93.19% (of which the utilization rate of the processing unit PE was 72.44%); the simulation throughput was 9.34 tiles / second, which is 3.4 times faster than the traditional periodic accurate model; the deviation between the execution completion time of each layer and the theoretical calculation value was controlled within 10%, verifying the reliability of the modeling accuracy of the present invention.

[0056] It should be noted that 8222 cycles is the theoretical computation cycle for a single tile, while 19564 microseconds is the end-to-end latency of the complete model. The latter is composed of the following cumulative components: the first layer convolution (4 tiles, approximately 6000 microseconds, including pipeline overlap optimization), the intermediate layer convolution (approximately 12000 microseconds), pooling and residual connections (approximately 1500 microseconds), and event scheduling overhead (approximately 64 microseconds). The ratio of single-tile cycle to complete model cycle is approximately 1190:1, corresponding to approximately 1200 equivalent tiles (including all layers), verifying the inherent consistency from single-tile theoretical calculations to complete system simulation.

[0057] Example 2: Electronic device This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of the method described in Embodiment 1.

[0058] Example 3: Computer-readable storage medium This embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in Embodiment 1.

[0059] The parts of this invention not described in detail are common knowledge in the field.

[0060] The objectives of this invention have been fully and effectively achieved through the above embodiments. Those skilled in the art will understand that this invention includes, but is not limited to, the contents described in the accompanying drawings and the specific embodiments described above. Although the invention has been described with reference to what is currently considered the most practical and preferred embodiments, it should be understood that the invention is not limited to the disclosed embodiments, and any modifications that do not depart from the functional and structural principles of the invention will be included within the scope of the claims.

Claims

1. A white-box modeling method for event-driven neural network processing units, characterized in that, Includes the following steps: S1: Construct a directed acyclic graph for the target neural network model; S2: Use the automatic cyclic block decomposition algorithm to decompose graph nodes into task blocks; S3: Event-based computational core simulation, including deterministic operation latency based on operand dimension and hardware physical parameters; direct calculation of completion time points and generation of events through preset timing models; retention of a periodic accurate simulation mechanism for non-deterministic operations; and pipeline overlap optimization by dynamically adjusting event timestamp offsets.

2. The event-driven white-box modeling method for neural network processing units according to claim 1, characterized in that, Step S1 specifically includes the following steps: S11: Receives neural network model files in Open Neural Network Exchange Format, parses model metadata using protocol buffer deserialization technology, and extracts computation graph topology, node operation types, tensor dimension information, and weight initializer data; S12: Traverse all nodes of the computation graph, construct a directed acyclic graph between operation nodes, and explicitly mark data dependencies and execution order.

3. The event-driven white-box modeling method for neural network processing units according to claim 2, characterized in that, Step S2 specifically includes the following steps: S21: When the memory requirement of the target neural network operation is detected to exceed the preset threshold, the algorithm starts the automatic block division process; S22: The algorithm iterates through all dimension parameters of the operation, identifies and locates the dimension index with the largest memory usage; S23: The algorithm determines whether the maximum dimension is a channel dimension. If the dimension is a channel dimension, an adjustment strategy based on hardware computing unit granularity is adopted; if the dimension is not a channel dimension, a unit step size adjustment strategy is adopted. S24: After the dimension parameters are adjusted, the algorithm recalculates the memory requirements of the operation based on the adjusted dimension parameters; S25: The algorithm verifies whether the adjusted memory requirement meets the preset threshold. If the memory requirement still exceeds the threshold, it returns to step S22 to continue execution. If the memory requirement meets the threshold constraint, it terminates the iteration and outputs the final dimension parameter configuration scheme. S26: Based on the finally determined dimension parameters, the algorithm decomposes the original operation into multiple tiles, and the dimension parameters of each tile satisfy the memory constraint conditions.

4. The event-driven white-box modeling method for neural network processing units according to claim 3, characterized in that, Step S3 specifically includes the following steps: S31: Perform instruction scheduling and dependency checks. The NPU core model obtains the tile operation instruction sequence from the task queue and verifies the data readiness status through the dependency check mechanism. S32: For systolic array computation instructions, the total execution cycle is calculated based on the operand dimension and hardware physical parameters using a preset timing model formula, and the corresponding completion event is registered in the global event queue; for vector unit operations, the execution time is calculated based on the operand size, vector width, and inherent hardware latency parameters, and corresponding events are generated. S33: Perform pipeline overlap optimization. When a subsequent instruction can reuse the current weight and the data is ready, it is allowed to be triggered during the execution of the preceding instruction. S34: The simulator traverses the global event queue with timestamp as the priority, selects the earliest event each time and jumps the global simulation time to that moment; after executing the event association logic, it dynamically triggers the generation of new events, forming a closed-loop driving process.

5. The event-driven white-box modeling method for neural network processing units according to claim 4, characterized in that, The parameters for traversing all dimensions of the operation include: batch size, spatial height, spatial width, number of channels, kernel size, and stride.

6. The event-driven white-box modeling method for neural network processing units according to claim 5, characterized in that, The formula for calculating memory requirements is: Memory requirement = Batch size × Height × Width × Number of channels × Data precision, where data precision is determined by the model configuration parameters.

7. The event-driven white-box modeling method for neural network processing units according to claim 5, characterized in that, The formula for calculating the total execution cycle using the preset timing model is: Total execution cycle = Computation unit height + Computation unit width + max(computation scale, 4) The computational scale is the product of the height block and the width block of the output feature map.

8. The event-driven white-box modeling method for neural network processing units according to claim 3, characterized in that, When the tile partitioning results are generated, the dimensional parameters of each tile satisfy the memory constraints, and the tile partitioning scheme considers both computational efficiency and data locality.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method as described in any one of claims 1-8.

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