WO2021031345A1 - 基于硬件环境的卷积计算仿真测试方法、装置及相关设备 - Google Patents

基于硬件环境的卷积计算仿真测试方法、装置及相关设备 Download PDF

Info

Publication number
WO2021031345A1
WO2021031345A1 PCT/CN2019/114532 CN2019114532W WO2021031345A1 WO 2021031345 A1 WO2021031345 A1 WO 2021031345A1 CN 2019114532 W CN2019114532 W CN 2019114532W WO 2021031345 A1 WO2021031345 A1 WO 2021031345A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
convolution calculation
result
convolution
data information
Prior art date
Application number
PCT/CN2019/114532
Other languages
English (en)
French (fr)
Inventor
曹其春
赵雅倩
董刚
范宝余
梁玲燕
Original Assignee
浪潮电子信息产业股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 浪潮电子信息产业股份有限公司 filed Critical 浪潮电子信息产业股份有限公司
Publication of WO2021031345A1 publication Critical patent/WO2021031345A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • This application relates to the field of testing technology, and in particular to a method, device and related equipment for convolution calculation simulation testing based on a hardware environment.
  • the purpose of this application is to provide a convolution calculation simulation test method, device and related equipment based on a hardware environment to effectively perform convolution calculation simulation test and improve hardware development efficiency.
  • a hardware environment-based convolution calculation simulation test method including:
  • Acquiring data information to be used for convolution calculation where the data information includes at least an input feature map and a weight;
  • the data information is a 32-bit floating point number type
  • the convolution calculation implementation logic of the simulated hardware environment After the data information to be used for convolution calculation is obtained, the convolution calculation implementation logic of the simulated hardware environment, The software simulation of convolution calculation based on the data information, before obtaining the first result data, further includes:
  • the data information is quantized from a 32-bit floating point number type to an 8-bit integer type.
  • the method further includes:
  • the first corresponding result is compared with the second corresponding result to obtain a second comparison result, and the second corresponding result is: using theoretical convolution calculation logic and performing processing based on the data information of the 32-bit floating point number type Convolution calculation, the result obtained;
  • the weight is a 7x7 convolution kernel
  • the convolution calculation implementation logic of the simulated hardware environment is implemented
  • software simulation of the convolution calculation is performed based on the data information to obtain the first result data
  • the weight is a 3x3 convolution kernel
  • the convolution calculation implementation logic of the simulated hardware environment software simulation of the convolution calculation is performed based on the data information, and the first result data is obtained ,include:
  • the columns corresponding to the two 9x9 matrices are multiplied and accumulated to obtain 9 numbers, arranged in a 3x3 area, and combined to obtain the output characteristic map, and obtain the first result data.
  • the weight is a 1x1 convolution kernel
  • the convolution calculation implementation logic of the simulated hardware environment is implemented
  • software simulation of the convolution calculation is performed based on the data information to obtain the first result data
  • the corresponding two 9x9 matrices are multiplied to obtain a 9x9 area, and the output characteristic map is obtained by combining, and the first result data is obtained.
  • a hardware environment-based convolution calculation simulation test device including:
  • a data information acquisition module for acquiring data information to be used for convolution calculation, the data information including at least an input feature map and weights;
  • the software simulation module is used to simulate the convolution calculation implementation logic of the hardware environment, and perform software simulation of the convolution calculation based on the data information to obtain the first result data;
  • the result data comparison module is used to compare the first result data with the second result data to obtain a first comparison result, and the second result data is performed using the data information in the hardware environment Data obtained by convolution calculation;
  • the logic verification module is used to verify whether the hardware implementation logic is correct according to the first comparison result.
  • a hardware environment-based convolution calculation simulation test equipment including:
  • Memory used to store computer programs
  • the processor is configured to implement the steps of any one of the foregoing hardware environment-based convolution calculation simulation test methods when executing the computer program.
  • FIG. 1 is an implementation flowchart of a convolution calculation simulation test method based on a hardware environment in an embodiment of the application
  • Figure 2 is a schematic diagram of a convolution kernel halving method in an embodiment of the application
  • FIG. 3 is a schematic diagram of a region extraction method in an embodiment of the application.
  • FIG. 4 is a schematic structural diagram of a convolution calculation simulation test device based on a hardware environment in an embodiment of the application
  • FIG. 5 is a schematic structural diagram of a convolution calculation simulation test device based on a hardware environment in an embodiment of the application.
  • an implementation flowchart of a convolution calculation simulation test method based on a hardware environment provided by an embodiment of this application, the method may include the following steps:
  • the data information includes at least an input feature map (feature map) and weights.
  • the hardware operation handle can be used to communicate with the hardware board to read relevant data information and write to the hardware memory.
  • the data information includes at least input feature maps and weights, and can also include data such as quantization parameters.
  • S120 Simulate the convolution calculation implementation logic of the preset hardware environment, perform software simulation of the convolution calculation based on the data information, and obtain the first result data.
  • the convolution calculation implementation logic in the hardware environment may include logic such as convolution kernel splitting, feature map data fetching, data reordering, systolic array calculation, and data accumulation.
  • the embodiment of the present application is the implementation of simulated convolution calculation on hardware, and the convolution calculation implementation logic of a preset hardware environment needs to be simulated, and software simulation of convolution calculation is performed based on data information to obtain the first result data.
  • step S120 may include the following steps:
  • Step 1 Convert the 7x7 convolution kernel to 9x9 convolution kernel, and divide the 9x9 convolution kernel into 9 3x3 convolution kernels;
  • Step 2 Split the input feature map into 9 feature maps according to the offset position split by the convolution kernel
  • Step 3 Perform convolution calculation on each of the 9 feature maps and the corresponding 3x3 convolution kernel, and accumulate the obtained feature maps to obtain a feature map of one channel;
  • Step 4 Perform accumulation on the input channel to obtain the feature map data on the output channel, and obtain the first result data.
  • the weight in the data information is a 7x7 convolution kernel. If it is, you can convert the 7x7 convolution kernel to a 9x9 convolution kernel, such as 7x7
  • the convolution kernel is filled with 0 on the right and bottom to become a 9x9 convolution kernel, as shown in Figure 2.
  • the 9x9 convolution kernel is equally divided into 9 3x3 convolution kernels. Specifically, the 9x9 convolution kernel can be divided into 9 3x3 convolution kernels from left to right and top to bottom, as shown in FIG. 2.
  • the input feature map corresponding to the 7x7 convolution kernel is split into 9 feature maps according to the offset position of the convolution kernel splitting.
  • step S120 may include the following steps:
  • the first step Take out the 11x11 area of the input feature map in turn;
  • the second step split each 11x11 area into 9 5x5 areas;
  • the third step reorder the data of each 5x5 area into a 9x9 matrix, and reorder the 3x3 convolution kernel data into a 9x9 matrix;
  • the fourth step through the systolic array, multiply and accumulate the columns corresponding to the two 9x9 matrices to obtain 9 numbers, arrange them into 3x3 areas, combine to obtain the output characteristic map, and obtain the first result data.
  • the weight in the data information is a 3x3 convolution kernel. If so, the input feature map corresponding to the 3x3 convolution kernel can be taken out in turn to take out the 11x11 area.
  • the rear 11x11 area and the front 11x11 area can have 2 columns or 2 rows of overlap, and then each 11x11 area is split into 9 5x5 areas, and there can be 2 rows or 2 columns of overlap between the rear 5x5 area and the first 5x5 area , As shown in Figure 3, reorder the data of each 5x5 area into a 9x9 matrix, and reorder the data of the 3x3 convolution kernel into a 9x9 matrix. After the systolic array, the columns of the two 9x9 matrices are multiplied and accumulated. 9 numbers, arranged in a 3x3 area, combined to obtain the output feature map, and obtain the first result data.
  • step S120 may include the following steps:
  • Step 1 Take out the 9x9 matrix from the input feature map in turn, and reorder the 1x1 convolution kernel data into a 9x9 matrix;
  • Step 2 Multiply the corresponding two 9x9 matrices through the systolic array to obtain a 9x9 area, combine to obtain the output characteristic map, and obtain the first result data.
  • the weight in the data information is a 1x1 convolution kernel. If so, the input feature map corresponding to the 1x1 convolution kernel can be taken out in turn to take out the 9x9 matrix, and at the same time Arrange the 1x1 convolution kernel into a 9x9 matrix.
  • the 81 numbers in the 9x9 matrix are all 1x1 data.
  • the corresponding two 9x9 matrices are multiplied to obtain a 9x9 area, and the output feature map is combined to obtain the first result data .
  • the second result data is data obtained by convolution calculation using data information in a hardware environment.
  • the second result data can be obtained by performing convolution calculation using data information in a hardware environment.
  • the second result data can be read through the hardware handle.
  • the first comparison result can be obtained.
  • the convolution calculation implementation logic of the hardware environment is simulated, and software simulation of the convolution calculation is performed based on the data information to obtain the first result data, Comparing the first result data with the second result data obtained by convolution calculation using data information in a hardware environment can verify whether the hardware implementation logic is correct. In this way, the simulation test of convolution calculation can be effectively performed, the errors in the hardware implementation logic can be found in time, the hardware debugging is convenient, and the hardware development efficiency can be improved.
  • the data information is a 32-bit floating point number type.
  • the method may further include the following steps:
  • the data information is quantized from a 32-bit floating point number type to an 8-bit integer type.
  • the method may further include the following steps:
  • the first step dequantize the first result data to a 32-bit floating point number type to obtain the first corresponding result;
  • the second step compare the first correspondence result with the second correspondence result to obtain the second comparison result.
  • the second correspondence result is: use theoretical convolution calculation logic and perform convolution based on 32-bit floating point data information Product calculation, the result obtained;
  • the third step According to the second comparison result, determine whether the accuracy loss meets the preset requirements.
  • the acquired data information to be used for convolution calculation may be a 32-bit floating point number type.
  • the data information may be quantized from a 32-bit floating point number type to 8 bits. Integer type.
  • step S120 the convolution calculation implementation logic of the hardware environment is simulated, and software simulation of the convolution calculation can be performed based on the data information of the 8-bit integer type to obtain the first result data.
  • the first result data can be dequantized to a 32-bit floating point number type to obtain the first corresponding result.
  • theoretical convolution calculation logic can be used to perform convolution calculation based on 32-bit floating point number type data information to obtain a second corresponding result.
  • the second comparison result can be obtained.
  • the accuracy loss can be determined, and it can be determined whether the accuracy loss meets the preset requirement.
  • the preset requirements can be set and adjusted according to actual conditions.
  • the data information such as input feature maps, weights, quantization parameters, and other data, can be adjusted to better perform the simulation test of the convolution calculation.
  • the embodiment of this application is aimed at the convolution calculation on the existing hardware environment, and there are difficulties in debugging such as large amount of data and closed environment.
  • the realization of simulation convolution calculation on hardware can effectively simulate the calculation result and realize it with hardware.
  • the results of the comparison of the hardware to determine the correctness of the convolution calculation so as to provide a basis for hardware development. That is to say, the implementation logic of convolution calculation on the hardware is moved to the software for simulation, and the intermediate results that are not easy to view in the hardware implementation can be clearly seen, and a large amount of data is compared to determine the correctness of the hardware implementation logic. Whether or not to quickly locate the error location of the hardware implementation logic is conducive to hardware development.
  • the embodiments of the present application also provide a hardware environment-based convolution calculation simulation test device.
  • the following describes a hardware environment-based convolution calculation simulation test device and the one described above.
  • the convolution calculation simulation test methods based on the hardware environment can correspond to each other.
  • the device includes the following modules:
  • the data information acquisition module 210 is configured to acquire data information to be used for convolution calculation, and the data information includes at least an input feature map and weights;
  • the software simulation module 220 is used to simulate the convolution calculation implementation logic of the hardware environment, perform software simulation of the convolution calculation based on the data information, and obtain the first result data;
  • the result data comparison module 230 is configured to compare the first result data with the second result data to obtain a first comparison result, and the second result data is data obtained by convolution calculation using data information in a hardware environment;
  • the logic verification module 240 is used to verify whether the hardware implementation logic is correct according to the first comparison result.
  • the convolution calculation implementation logic of the hardware environment is simulated, and software simulation of the convolution calculation is performed based on the data information to obtain the first result data, Comparing the first result data with the second result data obtained by convolution calculation using data information in a hardware environment can verify whether the hardware implementation logic is correct. In this way, the simulation test of convolution calculation can be effectively performed, the errors in the hardware implementation logic can be found in time, the hardware debugging is convenient, and the hardware development efficiency can be improved.
  • the error location module is used to locate and output the error location of the hardware implementation logic according to the first comparison result.
  • the data information is a 32-bit floating point number type, and further includes:
  • the quantization module is used to simulate the convolution calculation implementation logic of the hardware environment after obtaining the data information to be used for the convolution calculation, perform the software simulation of the convolution calculation based on the data information, and combine the data information before obtaining the first result data.
  • the 32-bit floating-point number type is quantized into an 8-bit integer type.
  • the accuracy loss determination module is used to simulate the convolution calculation logic of the hardware environment, and perform the software simulation of the convolution calculation based on the data information.
  • the first result data is dequantized to a 32-bit floating point number type, Obtain the first corresponding result; compare the first corresponding result with the second corresponding result to obtain the second comparison result, the second corresponding result is: using theoretical convolution calculation logic, based on 32-bit floating point data information Convolution calculation, the result obtained; according to the second comparison result, it is determined whether the accuracy loss meets the preset requirements.
  • the weight is a 7x7 convolution kernel
  • the software simulation module 220 is specifically used for:
  • the weight is a 3x3 convolution kernel
  • the software simulation module 220 is specifically used for:
  • the columns corresponding to the two 9x9 matrices are multiplied and accumulated to obtain 9 numbers, arranged in a 3x3 area, and combined to obtain the output characteristic map, and obtain the first result data.
  • the weight is a 1x1 convolution kernel
  • the software simulation module 220 is specifically used for:
  • the corresponding two 9x9 matrices are multiplied to obtain a 9x9 area, and the output characteristic map is obtained by combining, and the first result data is obtained.
  • the embodiment of the present application also provides a hardware environment-based convolution calculation simulation test device, as shown in FIG. 5, including:
  • the memory 310 is used to store computer programs
  • the processor 320 is configured to implement the steps of the foregoing hardware environment-based convolution calculation simulation test method when the computer program is executed.
  • the embodiment of the present application also provides a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium.
  • the computer program is executed by a processor, the foregoing convolution calculation based on the hardware environment is realized. Steps of simulation test method.
  • the steps of the method or algorithm described in combination with the embodiments disclosed herein can be directly implemented by hardware, a software module executed by a processor, or a combination of the two.
  • the software module can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or all areas in the technical field. Any other known storage media.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Design And Manufacture Of Integrated Circuits (AREA)

