The invention provides a model precision alignment testing method and
system based on code blocks and
electronic equipment, and relates to the technical field of
deep learning testing. The method comprises the following steps: delimiting an execution boundary for a to-be-tested code block through a
context manager and monitoring the execution boundary; executing the code block under monitoring based on input data in a reference calculation
record prepared for the code block, and automatically capturing a generated forward
data set; the forward
data set at least comprises an input
tensor input into the code block and an intermediate
tensor generated in the code block; after the reverse gradient calculation is completed, automatically capturing a gradient
data set corresponding to the forward data set; and finally, comparing the captured forward data set and / or gradient data set with corresponding data in the reference calculation
record to generate a precision alignment
test report. According to the method, fine-grained and low-intrusive
precision testing of the calculation process of any code snippets in the
deep learning model is realized, and the problems that the testing
granularity is too coarse and the flexibility is poor in a traditional method are solved.