Abstract

一种基于硬件环境的卷积计算仿真测试方法、装置、设备及存储介质,该方法包括以下步骤:获取待用于进行卷积计算的数据信息;模拟硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据;将第一结果数据与第二结果数据进行比对,获得第一比对结果,第二结果数据为在硬件环境下使用数据信息进行卷积计算获得的数据;根据第一比对结果,验证硬件实现逻辑是否正确。应用本申请实施例所提供的技术方案,可以有效进行卷积计算的仿真测试,及时发现硬件实现逻辑的错误之处,方便硬件调试,可以提高硬件开发效率。

Description

基于硬件环境的卷积计算仿真测试方法、装置及相关设备
本申请要求于2019年08月16日提交中国专利局、申请号为201910760181.0、发明名称为“基于硬件环境的卷积计算仿真测试方法、装置及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及测试技术领域,特别是涉及一种基于硬件环境的卷积计算仿真测试方法、装置及相关设备。
背景技术
随着计算机技术的快速发展,卷积神经网络逐渐兴起,从而促进了人工智能的进步,使得人工智能在农业、金融、安防、健康医疗、制造等各个领域应用越来越广泛。
卷积神经网络中最重要、计算量最大的地方就是各种各样的卷积计算,为了加快卷积计算的速度,各大硬件产商研发了针对卷积计算的加速卡。卷积计算的硬件加速平台(如FPGA(Field-Programmable Gate Array,现场可编程门阵列)),拥有大量、高效的并行逻辑,但对于卷积计算的数据量大、计算速度快的要求,在硬件上实现的逻辑异常复杂。在对硬件上的卷积计算进行测试时,往往因为硬件板卡上的数据无法有效的显示,使得测试及修复代码漏洞(bug)非常困难。基于上述问题,开发人员在设计软件代码时先经过开发环境(如xilinx FPGA开发环境vivado)进行仿真,通过仿真波形验证逻辑的正确与否,但由于数据量大、计算逻辑复杂,开发人员在仿真时往往耗时巨大、容易出错,使得设计开发进度缓慢。
综上所述,如何有效进行卷积计算仿真测试,提高硬件开发效率,是目前本领域技术人员急需解决的技术问题。
发明内容
本申请的目的是提供一种基于硬件环境的卷积计算仿真测试方法、装 置及相关设备,以有效进行卷积计算的仿真测试,提高硬件开发效率。
为解决上述技术问题,本申请提供如下技术方案:
一种基于硬件环境的卷积计算仿真测试方法,包括:
获取待用于进行卷积计算的数据信息,所述数据信息至少包括输入特征图和权重;
模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据;
将所述第一结果数据与第二结果数据进行比对,获得第一比对结果,所述第二结果数据为在所述硬件环境下使用所述数据信息进行卷积计算获得的数据;
根据所述第一比对结果,验证硬件实现逻辑是否正确。
在本申请的一种具体实施方式中,还包括:
根据所述第一比对结果,定位并输出硬件实现逻辑的错误位置。
在本申请的一种具体实施方式中,所述数据信息为32位浮点数类型,在所述获取待用于进行卷积计算的数据信息之后、所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据之前,还包括:
将所述数据信息由32位浮点数类型量化为8位整数类型。
在本申请的一种具体实施方式中,在所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据之后,还包括:
将所述第一结果数据反量化到32位浮点数类型,获得第一对应结果;
将所述第一对应结果与第二对应结果进行比对,获得第二比对结果,所述第二对应结果为:使用理论卷积计算逻辑,基于32位浮点数类型的所述数据信息进行卷积计算,获得的结果;
根据所述第二比对结果,确定精度损失是否满足预设要求。
在本申请的一种具体实施方式中,所述权重为7x7卷积核,所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据,包括:
将所述7x7卷积核转换为9x9卷积核,并将所述9x9卷积核平分成9个3x3卷积核;
将所述输入特征图按照卷积核拆分的偏移位置拆分成9个特征图;
对9个特征图中的每个特征图进行3x3卷积核的卷积计算,将得到的特征图进行累加得到一个通道的特征图;
在输入通道上进行累加得到输出通道上的特征图数据,获得第一结果数据。
在本申请的一种具体实施方式中,所述权重为3x3卷积核,所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据,包括:
将所述输入特征图依次取出11x11区域;
将每个11x11区域拆分成9个5x5区域;
将每个5x5区域进行数据重排序为9x9矩阵,同时将所述3x3卷积核数据重排序为9x9矩阵;
经过脉动阵列使对应两个9x9矩阵的列相乘累加得出9个数,排成3x3区域,组合得到输出特征图,获得第一结果数据。
在本申请的一种具体实施方式中,所述权重为1x1卷积核,所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据,包括:
将所述输入特征图依次取出9x9矩阵,并将所述1x1卷积核数据重排序为9x9矩阵;
经过脉动阵列使对应两个9x9矩阵相乘得出9x9区域,组合得到输出特征图,获得第一结果数据。
一种基于硬件环境的卷积计算仿真测试装置,包括:
数据信息获取模块,用于获取待用于进行卷积计算的数据信息,所述数据信息至少包括输入特征图和权重;
软件仿真模块,用于模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据;
结果数据比对模块,用于将所述第一结果数据与第二结果数据进行比 对,获得第一比对结果,所述第二结果数据为在所述硬件环境下使用所述数据信息进行卷积计算获得的数据;
逻辑验证模块,用于根据所述第一比对结果,验证硬件实现逻辑是否正确。
一种基于硬件环境的卷积计算仿真测试设备,包括:
存储器,用于存储计算机程序;
处理器,用于执行所述计算机程序时实现上述任一项所述基于硬件环境的卷积计算仿真测试方法的步骤。
一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述任一项所述基于硬件环境的卷积计算仿真测试方法的步骤。
应用本申请实施例所提供的技术方案,获取待用于进行卷积计算的数据信息后,模拟硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据,将第一结果数据与在硬件环境下使用数据信息进行卷积计算获得的第二结果数据进行比对,可以验证硬件实现逻辑是否正确。这样可以有效进行卷积计算的仿真测试,及时发现硬件实现逻辑的错误之处,方便硬件调试,可以提高硬件开发效率。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例中一种基于硬件环境的卷积计算仿真测试方法的实施流程图;
图2为本申请实施例中一种卷积核平分方式示意图;
图3为本申请实施例中一种区域提取方式示意图;
图4为本申请实施例中一种基于硬件环境的卷积计算仿真测试装置的结构示意图;
图5为本申请实施例中一种基于硬件环境的卷积计算仿真测试设备的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本申请方案,下面结合附图和具体实施方式对本申请作进一步的详细说明。显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
参见图1所示,为本申请实施例所提供的一种基于硬件环境的卷积计算仿真测试方法的实施流程图,该方法可以包括以下步骤:
S110:获取待用于进行卷积计算的数据信息。
数据信息至少包括输入特征图(featuremap)和权重。
在测试之初,先获取待用于进行卷积计算的数据信息。具体的,可以通过硬件操作句柄和硬件板卡通信,读取相关数据信息,并写入硬件内存。数据信息至少包括输入特征图和权重,还可以包括量化参数等数据。
S120:模拟预设的硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据。
硬件环境中的卷积计算实现逻辑可以包括卷积核拆分、取特征图数据方式、数据重排序、脉动阵列计算、数据累加等逻辑。本申请实施例就是仿真卷积计算在硬件上的实现,需模拟预设的硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,从而获得第一结果数据。
在本申请的一种具体实施方式中,权重为7x7卷积核,步骤S120可以包括以下步骤:
步骤一:将7x7卷积核转换为9x9卷积核,并将9x9卷积核平分成9个3x3卷积核;
步骤二:将输入特征图按照卷积核拆分的偏移位置拆分成9个特征图;
步骤三:对9个特征图中的每个特征图与对应的3x3卷积核进行卷积计算,将得到的特征图进行累加得到一个通道的特征图;
步骤四:在输入通道上进行累加得到输出通道上的特征图数据,获得第一结果数据。
为便于描述,将上述四个步骤结合起来进行说明。
在获取到待用于进行卷积计算的数据信息后,可以先判断数据信息中的权重是否为7x7卷积核,如果是,则可以将7x7卷积核转换为9x9卷积核,如将7x7卷积核在右、下补0,成为9x9卷积核,如图2所示。然后将9x9卷积核平分成9个3x3卷积核。具体的,可以将9x9卷积核从左到右、从上到下平分成9个3x3卷积核,如图2所示。同时,将7x7卷积核对应的输入特征图按照卷积核拆分的偏移位置拆分成9个特征图,这9个特征图需符合3x3卷积核的填充(padding)尺寸,不足的地方补0。对9个特征图中的每个特征图与对应的3x3卷积核进行卷积计算,将得到的特征图进行累加得到一个通道的特征图。上述卷积核进行卷积计算之后,都得到一个通道上的特征图,在输入通道上进行累加得到输出通道上的特征图数据,获得第一结果数据。
在本申请的另一种具体实施方式中,权重为3x3卷积核,步骤S120可以包括以下步骤:
第一个步骤:将输入特征图依次取出11x11区域;
第二个步骤:将每个11x11区域拆分成9个5x5区域;
第三个步骤:将每个5x5区域进行数据重排序为9x9矩阵,同时将3x3卷积核数据重排序为9x9矩阵;
第四个步骤:经过脉动阵列使对应两个9x9矩阵的列相乘累加得出9个数,排成3x3区域,组合得到输出特征图,获得第一结果数据。
为便于描述,将上述四个步骤结合起来进行说明。
在获取到待用于进行卷积计算的数据信息后,可以判断数据信息中的权重是否为3x3卷积核,如果是,则可以先将3x3卷积核对应的输入特征图依次取出11x11区域,后11x11区域与前11x11区域可以有2列或2行的重叠,然后将每个11x11区域再拆分出9个5x5区域,后5x5区域与前 5x5区域之间可以有2行或2列的重叠,如图3所示,再将每个5x5区域进行数据重排序为9x9矩阵,同时将3x3卷积核数据重排序为9x9矩阵,经过脉动阵列使对应两个9x9矩阵的列相乘累加得出9个数,排成3x3区域,组合得到输出特征图,获得第一结果数据。
在本申请的另一个实施例中,权重为1x1卷积核,步骤S120可以包括以下步骤:
步骤一:将输入特征图依次取出9x9矩阵,并将1x1卷积核数据重排序为9x9矩阵;
步骤二:经过脉动阵列使对应两个9x9矩阵相乘得出9x9区域,组合得到输出特征图,获得第一结果数据。
为便于描述,将上述两个步骤结合起来进行说明。
在获取到待用于进行卷积计算的数据信息后,可以判断数据信息中的权重是否为1x1卷积核,如果是,则可以将1x1卷积核对应的输入特征图依次取出9x9矩阵,同时将1x1卷积核排成9x9矩阵,9x9矩阵中的81个数都是1x1的数据,经过脉动阵列使对应两个9x9矩阵相乘得出9x9区域,组合得到输出特征图,获得第一结果数据。
S130:将第一结果数据与第二结果数据进行比对,获得第一比对结果。
第二结果数据为在硬件环境下使用数据信息进行卷积计算获得的数据。
在硬件环境下使用数据信息进行卷积计算可以获得第二结果数据。通过硬件句柄可以读出第二结果数据。
将第一结果数据与第二结果数据进行比对,可以获得第一对比结果。
S140:根据第一比对结果,验证硬件实现逻辑是否正确。
根据第一比对结果,可以验证硬件实现逻辑是否正确,并可定位并输出硬件实现逻辑的错误位置。
应用本申请实施例所提供的方法,获取待用于进行卷积计算的数据信息后,模拟硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据,将第一结果数据与在硬件环境下使用数据信息进行卷积计算获得的第二结果数据进行比对,可以验证硬件实现逻辑 是否正确。这样可以有效进行卷积计算的仿真测试,及时发现硬件实现逻辑的错误之处,方便硬件调试,可以提高硬件开发效率。
在本申请的一个实施例中,数据信息为32位浮点数类型,在步骤S110之后、步骤S120之前,该方法还可以包括以下步骤:
将数据信息由32位浮点数类型量化为8位整数类型。
在步骤S120之后,该方法还可以包括以下步骤:
第一个步骤:将第一结果数据反量化到32位浮点数类型,获得第一对应结果;
第二个步骤:将第一对应结果与第二对应结果进行比对,获得第二比对结果,第二对应结果为:使用理论卷积计算逻辑,基于32位浮点数类型的数据信息进行卷积计算,获得的结果;
第三个步骤:根据第二比对结果,确定精度损失是否满足预设要求。
在本申请实施例中,获取到的待用于进行卷积计算的数据信息可以为32位浮点数类型,为了有利于硬件平台的计算,可以将数据信息由32位浮点数类型量化为8位整数类型。
进而在步骤S120模拟硬件环境的卷积计算实现逻辑,可以基于8位整数类型的数据信息进行卷积计算的软件仿真,获得第一结果数据。
在获得第一结果数据之后,可以将第一结果数据反量化到32位浮点数类型,获得第一对应结果。同时,可以使用理论卷积计算逻辑,基于32位浮点数类型的数据信息进行卷积计算,获得第二对应结果。将第一对应结果与第二对应结果进行比对,可以获得第二比对结果,根据第二比对结果,可以确定精度损失,并确定精度损失是否满足预设要求。该预设要求可以根据实际情况进行设定和调整。
在确定精度损失不满足预设要求的情况下,可以对数据信息,如输入特征图、权重、量化参数等数据进行调整,以便更好地进行卷积计算的仿真测试。
本申请实施例针对已有硬件环境上的卷积计算,存在数据量大、环境封闭等调试难问题,仿真卷积计算在硬件上的实现,能有效的对计算的结果进行仿真,与硬件实现的结果比对,判断硬件实现卷积计算的正确性, 从而为硬件开发提供依据。也就是说,将卷积计算在硬件上的实现逻辑,搬到软件上进行仿真,能够清晰地看到硬件实现中不易查看的中间结果,并对大量数据进行比对,判断硬件实现逻辑的正确与否,快速定位硬件实现逻辑的错误位置,有利于硬件开发。
相应于上面的方法实施例,本申请实施例还提供了一种基于硬件环境的卷积计算仿真测试装置,下文描述的一种基于硬件环境的卷积计算仿真测试装置与上文描述的一种基于硬件环境的卷积计算仿真测试方法可相互对应参照。
参见图4所示,该装置包括以下模块:
数据信息获取模块210,用于获取待用于进行卷积计算的数据信息,数据信息至少包括输入特征图和权重;
软件仿真模块220,用于模拟硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据;
结果数据比对模块230,用于将第一结果数据与第二结果数据进行比对,获得第一比对结果,第二结果数据为在硬件环境下使用数据信息进行卷积计算获得的数据;
逻辑验证模块240,用于根据第一比对结果,验证硬件实现逻辑是否正确。
应用本申请实施例所提供的装置,获取待用于进行卷积计算的数据信息后,模拟硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据,将第一结果数据与在硬件环境下使用数据信息进行卷积计算获得的第二结果数据进行比对,可以验证硬件实现逻辑是否正确。这样可以有效进行卷积计算的仿真测试,及时发现硬件实现逻辑的错误之处,方便硬件调试,可以提高硬件开发效率。
在本申请的一种具体实施方式中,还包括:
错误定位模块,用于根据第一比对结果,定位并输出硬件实现逻辑的错误位置。
在本申请的一种具体实施方式中,数据信息为32位浮点数类型,还包括:
量化模块,用于在获取待用于进行卷积计算的数据信息之后、模拟硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据之前,将数据信息由32位浮点数类型量化为8位整数类型。
在本申请的一种具体实施方式中,还包括:
精度损失确定模块,用于在模拟硬件环境的卷积计算实现逻辑,基于数据信息进行卷积计算的软件仿真,获得第一结果数据之后,将第一结果数据反量化到32位浮点数类型,获得第一对应结果;将第一对应结果与第二对应结果进行比对,获得第二比对结果,第二对应结果为:使用理论卷积计算逻辑,基于32位浮点数类型的数据信息进行卷积计算,获得的结果;根据第二比对结果,确定精度损失是否满足预设要求。
在本申请的一种具体实施方式中,权重为7x7卷积核,软件仿真模块220,具体用于:
将7x7卷积核转换为9x9卷积核,并将9x9卷积核平分成9个3x3卷积核;
将输入特征图按照卷积核拆分的偏移位置拆分成9个特征图;
对9个特征图中的每个特征图与对应的3x3卷积核进行卷积计算,将得到的特征图进行累加得到一个通道的特征图;
在输入通道上进行累加得到输出通道上的特征图数据,获得第一结果数据。
在本申请的一种具体实施方式中,权重为3x3卷积核,软件仿真模块220,具体用于:
将输入特征图依次取出11x11区域;
将每个11x11区域拆分成9个5x5区域;
将每个5x5区域进行数据重排序为9x9矩阵,同时将3x3卷积核数据重排序为9x9矩阵;
经过脉动阵列使对应两个9x9矩阵的列相乘累加得出9个数,排成3x3区域,组合得到输出特征图,获得第一结果数据。
在本申请的一种具体实施方式中,权重为1x1卷积核,软件仿真模块220,具体用于:
将输入特征图依次取出9x9矩阵,并将1x1卷积核数据重排序为9x9矩阵;
经过脉动阵列使对应两个9x9矩阵相乘得出9x9区域,组合得到输出特征图,获得第一结果数据。
相应于上面的方法实施例,本申请实施例还提供了一种基于硬件环境的卷积计算仿真测试设备,如图5所示,包括:
存储器310,用于存储计算机程序;
处理器320,用于执行计算机程序时实现上述基于硬件环境的卷积计算仿真测试方法的步骤。
相应于上面的方法实施例,本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述基于硬件环境的卷积计算仿真测试方法的步骤。
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。
本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的技术方案及其核心思想。应当指 出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请权利要求的保护范围内。

Claims (10)

  1. 一种基于硬件环境的卷积计算仿真测试方法,其特征在于,包括:
    获取待用于进行卷积计算的数据信息,所述数据信息至少包括输入特征图和权重;
    模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据;
    将所述第一结果数据与第二结果数据进行比对,获得第一比对结果,所述第二结果数据为在所述硬件环境下使用所述数据信息进行卷积计算获得的数据;
    根据所述第一比对结果,验证硬件实现逻辑是否正确。
  2. 根据权利要求1所述的方法,其特征在于,还包括:
    根据所述第一比对结果,定位并输出硬件实现逻辑的错误位置。
  3. 根据权利要求1所述的方法,其特征在于,所述数据信息为32位浮点数类型,在所述获取待用于进行卷积计算的数据信息之后、所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据之前,还包括:
    将所述数据信息由32位浮点数类型量化为8位整数类型。
  4. 根据权利要求3所述的方法,其特征在于,在所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据之后,还包括:
    将所述第一结果数据反量化到32位浮点数类型,获得第一对应结果;
    将所述第一对应结果与第二对应结果进行比对,获得第二比对结果,所述第二对应结果为:使用理论卷积计算逻辑,基于32位浮点数类型的所述数据信息进行卷积计算,获得的结果;
    根据所述第二比对结果,确定精度损失是否满足预设要求。
  5. 根据权利要求1至4之中任一项所述的方法,其特征在于,所述权重为7x7卷积核,所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据,包括:
    将所述7x7卷积核转换为9x9卷积核,并将所述9x9卷积核平分成9 个3x3卷积核;
    将所述输入特征图按照卷积核拆分的偏移位置拆分成9个特征图;
    对9个特征图中的每个特征图与对应的3x3卷积核进行卷积计算,将得到的特征图进行累加得到一个通道的特征图;
    在输入通道上进行累加得到输出通道上的特征图数据,获得第一结果数据。
  6. 根据权利要求1至4之中任一项所述的方法,其特征在于,所述权重为3x3卷积核,所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据,包括:
    将所述输入特征图依次取出11x11区域;
    将每个11x11区域拆分成9个5x5区域;
    将每个5x5区域进行数据重排序为9x9矩阵,同时将所述3x3卷积核数据重排序为9x9矩阵;
    经过脉动阵列使对应两个9x9矩阵的列相乘累加得出9个数,排成3x3区域,组合得到输出特征图,获得第一结果数据。
  7. 根据权利要求1至4之中任一项所述的方法,其特征在于,所述权重为1x1卷积核,所述模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据,包括:
    将所述输入特征图依次取出9x9矩阵,并将所述1x1卷积核数据重排序为9x9矩阵;
    经过脉动阵列使对应两个9x9矩阵相乘得出9x9区域,组合得到输出特征图,获得第一结果数据。
  8. 一种基于硬件环境的卷积计算仿真测试装置,其特征在于,包括:
    数据信息获取模块,用于获取待用于进行卷积计算的数据信息,所述数据信息至少包括输入特征图和权重;
    软件仿真模块,用于模拟硬件环境的卷积计算实现逻辑,基于所述数据信息进行卷积计算的软件仿真,获得第一结果数据;
    结果数据比对模块,用于将所述第一结果数据与第二结果数据进行比对,获得第一比对结果,所述第二结果数据为在所述硬件环境下使用所述 数据信息进行卷积计算获得的数据;
    逻辑验证模块,用于根据所述第一比对结果,验证硬件实现逻辑是否正确。
  9. 一种基于硬件环境的卷积计算仿真测试设备,其特征在于,包括:
    存储器,用于存储计算机程序;
    处理器,用于执行所述计算机程序时实现如权利要求1至7任一项所述基于硬件环境的卷积计算仿真测试方法的步骤。
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述基于硬件环境的卷积计算仿真测试方法的步骤。
PCT/CN2019/114532 2019-08-16 2019-10-31 基于硬件环境的卷积计算仿真测试方法、装置及相关设备 WO2021031345A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910760181.0 2019-08-16
CN201910760181.0A CN110516334B (zh) 2019-08-16 2019-08-16 基于硬件环境的卷积计算仿真测试方法、装置及相关设备

Publications (1)

Publication Number Publication Date
WO2021031345A1 true WO2021031345A1 (zh) 2021-02-25

Family

ID=68626410

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/114532 WO2021031345A1 (zh) 2019-08-16 2019-10-31 基于硬件环境的卷积计算仿真测试方法、装置及相关设备

Country Status (2)

Country Link
CN (1) CN110516334B (zh)
WO (1) WO2021031345A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113392973A (zh) * 2021-06-25 2021-09-14 广东工业大学 一种基于fpga的ai芯片神经网络加速方法

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111258839B (zh) * 2020-02-16 2022-11-29 苏州浪潮智能科技有限公司 一种基于ResNet50网络的AI加速卡仿真测试系统及其工作方法
CN111737159B (zh) * 2020-08-27 2021-02-09 苏州浪潮智能科技有限公司 一种软件调试方法、装置、设备及计算机可读存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104346272A (zh) * 2013-07-24 2015-02-11 无锡华润微电子有限公司 芯片自动仿真验证系统
US9262303B2 (en) * 2008-12-05 2016-02-16 Altera Corporation Automated semiconductor design flaw detection system
CN108038328A (zh) * 2017-12-24 2018-05-15 苏州赛源微电子有限公司 芯片自动仿真验证系统
CN109558329A (zh) * 2018-12-10 2019-04-02 广东浪潮大数据研究有限公司 一种程序检测方法、装置、设备及可读存储介质
CN109857640A (zh) * 2018-12-28 2019-06-07 上海航天控制技术研究所 一种基于原型设计的嵌入式代码提前验证方法

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105302950B (zh) * 2015-10-19 2018-07-24 北京精密机电控制设备研究所 一种软、硬件协同的可编程逻辑器件交联仿真测试方法
US10621486B2 (en) * 2016-08-12 2020-04-14 Beijing Deephi Intelligent Technology Co., Ltd. Method for optimizing an artificial neural network (ANN)
GB2570187B (en) * 2017-11-06 2022-07-06 Imagination Tech Ltd Single plane filters
CN107993186B (zh) * 2017-12-14 2021-05-25 中国人民解放军国防科技大学 一种基于Winograd算法的3D CNN加速方法及系统
CN108629411A (zh) * 2018-05-07 2018-10-09 济南浪潮高新科技投资发展有限公司 一种卷积运算硬件实现装置及方法
CN109934339B (zh) * 2019-03-06 2023-05-16 东南大学 一种基于一维脉动阵列的通用卷积神经网络加速器

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9262303B2 (en) * 2008-12-05 2016-02-16 Altera Corporation Automated semiconductor design flaw detection system
CN104346272A (zh) * 2013-07-24 2015-02-11 无锡华润微电子有限公司 芯片自动仿真验证系统
CN108038328A (zh) * 2017-12-24 2018-05-15 苏州赛源微电子有限公司 芯片自动仿真验证系统
CN109558329A (zh) * 2018-12-10 2019-04-02 广东浪潮大数据研究有限公司 一种程序检测方法、装置、设备及可读存储介质
CN109857640A (zh) * 2018-12-28 2019-06-07 上海航天控制技术研究所 一种基于原型设计的嵌入式代码提前验证方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113392973A (zh) * 2021-06-25 2021-09-14 广东工业大学 一种基于fpga的ai芯片神经网络加速方法

Also Published As

Publication number Publication date
CN110516334B (zh) 2021-12-03
CN110516334A (zh) 2019-11-29

Similar Documents

Publication Publication Date Title
WO2021031345A1 (zh) 基于硬件环境的卷积计算仿真测试方法、装置及相关设备
US8271252B2 (en) Automatic verification of device models
Kennedy et al. Case studies in Gaussian process modelling of computer codes
US7765500B2 (en) Automated generation of theoretical performance analysis based upon workload and design configuration
US9465718B2 (en) Filter generation for load testing managed environments
CN110197183A (zh) 一种图像盲去噪的方法、装置和计算机设备
CN114462338A (zh) 一种集成电路的验证方法、装置、计算机设备及存储介质
US20120246606A1 (en) Generation of an end point report for a timing simulation of an integrated circuit
CN103793032B (zh) 用于确定上电复位的方法和装置
CN110263328A (zh) 一种学科能力类型标注方法、装置、存储介质及终端设备
CN114842270A (zh) 一种目标图像的分类方法、装置、电子设备及介质
CN114021440B (zh) 一种基于matlab的fpga时序仿真验证方法及装置
Sun et al. Model checking for partially linear models with missing responses at random
CN108875789B (zh) 一种基于深度学习的甘蔗蔗芽特征识别装置
CN113642667B (zh) 一种图片增强策略确定方法、装置、电子设备及存储介质
CN114791883A (zh) 一种基于高阶变异的程序自动化错误定位方法及系统
US10740521B1 (en) System and method for localized logic simulation replay using emulated values
CN114092813A (zh) 一种工业园区图像提取方法、模型、电子设备和存储介质
CN114077884A (zh) 深度学习模型的模型转换优化装置、方法及可读存储介质
US20190205491A1 (en) Method and apparatus of emulation techniques for enhanced fpga validation
Gentleman et al. Use R!.
Romli et al. Improving the reliability and validity of test data adequacy in programming assessments
US20070277133A1 (en) Model correspondence method and device
Milroy et al. Investigating the impact of mixed precision on correctness for a large climate code
CN117112847B (zh) 一种基于社区模型的图数据库的数据生成方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19942601

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19942601

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 19942601

Country of ref document: EP

Kind code of ref document: A1