[go: up one dir, main page]

CN116325703A - A data format processing method and device - Google Patents

A data format processing method and device Download PDF

Info

Publication number
CN116325703A
CN116325703A CN202080105412.5A CN202080105412A CN116325703A CN 116325703 A CN116325703 A CN 116325703A CN 202080105412 A CN202080105412 A CN 202080105412A CN 116325703 A CN116325703 A CN 116325703A
Authority
CN
China
Prior art keywords
format
computing unit
unit
computing
data
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202080105412.5A
Other languages
Chinese (zh)
Inventor
俞郑中
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of CN116325703A publication Critical patent/CN116325703A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/84Mapping; Conversion

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the application discloses a data format processing method and device, relates to the technical field of artificial intelligence, solves the problem of high performance overhead caused by excessive format conversion processing in the prior art, and improves user experience. The specific scheme is as follows: the method is applied to a computing network, and the computing network sequentially comprises a first computing unit and a second computing unit, and comprises the following steps: acquiring data formats supported by a first computing unit and a second computing unit; if the first computing unit is determined not to support the format of the input data of the first computing unit, adding a first format conversion unit before the first computing unit, wherein the first format conversion unit is used for converting the format of the input data of the first computing unit into a data format supported by the first computing unit; if it is determined that the second computing unit supports the format of the output data of the first computing unit, it is determined that the format conversion process is not performed between the first computing unit and the second computing unit.

Description

一种数据格式处理方法和装置A data format processing method and device 技术领域technical field

本申请实施例涉及人工智能技术领域,尤其涉及一种数据格式处理方法和装置。The embodiments of the present application relate to the technical field of artificial intelligence, and in particular, to a data format processing method and device.

背景技术Background technique

在人工智能(artificial intelligence,AI)芯片中,为了充分发挥芯片的计算能力,通常要求数据按照特定的格式进行排布,由于不同的运算要求的数据格式不同,因此可能需要对不同格式的数据进行转换。In an artificial intelligence (AI) chip, in order to give full play to the computing power of the chip, it is usually required that the data be arranged in a specific format. Since different operations require different data formats, it may be necessary to process data in different formats. convert.

图1为一种计算网络的结构示意图,如图1所示,该计算网络中的算子序列依次包括卷积Conv1算子、激活函数单元Relu1算子、Conv2算子和Relu2算子,其中,Conv算子要求输入数据的格式按照NC1HWC0格式排布,Relu算子要求输入数据的格式按照ND格式排布。由于原始图片的数据格式为NHWC格式,与Conv1算子要求的输入数据的格式不同,因此需要对输入数据的格式进行转换。Fig. 1 is a schematic structural diagram of a computing network. As shown in Fig. 1, the operator sequence in the computing network includes convolution Conv1 operator, activation function unit Relu1 operator, Conv2 operator and Relu2 operator in turn, wherein, The Conv operator requires the format of the input data to be arranged in the NC1HWC0 format, and the Relu operator requires the format of the input data to be arranged in the ND format. Since the data format of the original image is NHWC format, which is different from the format of the input data required by the Conv1 operator, the format of the input data needs to be converted.

图2为一种数据格式转换处理的示意图,如图2所示,可以通过在Conv算子内的开始位置和结束位置分别增加格式转换处理逻辑,Conv算子内的开始位置增加的格式转换处理逻辑可以将输入数据的格式由NHWC格式转换为NC1HWC0格式,Conv算子内的结束位置增加的格式转换处理逻辑可以将输出数据的格式由NC1HWC0格式转换为NHWC格式。但是,该方法在算子内部增加格式转换处理逻辑后,增加了算子的耗时,降低了算子的性能。如果网络中存在多个Conv算子,那么每个Conv算子内部都存在转换逻辑,因此格式转换处理较多,导致网络性能开销很大。Figure 2 is a schematic diagram of data format conversion processing, as shown in Figure 2, the format conversion processing can be added by adding format conversion processing logic at the start position and end position in the Conv operator, and the start position in the Conv operator The logic can convert the format of the input data from the NHWC format to the NC1HWC0 format, and the format conversion processing logic added to the end position in the Conv operator can convert the format of the output data from the NC1HWC0 format to the NHWC format. However, this method increases the time consumption of the operator and reduces the performance of the operator after the format conversion processing logic is added inside the operator. If there are multiple Conv operators in the network, each Conv operator has conversion logic inside, so there are more format conversion processes, resulting in a large network performance overhead.

发明内容Contents of the invention

本申请实施例提供一种数据格式处理方法和装置,能够减少格式转换处理,提升网络性能。Embodiments of the present application provide a data format processing method and device, which can reduce format conversion processing and improve network performance.

为达到上述目的,本申请实施例采用如下技术方案:In order to achieve the above purpose, the embodiment of the present application adopts the following technical solutions:

本申请实施例的第一方面,提供一种数据格式处理方法,应用于一种计算网络,该计算网络中依次包括第一计算单元和第二计算单元,该方法包括:获取第一计算单元和第二计算单元支持的数据格式;若确定第一计算单元不支持第一计算单元的输入数据的格式,在第一计算单元之前添加第一格式转换单元,该第一格式转换单元用于将第一计算单元的输入数据的格式转换为第一计算单元支持的数据格式;若确定第二计算单元支持第一计算单元的输出数据的格式,确定不在第一计算单元和第二计算单元之间进行格式转换处理。基于本方案,在第一计算单元不支持第一计算单元的输入数据的格式时,在第一计算单元之前添加第一格式转换单元,以将第一计算单元的输入数据的格式转换为第一计算单元支持的数据格式,在第二计算单元支持第一计算单元的输出数据的格式时,确定不在第一计算单元和第二计算单元之间进行格式转换处理,即确定不在第一计算单元和第二计算单元之间插入格式转换算子因此,减少了网络中格式转换单元的数量,减少了网络中的格式处理,提升了网络性能。According to the first aspect of the embodiments of the present application, a data format processing method is provided, which is applied to a computing network, and the computing network includes a first computing unit and a second computing unit in sequence, and the method includes: obtaining the first computing unit and the The data format supported by the second calculation unit; if it is determined that the first calculation unit does not support the format of the input data of the first calculation unit, a first format conversion unit is added before the first calculation unit, and the first format conversion unit is used to convert the first calculation unit The format of the input data of a computing unit is converted to the data format supported by the first computing unit; if it is determined that the second computing unit supports the format of the output data of the first computing unit, it is determined not to perform between the first computing unit and the second computing unit Format conversion processing. Based on this scheme, when the first computing unit does not support the format of the input data of the first computing unit, a first format conversion unit is added before the first computing unit to convert the format of the input data of the first computing unit into the first For the data format supported by the computing unit, when the second computing unit supports the format of the output data of the first computing unit, it is determined not to perform format conversion processing between the first computing unit and the second computing unit, that is, it is determined not to perform format conversion processing between the first computing unit and the second computing unit. The format conversion operator is inserted between the second calculation units. Therefore, the number of format conversion units in the network is reduced, the format processing in the network is reduced, and the network performance is improved.

可选的,计算网络包括三个或三个以上计算单元时,上述第一计算单元和第二计算单元可以为该计算网络中任意连续的两个计算单元。例如,第一计算单元为计算网 络的首个计算单元时,第二计算单元为该首个计算单元之后的计算单元。再例如,第一计算单元为位于计算网络的中间位置的计算单元时,第二计算单元为该第一计算单元之后的计算单元。Optionally, when the computing network includes three or more computing units, the above-mentioned first computing unit and the second computing unit may be any consecutive two computing units in the computing network. For example, when the first computing unit is the first computing unit of the computing network, the second computing unit is the computing unit after the first computing unit. For another example, when the first computing unit is a computing unit located in the middle of the computing network, the second computing unit is a computing unit after the first computing unit.

可以理解的,本申请在进行格式处理时,当第二个算子不支持第一个算子的输出数据的格式时,在第一个算子和第二个算子之间插入数据转换单元,当第三个算子支持第二个算子的输出数据的格式时,确定不在第二个算子和第三个算子之间插入数据转换单元,当第四个算子支持第三个算子的输出数据的格式时,确定不在第三个算子和第四个算子之间插入数据转换单元,直至第N个算子不支持第N-1个算子的输出数据的格式时,才会在第N-1个算子和第N个算子之间插入数据转换单元,即本申请在判断是否进行数据格式转换处理时,考虑了多个算子支持的数据格式的连续性,与现有技术相比,能够大大减少格式转换处理,提升网络性能。It can be understood that when the application performs format processing, when the second operator does not support the format of the output data of the first operator, a data conversion unit is inserted between the first operator and the second operator , when the third operator supports the output data format of the second operator, it is determined not to insert a data conversion unit between the second operator and the third operator, when the fourth operator supports the third When determining the format of the output data of an operator, it is determined not to insert a data conversion unit between the third operator and the fourth operator until the Nth operator does not support the format of the output data of the N-1th operator , the data conversion unit will be inserted between the N-1th operator and the Nth operator, that is, the application considers the continuity of the data format supported by multiple operators when judging whether to perform data format conversion processing , compared with the prior art, the format conversion process can be greatly reduced, and the network performance can be improved.

结合第一方面,在一种可能的实现方式中,在上述第一计算单元为上述计算网络中的首个计算单元的情况下,上述第一计算单元的输入数据的格式为上述计算网络的原始输入数据的格式。基于本方案,在首个计算单元不支持原始输入数据的格式的情况下,在首个计算单元之前插入格式转换处理单元,以将原始输入数据的格式转换为首个计算单元支持的数据格式,从而能够使得首个计算单元的运算正常进行。With reference to the first aspect, in a possible implementation manner, when the first computing unit is the first computing unit in the computing network, the format of the input data of the first computing unit is the original The format of the input data. Based on this scheme, when the first computing unit does not support the format of the original input data, a format conversion processing unit is inserted before the first computing unit to convert the format of the original input data into a data format supported by the first computing unit, thereby It can make the operation of the first computing unit go on normally.

结合第一方面和上述可能的实现方式,在另一种可能的实现方式中,在上述第一计算单元为上述计算网络中位于中间位置的计算单元的情况下,上述第一计算单元的输入数据的格式为上述第一计算单元之前的计算单元的输出数据的格式。基于本方案,在位于中间位置的第一计算单元不支持前一个计算单元的输出数据的格式的情况下,在第一计算单元的前一个计算单元和第一计算单元之间插入格式转换处理单元,以将第一计算单元的前一个计算单元的输出数据的格式转换为第一计算单元支持的数据格式,从而能够使得第一计算单元的运算正常进行。In combination with the first aspect and the above-mentioned possible implementation, in another possible implementation, when the above-mentioned first computing unit is a computing unit located in the middle of the above-mentioned computing network, the input data of the above-mentioned first computing unit The format of is the format of the output data of the calculation units preceding the first calculation unit. Based on this scheme, when the first computing unit in the middle does not support the format of the output data of the previous computing unit, a format conversion processing unit is inserted between the previous computing unit of the first computing unit and the first computing unit , to convert the output data format of the previous computing unit of the first computing unit into a data format supported by the first computing unit, so that the operation of the first computing unit can be performed normally.

结合第一方面和上述可能的实现方式,在另一种可能的实现方式中,在上述第二计算单元支持多个数据格式的情况下,确定上述第二计算单元支持上述第一计算单元的输出数据的格式,包括:若上述第二计算单元支持的多个数据格式包括上述第一计算单元的输出数据的格式,确定上述第二计算单元支持上述第一计算单元的输出数据的格式。基于本方案,在第二计算单元支持的多个数据格式包括第一计算单元的输出数据的格式的情况下,可以确定第二计算单元支持第一计算单元的输出数据的格式,从而确定不在第一计算单元和第二计算单元之间进行格式转换处理,因此减少了网络中格式转换处理的次数,提升了网络性能。可选的,在第二计算单元支持的一个数据格式与第一计算单元的输出数据的格式相同的情况下,可以确定第二计算单元支持第一计算单元的输出数据的格式。In combination with the first aspect and the above-mentioned possible implementation, in another possible implementation, in the case that the above-mentioned second computing unit supports multiple data formats, it is determined that the above-mentioned second computing unit supports the output of the above-mentioned first computing unit The data format includes: if the multiple data formats supported by the second computing unit include the format of the output data of the first computing unit, determining that the second computing unit supports the format of the output data of the first computing unit. Based on this scheme, when the multiple data formats supported by the second computing unit include the format of the output data of the first computing unit, it can be determined that the second computing unit supports the format of the output data of the first computing unit, so that it is determined that the format of the output data of the first computing unit is not Format conversion processing is performed between the first computing unit and the second computing unit, thereby reducing the number of format conversion processing times in the network and improving network performance. Optionally, in a case where a data format supported by the second computing unit is the same as the output data format of the first computing unit, it may be determined that the second computing unit supports the format of the output data of the first computing unit.

结合第一方面和上述可能的实现方式,在另一种可能的实现方式中,上述获取上述第一计算单元和上述第二计算单元支持的数据格式,包括:获取上述第一计算单元和上述第二计算单元的预置模式类型;该预置模式类型包括格式无关类、约减Reduce类和广播Broadcast类;根据上述第一计算单元和上述第二计算单元的预置模式类型,确定上述第一计算单元和上述第二计算单元支持的数据格式。基于本方案,在算子信息库中可以为每个算子划分模式类型,从而根据算子的模式类型信息即可确定算子支 持的数据格式,能够减少算子信息库中的信息量,不需要对算子支持的每种格式都进行配置。而且通过算子信息库配置算子的预置模式类型,能够使得算子实现不用关注具体的格式,直接按照算子的输入shape和属性进行运算即可,减少了算子开发中格式处理的负担。In combination with the first aspect and the above possible implementation manner, in another possible implementation manner, the acquisition of the data format supported by the first computing unit and the second computing unit includes: acquiring the data format supported by the first computing unit and the second computing unit 2. The preset mode type of the computing unit; the preset mode type includes format-independent class, reduction Reduce class and broadcast Broadcast class; according to the preset mode types of the first computing unit and the second computing unit, determine the first The data format supported by the computing unit and the above-mentioned second computing unit. Based on this scheme, the mode type can be divided for each operator in the operator information base, so that the data format supported by the operator can be determined according to the mode type information of the operator, which can reduce the amount of information in the operator information base. Each format supported by the operator needs to be configured. Moreover, configuring the preset mode type of the operator through the operator information library can enable the implementation of the operator without paying attention to the specific format, and can directly perform operations according to the input shape and attributes of the operator, reducing the burden of format processing in operator development. .

结合第一方面和上述可能的实现方式,在另一种可能的实现方式中,上述方法还包括:若确定上述计算网络的最后一个计算单元的输出数据的格式与上述计算网络的原始输出数据的格式不同,在上述计算网络的最后一个计算单元之后添加第二格式转换单元,该第二格式转换单元用于将上述最后一个计算单元的输出数据的格式转换为上述计算网络的原始输出数据的格式。基于本方案,通过在计算网络的最后一个计算单元的输出数据的格式与原始输出数据的格式不同时,通过格式转换处理,以保持计算网络的输出数据的格式与原始输出数据的格式一致。可选的,当第二计算单元为计算网络的最后一个计算单元时,如果第二计算单元的输出数据的格式与原始输出数据的格式不同,在第二计算单元之后插入格式转换算子,以将第二计算单元的输出数据的格式转换为原始输出数据的格式。In combination with the first aspect and the above possible implementation manner, in another possible implementation manner, the above method further includes: if it is determined that the format of the output data of the last computing unit of the above computing network is different from the format of the original output data of the above computing network The formats are different, and a second format conversion unit is added after the last calculation unit of the above-mentioned calculation network, and the second format conversion unit is used to convert the format of the output data of the above-mentioned last calculation unit into the format of the original output data of the above-mentioned calculation network . Based on this solution, when the format of the output data of the last computing unit of the computing network is different from that of the original output data, format conversion is performed to keep the format of the output data of the computing network consistent with the format of the original output data. Optionally, when the second computing unit is the last computing unit of the computing network, if the format of the output data of the second computing unit is different from that of the original output data, a format conversion operator is inserted after the second computing unit to Converting the format of the output data of the second computing unit to the format of the original output data.

本申请实施例的第二方面,提供一种数据格式处理装置,应用于一种计算网络,该计算网络中依次包括第一计算单元和第二计算单元,该装置包括:处理单元和获取单元;该获取单元,用于获取第一计算单元和第二计算单元支持的数据格式;该处理单元,用于若确定第一计算单元不支持第一计算单元的输入数据的格式,在第一计算单元之前添加第一格式转换单元,该第一格式转换单元用于将第一计算单元的输入数据的格式转换为第一计算单元支持的数据格式;处理单元,还用于若确定第二计算单元支持第一计算单元的输出数据的格式,确定不在第一计算单元和第二计算单元之间进行格式转换处理。The second aspect of the embodiment of the present application provides a data format processing device, which is applied to a computing network, and the computing network includes a first computing unit and a second computing unit in sequence, and the device includes: a processing unit and an acquisition unit; The obtaining unit is used to obtain the data format supported by the first computing unit and the second computing unit; the processing unit is used to determine that the first computing unit does not support the format of the input data of the first computing unit, in the first computing unit A first format conversion unit is added before, and the first format conversion unit is used to convert the format of the input data of the first computing unit into a data format supported by the first computing unit; the processing unit is also used to determine that the second computing unit supports The format of the output data of the first computing unit is determined not to perform format conversion processing between the first computing unit and the second computing unit.

结合第二方面,在一种可能的实现方式中,在上述第一计算单元为上述计算网络中的首个计算单元的情况下,上述第一计算单元的输入数据的格式为上述计算网络的原始输入数据的格式。With reference to the second aspect, in a possible implementation manner, when the first computing unit is the first computing unit in the computing network, the format of the input data of the first computing unit is the original The format of the input data.

结合第二方面和上述可能的实现方式,在另一种可能的实现方式中,在上述第一计算单元为上述计算网络中位于中间位置的计算单元的情况下,上述第一计算单元的输入数据的格式为上述第一计算单元之前的计算单元的输出数据的格式。With reference to the second aspect and the above possible implementation manner, in another possible implementation manner, when the above-mentioned first computing unit is a computing unit at an intermediate position in the above-mentioned computing network, the input data of the above-mentioned first computing unit The format of is the format of the output data of the calculation units preceding the first calculation unit.

结合第二方面和上述可能的实现方式,在另一种可能的实现方式中,上述处理单元,具体用于若确定上述第二计算单元支持的多个数据格式包括上述第一计算单元的输出数据的格式,确定上述第二计算单元支持上述第一计算单元的输出数据的格式。In combination with the second aspect and the above possible implementation, in another possible implementation, the processing unit is specifically configured to determine that the multiple data formats supported by the second computing unit include the output data of the first computing unit The format of the output data of the first computing unit supported by the second computing unit is determined.

结合第二方面和上述可能的实现方式,在另一种可能的实现方式中,上述获取单元,还用于获取上述第一计算单元和上述第二计算单元的预置模式类型;该预置模式类型包括格式无关类、约减Reduce类和广播Broadcast类;上述处理单元,还用于根据上述第一计算单元和上述第二计算单元的预置模式类型,确定上述第一计算单元和上述第二计算单元支持的数据格式。With reference to the second aspect and the above possible implementation manner, in another possible implementation manner, the acquisition unit is further configured to acquire the preset mode types of the first calculation unit and the second calculation unit; the preset mode The types include format-independent class, reduction class, and broadcast broadcast class; the above-mentioned processing unit is also used to determine the above-mentioned first computing unit and the above-mentioned second computing unit according to the preset mode types of the above-mentioned first computing unit and the above-mentioned second computing unit The data format supported by the computing unit.

结合第二方面和上述可能的实现方式,在另一种可能的实现方式中,上述处理单元,还用于:若确定上述计算网络的最后一个计算单元的输出数据的格式与上述计算网络的原始输出数据的格式不同,在上述计算网络的最后一个计算单元之后添加第二 格式转换单元,该第二格式转换单元用于将上述最后一个计算单元的输出数据的格式转换为上述计算网络的原始输出数据的格式。In combination with the second aspect and the above possible implementation manner, in another possible implementation manner, the above processing unit is further configured to: if it is determined that the output data format of the last computing unit of the above computing network is the same as the original The format of the output data is different, and a second format conversion unit is added after the last calculation unit of the above-mentioned calculation network, and the second format conversion unit is used to convert the format of the output data of the above-mentioned last calculation unit into the original output of the above-mentioned calculation network The format of the data.

本申请实施例的第三方面,提供一种电子设备,该电子设备可以实现第一方面所述的数据格式处理方法,其可以通过软件、硬件、或者通过硬件执行相应的软件实现上述方法。在一种可能的实现方式中,该电子设备可以包括处理器和存储器。该处理器被配置为支持该电子设备执行上述第一方面所述的方法中相应的功能。存储器用于与处理器耦合,其保存该电子设备必要的程序指令和数据。The third aspect of the embodiments of the present application provides an electronic device, which can implement the data format processing method described in the first aspect, and implement the above method through software, hardware, or by executing corresponding software through hardware. In a possible implementation manner, the electronic device may include a processor and a memory. The processor is configured to support the electronic device to execute corresponding functions in the method described in the first aspect above. The memory is used to be coupled with the processor, and it stores necessary program instructions and data of the electronic device.

本申请实施例的第四方面,提供一种计算机可读存储介质,该计算机可读存储介质包括计算机指令,当所述计算机指令在电子设备上运行时,使得电子设备执行如上述第一方面及其可能的实现方式所述的数据格式处理方法。The fourth aspect of the embodiments of the present application provides a computer-readable storage medium, the computer-readable storage medium includes computer instructions, and when the computer instructions are run on the electronic device, the electronic device executes the above-mentioned first aspect and The data format processing method described in its possible implementation manner.

本申请实施例的第五方面,提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如上述第一方面及其可能的实现方式方式所述的数据格式处理方法。In the fifth aspect of the embodiments of the present application, a computer program product is provided. When the computer program product is run on a computer, the computer executes the data format as described in the above first aspect and its possible implementation manners. Approach.

本申请实施例的第六方面,提供一种电子设备,该电子设备包括中央处理器(Central Process Unit,CPU)和神经网络处理器(Neural-network Processing Unit,NPU),所述CPU用于执行如上述第一方面及其可能的实现方式所述的数据格式处理方法,所述NPU用于执行所述CPU基于所述数据格式处理方法得到的计算网络。A sixth aspect of the embodiments of the present application provides an electronic device, the electronic device includes a central processing unit (Central Process Unit, CPU) and a neural network processor (Neural-network Processing Unit, NPU), the CPU is used to execute According to the data format processing method described in the first aspect and possible implementations thereof, the NPU is configured to execute the computing network obtained by the CPU based on the data format processing method.

上述第二方面,第三方面,第四方面,第五方面以及第六方面的效果描述可以参考第一方面的相应效果的描述,在此不再赘述。For the description of the effects of the second aspect, the third aspect, the fourth aspect, the fifth aspect and the sixth aspect, reference may be made to the description of the corresponding effects of the first aspect, which will not be repeated here.

附图说明Description of drawings

图1为本申请实施例提供的一种计算网络的结构示意图;FIG. 1 is a schematic structural diagram of a computing network provided by an embodiment of the present application;

图2为本申请实施例提供的一种数据格式转换处理的示意图;FIG. 2 is a schematic diagram of a data format conversion process provided by an embodiment of the present application;

图3为本申请实施例提供的一种图片的数据组成示意图;Fig. 3 is a schematic diagram of the data composition of a picture provided by the embodiment of the present application;

图4为本申请实施例提供的一种数据格式的示意图;FIG. 4 is a schematic diagram of a data format provided by an embodiment of the present application;

图5为本申请实施例提供的另一种数据格式转换处理的示意图;FIG. 5 is a schematic diagram of another data format conversion process provided by the embodiment of the present application;

图6为本申请实施例提供的一种系统架构的结构示意图;FIG. 6 is a schematic structural diagram of a system architecture provided by an embodiment of the present application;

图7为本申请实施例提供的一种数据格式处理方法的流程示意图;FIG. 7 is a schematic flowchart of a data format processing method provided by an embodiment of the present application;

图8为本申请实施例提供的一种数据格式处理方法的应用示意图;FIG. 8 is an application schematic diagram of a data format processing method provided in the embodiment of the present application;

图9为本申请实施例提供的另一种数据格式处理方法的应用示意图;FIG. 9 is an application schematic diagram of another data format processing method provided by the embodiment of the present application;

图10为本申请实施例提供的一种数据格式处理方法的中间逻辑处理的示意图;FIG. 10 is a schematic diagram of intermediate logic processing of a data format processing method provided by an embodiment of the present application;

图11为本申请实施例提供的一种数据格式处理装置的组成示意图。FIG. 11 is a schematic diagram of a composition of a data format processing device provided by an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。在本申请中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,a和b,a和c,b和c,或,a和b 和c,其中a、b和c可以是单个,也可以是多个。另外,为了便于清楚描述本申请实施例的技术方案,在本申请的实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分,本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定。比如,本申请实施例中的第一计算单元中的“第一”和第二计算单元中的“第二”仅用于区分不同的计算单元。本申请实施例中出现的第一、第二等描述,仅作示意与区分描述对象之用,没有次序之分,也不表示本申请实施例中对设备个数的特别限定,不能构成对本申请实施例的任何限制。The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. In this application, "at least one" means one or more, and "multiple" means two or more. "And/or" describes the association relationship of associated objects, indicating that there may be three types of relationships, for example, A and/or B, which can mean: A exists alone, A and B exist at the same time, and B exists alone, where A, B can be singular or plural. The character "/" generally indicates that the contextual objects are an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one item (piece) of a, b or c can represent: a, b, c, a and b, a and c, b and c, or, a and b and c, wherein a, b and c can be single or multiple. In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with basically the same function and effect, Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order. For example, "first" in the first computing unit and "second" in the second computing unit in the embodiment of the present application are only used to distinguish different computing units. The first, second, etc. descriptions that appear in the embodiments of this application are only for illustration and to distinguish the description objects, and there is no order, nor does it represent a special limitation on the number of devices in the embodiments of this application, and cannot constitute a limitation on the number of devices in this application. Any limitations of the examples.

需要说明的是,本申请中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其他实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。It should be noted that, in this application, words such as "exemplary" or "for example" are used as examples, illustrations or illustrations. Any embodiment or design described herein as "exemplary" or "for example" is not to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete manner.

首先,对本申请涉及的各种数据格式的含义进行解释。First, the meanings of various data formats involved in this application are explained.

1、NCHW1. NCHW

其中,N代表数量batch,C代表通道channel,H代表高度height,W代表宽度width。NCHW格式的排列顺序为[batch,channels,height,width],即表示数据的排列顺序按照W维度、H维度、C维度、N维度依次排列。例如,以输入图片为一张,该图片的数据为图3所示的数据为例,如果使用NCHW格式存储,那么shape为(1,3,10,10)。图4中的(a)为NCHW格式的数据排布方式,如图4中的(a)所示,第一个元素是000,第二个元素是沿着W方向的,即001,这样依次沿W方向直至009,再沿着H方向,即010,011,012...019…090…直到099后,再沿C方向,100,101...109,110,111...119…200,201…直到299。若N为大于1的整数,那么继续沿着N方向依次排列。Among them, N represents the number of batches, C represents the channel channel, H represents the height, and W represents the width. The arrangement order of the NCHW format is [batch, channels, height, width], which means that the arrangement order of the data is in order of W dimension, H dimension, C dimension, and N dimension. For example, taking one input picture and the data of the picture as shown in Figure 3 as an example, if the NCHW format is used to store, then the shape is (1, 3, 10, 10). (a) in Figure 4 is the data arrangement in NCHW format. As shown in (a) in Figure 4, the first element is 000, and the second element is along the W direction, that is, 001, so that Follow the W direction until 009, then follow the H direction, that is, 010, 011, 012...019...090... until 099, then follow the C direction, 100, 101...109, 110, 111...119... 200, 201... until 299. If N is an integer greater than 1, then continue to arrange sequentially along the N direction.

2、NHWC2. NHWC

NHWC的排列顺序为[batch,height,width,channels],即表示数据的排列顺序按照C维度、W维度、H维度、N维度依次排列。例如,以输入图片为一张,该图片的数据为如图3所示的数据为例,如果使用NHWC格式存储,那么shape为(1,10,10,3)。图4中的(b)为NHWC格式的数据排布方式,如图4中的(b)所示,第一个元素是000,第二个元素是沿着C方向的,即100,这样依次沿C方向到200,再沿着W方向,即001,101,201…009…直到209后,沿H方向,010,110,210,011,111,211…直到299。若N为大于1的整数,那么继续沿着N方向依次排列。The arrangement order of NHWC is [batch, height, width, channels], which means that the arrangement order of the data is arranged according to the C dimension, W dimension, H dimension, and N dimension. For example, taking one input picture and the data of the picture as shown in Figure 3 as an example, if the NHWC format is used to store, then the shape is (1, 10, 10, 3). (b) in Figure 4 is the data arrangement in the NHWC format. As shown in (b) in Figure 4, the first element is 000, and the second element is along the C direction, that is, 100, so in turn Follow the C direction to 200, then follow the W direction, that is, 001, 101, 201...009... until 209, and follow the H direction, 010, 110, 210, 011, 111, 211... until 299. If N is an integer greater than 1, then continue to arrange sequentially along the N direction.

3、NC1HWC03. NC1HWC0

NC1HWC0格式是将C轴进行拆分,可以将C轴拆分为C1个C0。在N为1的情况下,数据的排列顺序按照第一个C0的C维度、W维度、H维度、第二C0的C维度、W维度、H维度…直至第C1个C0的C维度、W维度、H维度依次排列。若N为大于1的整数,那么继续沿着N方向依次排列。The NC1HWC0 format is to split the C axis, which can be split into C1 and C0. In the case where N is 1, the data is arranged in the order of the C dimension, W dimension, H dimension of the first C0, the C dimension, W dimension, H dimension of the second C0... until the C dimension, W dimension of the C1th C0 Dimension and H dimension are arranged in sequence. If N is an integer greater than 1, then continue to arrange sequentially along the N direction.

可选的,在使用NC1HWC0格式时,如果C轴的数量不是C0的倍数,需要先将C轴维度使用0值扩充到C0的倍数,再将C轴拆分为C1和C0两个维度,转换成NC1HWC0格式。如果C轴的数量是C0的倍数,则不需要扩充,可以将C轴拆分为C1和C0两个维度。Optionally, when using the NC1HWC0 format, if the number of C-axis is not a multiple of C0, you need to first expand the C-axis dimension to a multiple of C0 with a value of 0, and then split the C-axis into two dimensions, C1 and C0, and convert into NC1HWC0 format. If the number of C axes is a multiple of C0, no expansion is required, and the C axes can be split into two dimensions, C1 and C0.

例如,以输入图片为一张,该图片的数据为如图3所示的数据为例,如果使用NC1HWC0格式存储,那么shape为(1,1,10,10,16),其中C0为16。由于图片的C轴为3,因此需要先将C维度使用0值扩充到16的倍数。再将C维度拆分为C1和C0两个维度,最后做转置成NC1HWC0格式。图4中的(c)为NC1HWC0格式的数据排布方式,如图4中的(c)所示,第一个元素是000,第二个元素是沿着第一个C0的C方向的,即100,这样依次沿C方向到200,0,0,0,0...0,再沿着W方向,即001,101,201,0...0,009,109,209,0...0后,沿H方向,010,110,210,0...0,011,111,211…直到最后一个0。若N为大于1的整数,那么继续沿着N方向依次排列。For example, take the input picture as an example, and the data of the picture is the data shown in Figure 3. If the NC1HWC0 format is used to store, then the shape is (1, 1, 10, 10, 16), where C0 is 16. Since the C axis of the picture is 3, it is necessary to expand the C dimension to a multiple of 16 with a value of 0. Then split the C dimension into two dimensions, C1 and C0, and finally transpose it into NC1HWC0 format. (c) in Figure 4 is the data arrangement in NC1HWC0 format. As shown in (c) in Figure 4, the first element is 000, and the second element is along the C direction of the first C0. That is 100, so follow the C direction to 200, 0, 0, 0, 0...0, and then follow the W direction, that is, 001, 101, 201, 0...0, 009, 109, 209, 0. After ..0, along the H direction, 010, 110, 210, 0...0, 011, 111, 211... until the last 0. If N is an integer greater than 1, then continue to arrange sequentially along the N direction.

需要说明的是,NC1HWC0格式中C0的取值与硬件有关,芯片不同,C0的取值可能不同,本申请实施例对于C0的取值并不限定,本申请实施例及附图中仅以C0为16为例进行说明。It should be noted that the value of C0 in the NC1HWC0 format is related to hardware, and the value of C0 may be different for different chips. The embodiment of this application does not limit the value of C0. In the embodiment of this application and the drawings, only C0 16 is used as an example for illustration.

可选的,NHWC格式可以通过格式转换处理转换为NC1HWC0格式,即将初始的C轴拆分为C1和C0轴,然后再调整轴顺序。比如,初始Shape为(32,114,114,32),调整格式为NC1HWC0之后,shape调整为(32,2,114,114,16)。Optionally, the NHWC format can be converted to the NC1HWC0 format through format conversion processing, that is, the initial C axis is split into C1 and C0 axes, and then the order of the axes is adjusted. For example, the initial shape is (32, 114, 114, 32), and after the format is adjusted to NC1HWC0, the shape is adjusted to (32, 2, 114, 114, 16).

可选的,NCHW格式可以通过格式转换处理转换为NC1HWC0格式,即将初始的C轴拆分为C1和C0轴,然后再调整轴顺序。比如,初始Shape为(32,32,114,114),调整为NC1HWC0之后,shape调整为(32,2,114,114,16)。Optionally, the NCHW format can be converted to the NC1HWC0 format through format conversion processing, that is, the initial C axis is split into C1 and C0 axes, and then the order of the axes is adjusted. For example, the initial shape is (32, 32, 114, 114), after being adjusted to NC1HWC0, the shape is adjusted to (32, 2, 114, 114, 16).

在AI芯片中,通常要求数据按照特定的格式进行排布,由于不同的运算要求的数据格式不同,因此可能需要对不同格式的数据进行转换。In AI chips, data is usually required to be arranged in a specific format. Since different operations require different data formats, it may be necessary to convert data in different formats.

例如,如图1所示的计算网络,该计算网络中的算子序列依次包括Conv1算子、Relu1算子、Conv2算子和Relu2算子,其中,Conv算子要求输入数据的格式按照NC1HWC0格式排布,Relu算子要求输入数据的格式按照ND格式排布。由于原始图片的数据格式为NHWC格式,与Conv1算子要求的输入数据的格式不同,因此需要对输入数据的格式进行转换。需要说明的是,ND表示按照原始格式进行运算。可选的,该原始格式可以为NHWC或者NCHW。即ND格式可以为NHWC格式,也可以为NCHW格式。For example, in the computing network shown in Figure 1, the sequence of operators in the computing network includes Conv1 operator, Relu1 operator, Conv2 operator, and Relu2 operator in turn, where the Conv operator requires the format of input data to follow the NC1HWC0 format Arrangement, the Relu operator requires the format of the input data to be arranged in the ND format. Since the data format of the original image is NHWC format, which is different from the format of the input data required by the Conv1 operator, the format of the input data needs to be converted. It should be noted that ND indicates that operations are performed in the original format. Optionally, the original format may be NHWC or NCHW. That is, the ND format can be NHWC format or NCHW format.

例如,如图2所示的一种数据格式转换处理的示意图,通过在卷积Conv算子内的开始位置和结束位置分别增加格式转换处理逻辑,Conv算子内的开始位置增加的格式转换处理逻辑可以将输入数据的格式由NHWC格式转换为NC1HWC0格式,Conv算子内的结束位置增加的格式转换处理逻辑可以将输出数据的格式由NC1HWC0格式转换为NHWC格式。但是,该方法在算子内部增加格式转换处理逻辑后,增加了算子的耗时,降低了算子的性能。如果网络中存在多个Conv算子,每个Conv算子内部都存在转换逻辑,网络性能开销很大。For example, as shown in Figure 2, a schematic diagram of data format conversion processing, by adding format conversion processing logic at the start position and end position of the convolution Conv operator, the format conversion process of increasing the start position in the Conv operator The logic can convert the format of the input data from the NHWC format to the NC1HWC0 format, and the format conversion processing logic added to the end position in the Conv operator can convert the format of the output data from the NC1HWC0 format to the NHWC format. However, this method increases the time consumption of the operator and reduces the performance of the operator after the format conversion processing logic is added inside the operator. If there are multiple Conv operators in the network, each Conv operator has conversion logic inside, and the network performance overhead is very high.

再例如,如图5所示的另一种数据格式转换处理的示意图,通过在每个Conv算子的前后分别插入格式转换算子(例如,TransData),使得Conv算子之前插入的格式转换算子可以将原始输入数据的格式由NHWC格式转换为NC1HWC0格式,Conv算子之后插入的格式转换算子可以将Conv算子的输出数据的格式由NC1HWC0格式转换为NHWC格式。但是,该方法插入的格式转换算子会带来额外的性能开销,如果 在一个有20层该小网络结构的大网络中,格式转换算子的数量会翻20倍,性能开销很大,降低了网络性能。For another example, as shown in Figure 5, another schematic diagram of data format conversion processing, by inserting a format conversion operator (for example, TransData) before and after each Conv operator, the format conversion operator inserted before the Conv operator The operator can convert the format of the original input data from NHWC format to NC1HWC0 format, and the format conversion operator inserted after the Conv operator can convert the format of the output data of the Conv operator from NC1HWC0 format to NHWC format. However, the format conversion operators inserted by this method will bring additional performance overhead. If in a large network with 20 layers of this small network structure, the number of format conversion operators will increase by 20 times, and the performance overhead will be large, reducing network performance.

可以理解的,图2所示的数据格式转换处理方法和图5所示的数据格式转换处理方法的区别在于,图2所示的方法是在算子内部进行格式转换,而图5所示的方法是在算子外进行格式转换,这两种数据格式转换处理方法在进行格式转换处理的时候都存在网络性能开销较大的问题。It can be understood that the difference between the data format conversion processing method shown in Figure 2 and the data format conversion processing method shown in Figure 5 is that the method shown in Figure 2 performs format conversion inside the operator, while the method shown in Figure 5 The method is to perform format conversion outside the operator. Both of these two data format conversion processing methods have the problem of large network performance overhead when performing format conversion processing.

为了缓解因格式转换处理过多,造成网络性能开销较大的问题,本申请实施例提供一种数据格式处理方法,该方法能够减少格式转换处理,提升网络性能。In order to alleviate the problem of high network performance overhead due to excessive format conversion processing, the embodiment of the present application provides a data format processing method, which can reduce format conversion processing and improve network performance.

示例性的,本申请实施例提供的数据格式处理方法可以应用于图6所示的系统架构。如图6所示,该系统架构包括图引擎(Graph Engine,GE)、融合引擎(Fusion Engine,FE)和算子库(Operator,Op)。Exemplarily, the data format processing method provided in the embodiment of the present application may be applied to the system architecture shown in FIG. 6 . As shown in Figure 6, the system architecture includes a graph engine (Graph Engine, GE), a fusion engine (Fusion Engine, FE) and an operator library (Operator, Op).

其中,GE、FE调用Op中的算子。Op提供有算子原型库、算子信息库、算子实现库。算子原型库提供算子的定义,例如算子有哪些输入、输出以及属性等信息。算子信息库提供算子实现的能力,例如算子支持的数据类型以及支持的输入数据格式(format)和输出数据格式等。算子实现库提供算子的实现,FE通过调用算子实现库,进行算子编译生成算子。Among them, GE and FE call the operator in Op. Op provides operator prototype library, operator information library, and operator implementation library. The operator prototype library provides the definition of the operator, such as the input, output, and attributes of the operator. The operator information library provides the capabilities implemented by the operator, such as the data types supported by the operator, and the supported input data format (format) and output data format. The operator implementation library provides operator implementation, and FE compiles and generates operators by calling the operator implementation library.

FE用于处理与硬件相关的图优化。FE包括Op判断模块(Op Judge)、格式选择模块(Format Selector)和算子信息库加载模块(Op Store)。其中,FE中的Op判断模块负责调整算子,使得算子适配硬件,可以良好的运行在相应的芯片上。例如,当初始数据格式和算子支持的数据格式不同时,FE中的Op判断模块可以对初始数据格式进行格式转换处理,使得转换后的数据格式为算子支持的数据格式。算子信息库加载模块在初始化时加载算子信息库,得到每个算子的能力,以及支持的数据格式。格式选择模块(Format Selector)负责在某个算子支持多个数据格式时,选择采用多个数据格式中的哪个数据格式。例如,格式选择模块可以在算子支持多个数据格式时,选择多个数据格式中与该算子的前一算子的输出数据的格式相同的数据格式,以保持数据格式的连续性。FE is used to handle hardware-related graph optimizations. FE includes an Op Judge module (Op Judge), a format selection module (Format Selector) and an operator information library loading module (Op Store). Among them, the Op judgment module in FE is responsible for adjusting the operator, so that the operator is adapted to the hardware and can run well on the corresponding chip. For example, when the initial data format is different from the data format supported by the operator, the Op judgment module in FE can perform format conversion processing on the initial data format, so that the converted data format is the data format supported by the operator. The operator information library loading module loads the operator information library during initialization to obtain the capabilities and supported data formats of each operator. The format selector module (Format Selector) is responsible for selecting which data format among multiple data formats to adopt when an operator supports multiple data formats. For example, when an operator supports multiple data formats, the format selection module may select the same data format as the output data format of the previous operator of the operator among the multiple data formats, so as to maintain the continuity of the data format.

GE初始化时加载算子原型库,FE初始化时加载算子信息库。GE调用算子原型库中的推导逻辑,进行推导得到网络图中的每个算子节点的初始shape和初始数据格式,GE调用FE对网络图(graph)进行硬件相关的优化。The operator prototype library is loaded when GE is initialized, and the operator information library is loaded when FE is initialized. GE calls the derivation logic in the operator prototype library to derive the initial shape and initial data format of each operator node in the network graph, and GE calls FE to optimize the network graph (graph) related to hardware.

示例性的,上述算子信息库可以通过两种方式提供算子支持的数据格式。第一种方式是将算子归类,通过op.pattern配置算子所属的预置模式类型,不同预置模式类型支持的数据格式可以不同。第二种是通过input0.format配置算子支持的输入数据格式。Exemplarily, the above-mentioned operator information base can provide the data format supported by the operator in two ways. The first way is to classify operators, and configure the preset pattern type that the operator belongs to through op.pattern. The data formats supported by different preset pattern types can be different. The second is to configure the input data format supported by the operator through input0.format.

可选的,算子的预置模式类型可以包括:格式无关类、约减Reduce类和广播Broadcast类。Optionally, the preset mode types of the operator may include: format-independent type, reduction type and broadcast type.

其中,格式无关类可以支持任意数据格式,适用调整单输入单输出的纯ElementWise类算子,例如,格式无关类的算子可以包括Sqrt算子、Square算子、Sin算子、Neg算子等算子。格式无关类的算子支持任意格式间的调整。例如,格式无关类算子支持的格式包括NCHW、NHWC、NC1HWC0、FRACTAL_Z、FRACTAL_Z_3D、FRACTAL_NZ、C1HWNCoC0等格式。本申请实施例对于格式无关类算子支持的数据 格式类型并不限定,在此仅是示例性说明。Among them, the format-independent class can support any data format, and is suitable for adjusting pure ElementWise operators with single input and single output. For example, operators of the format-independent class can include Sqrt operator, Square operator, Sin operator, Neg operator, etc. operator. Operators of the format-independent class support adjustment between arbitrary formats. For example, the formats supported by format-independent operators include NCHW, NHWC, NC1HWC0, FRACTAL_Z, FRACTAL_Z_3D, FRACTAL_NZ, C1HWNCoC0 and other formats. The embodiment of the present application does not limit the type of data format supported by the format-independent operator, and this is only an example.

Reduce类算子支持的数据格式与约束条件有关。Reduce类算子可以包括ReduceSum、ReduceMax、ReduceMin等算子。例如,对于Reduce类算子,在Reduce轴包含C轴的场景,支持输入数据格式NC1HWC0,输出数据格式ND。在Reduce轴不包含C轴的场景,支持输入数据格式NC1HWC0,输出数据格式NC1HWC0。Reduce类算子无论什么场景都支持输入数据的格式为ND,输出数据的格式也为ND。The data formats supported by Reduce operators are related to constraints. Reduce operators can include operators such as ReduceSum, ReduceMax, and ReduceMin. For example, for a Reduce operator, in the scene where the Reduce axis includes the C axis, the input data format is NC1HWC0, and the output data format is ND. In the scenario where the reduce axis does not include the C axis, the input data format NC1HWC0 and the output data format NC1HWC0 are supported. Reduce operators support input data in ND format and output data in ND format in any scenario.

例如,输入的初始Shape为(32,32,114,114),初始格式为NCHW,初始的Reduce轴属性为[1,],调整格式后,输入的格式为NC1HWC0格式,调整后Shape为(32,2,114,114,16),调整后的Reduce轴属性为[1,4]。For example, the input initial Shape is (32, 32, 114, 114), the initial format is NCHW, and the initial Reduce axis attribute is [1,], after the format is adjusted, the input format is NC1HWC0 format, and the adjusted Shape is (32 , 2, 114, 114, 16), the adjusted Reduce axis attribute is [1, 4].

Broadcast类算子支持的数据格式与约束条件有关。Broadcast类算子包括Add,RealDiv,Minimum等算子。例如,对于Broadcast类算子,在Broadcast的轴不包含C的场景,支持输入数据格式为NC1HWC0,输出数据格式也为NC1HWC0。如果Broadcat的轴包含C轴的场景,Broadcast类算子支持的输入数据格式为ND,输出数据格式也为ND。The data formats supported by Broadcast operators are related to constraints. Broadcast operators include operators such as Add, RealDiv, and Minimum. For example, for a Broadcast operator, if the Broadcast axis does not contain C, the supported input data format is NC1HWC0, and the output data format is also NC1HWC0. If the axis of Broadcast includes the scene of C axis, the input data format supported by the Broadcast class operator is ND, and the output data format is also ND.

可选的,算子信息库通过op.pattern配置算子所属的预置模式类型时,具体的配置方式如下:Optionally, when the operator information base configures the preset pattern type of the operator through op.pattern, the specific configuration method is as follows:

[Square][Square]

input0.name=xinput0.name=x

input0.dtype=float16,float,int32input0.dtype=float16, float, int32

output0.name=youtput0.name=y

output0.dtype=float16,float,int32output0.dtype = float16, float, int32

op.pattern=formatAgnosticop.pattern=formatAgnostic

可选的,算子信息库通过input0.format配置算子支持的数据格式时,具体的配置方式如下:Optionally, when the operator information base configures the data format supported by the operator through input0.format, the specific configuration method is as follows:

[Square][Square]

input0.name=xinput0.name=x

input0.dtype=float16,float,int32input0.dtype=float16, float, int32

input0.format=ND,NC1HWC0input0.format=ND,NC1HWC0

output0.name=youtput0.name=y

output0.dtype=float16,float,int32output0.dtype = float16, float, int32

output0.format=ND,NC1HWC0output0.format=ND,NC1HWC0

可选的,当算子不属于预置的任一种模式类型时,可以通过input0.format配置算子支持的数据格式。但是,当该算子支持多个数据格式时,对于算子支持的每个数据格式均需要通过input0.format配置。Optionally, when the operator does not belong to any of the preset mode types, the data format supported by the operator can be configured through input0.format. However, when the operator supports multiple data formats, each data format supported by the operator needs to be configured through input0.format.

可以理解的,算子信息库通过将算子归类,采用op.pattern配置算子的预置模式类型,根据该预置模式类型可以确定算子支持的数据格式,该配置方法相较于通过input0.format配置算子支持的数据格式,可以大大的减少算子信息库中的信息量,不需要对算子支持的每种格式都进行配置。而且通过算子信息库配置算子的预置模式类型,能够使得算子实现不用关注具体的格式,直接按照算子的输入shape和属性进行 运算即可,减少了算子开发中格式处理的负担。Understandably, the operator information base classifies operators and uses op.pattern to configure the preset pattern type of the operator. According to the preset pattern type, the data format supported by the operator can be determined. This configuration method is compared with the input0.format configures the data format supported by the operator, which can greatly reduce the amount of information in the operator information database, and does not need to configure each format supported by the operator. Moreover, configuring the preset mode type of the operator through the operator information library can enable the implementation of the operator without paying attention to the specific format, and can directly perform operations according to the input shape and attributes of the operator, reducing the burden of format processing in operator development. .

本申请实施例提供一种数据格式处理方法,该方法应用于一种计算网络,该计算网络中依次包括第一计算单元和第二计算单元,如图7所示,该数据格式处理方法可以包括以下步骤:An embodiment of the present application provides a data format processing method, the method is applied to a computing network, the computing network includes a first computing unit and a second computing unit in sequence, as shown in Figure 7, the data format processing method may include The following steps:

S701、获取第一计算单元和第二计算单元支持的数据格式。S701. Acquire data formats supported by the first computing unit and the second computing unit.

可以理解的,上述步骤S701中可以由处理器调用算子信息库加载模块的接口获取第一计算单元和第二计算单元支持的数据格式。It can be understood that in step S701 above, the processor may call the interface of the operator information library loading module to obtain the data formats supported by the first computing unit and the second computing unit.

可选的,本申请实施例中的第一计算单元和第二计算单元可以为同一类型的算子,也可以为不同类型的算子,本申请实施例并不限定第一计算单元和第二计算单元的具体算子类型。Optionally, the first calculation unit and the second calculation unit in this embodiment of the application may be operators of the same type, or operators of different types. This embodiment of the application does not limit the first calculation unit and the second calculation unit. The specific operator type of the computing unit.

示例性的,本申请实施例提供的数据格式处理方法可以应用于图1所示的计算网络,该计算网络中的算子序列依次包括Conv1算子、Relu1算子、Conv2算子、和Relu2算子。本申请实施例对于计算网络中算子序列的具体结构不进行限定,在此仅以算子序列为图1所示的算子序列为例进行说明。Exemplarily, the data format processing method provided by the embodiment of the present application can be applied to the computing network shown in FIG. son. The embodiment of the present application does not limit the specific structure of the operator sequence in the computing network, and only the operator sequence shown in FIG. 1 is taken as an example for illustration.

可选的,上述第一计算单元可以为计算网络中的首个计算单元,也可以为计算网络中位于中间位置的计算单元。例如,当第一计算单元为计算网络中的首个计算单元时,第一计算单元可以为图1中的Conv1算子,第二计算单元可以为图1中的Relu1算子,该Conv1算子的输入数据为计算网络的原始输入数据。再例如,当第一计算单元为计算网络中位于中间位置的计算单元时,第一计算单元可以为图1中的Conv2算子,第二计算单元可以为图1中的Relu2算子,该Conv2算子的输入数据为Relu1算子的输出数据。可以理解的,本申请实施例对于第一计算单元在计算网络中的具体位置并不限定,该第一计算单元为第二计算单元之前的计算单元。Optionally, the above-mentioned first computing unit may be the first computing unit in the computing network, or may be a computing unit in an intermediate position in the computing network. For example, when the first computing unit is the first computing unit in the computing network, the first computing unit can be the Conv1 operator in Figure 1, and the second computing unit can be the Relu1 operator in Figure 1, the Conv1 operator The input data of is the original input data of the computing network. For another example, when the first computing unit is a computing unit in the middle of the computing network, the first computing unit can be the Conv2 operator in Figure 1, and the second computing unit can be the Relu2 operator in Figure 1, the Conv2 The input data of the operator is the output data of the Relu1 operator. It can be understood that the embodiment of the present application does not limit the specific position of the first computing unit in the computing network, and the first computing unit is a computing unit before the second computing unit.

示例性的,上述步骤S701中获取第一计算单元和第二计算单元支持的数据格式,可以包括:获取第一计算单元和第二计算单元的预置模式类型;根据第一计算单元和第二计算单元的预置模式类型,确定第一计算单元和第二计算单元支持的数据格式。该预置模式类型可以包括格式无关类、约减Reduce类和广播Broadcast类。可选的,FE可以从算子信息库获取第一计算单元和第二计算单元的预置模式类型。可选的,FE获取第一计算单元和第二计算单元支持的数据格式时,可以根据预置模式类型,以及具体的约束条件,确定第一计算单元和第二计算单元支持的数据格式。Exemplarily, obtaining the data formats supported by the first computing unit and the second computing unit in the above step S701 may include: obtaining the preset mode types of the first computing unit and the second computing unit; The preset mode type of the computing unit determines the data format supported by the first computing unit and the second computing unit. The preset mode types may include format-independent class, reduce-reduce class and broadcast-broadcast class. Optionally, the FE may acquire the preset mode types of the first computing unit and the second computing unit from the operator information library. Optionally, when the FE acquires the data formats supported by the first computing unit and the second computing unit, it may determine the data formats supported by the first computing unit and the second computing unit according to the preset mode type and specific constraints.

可以理解的,通过算子信息库配置算子的预置模式类型,能够使得算子实现不用关注具体的格式,直接按照算子的输入shape和属性进行运算即可,减少了算子开发中格式处理的负担。It is understandable that configuring the preset mode type of an operator through the operator information base can make the implementation of the operator do not need to pay attention to the specific format, and can directly perform operations according to the input shape and attributes of the operator, reducing the format of the operator development processing burden.

可选的,当算子信息库中第一计算单元是通过input0.format配置该算子支持的数据格式时,FE可以从算子信息库中直接获取到第一计算单元支持的数据格式。Optionally, when the first calculation unit in the operator information base configures the data format supported by the operator through input0.format, the FE can directly obtain the data format supported by the first calculation unit from the operator information base.

可选的,本申请实施例中计算单元支持的数据格式可以为计算单元支持的输入数据的格式。Optionally, the data format supported by the computing unit in this embodiment of the present application may be the input data format supported by the computing unit.

S702、若确定第一计算单元不支持第一计算单元的输入数据的格式,在第一计算单元之前添加第一格式转换单元。S702. If it is determined that the first computing unit does not support the format of the input data of the first computing unit, add a first format converting unit before the first computing unit.

可以理解的,上述步骤S702可以由处理器确定第一计算单元是否支持第一计算单 元的输入数据的格式,并在处理器确定第一计算单元不支持第一计算单元的输入数据的格式时,在第一计算单元之前添加第一格式转换单元。可选的,若处理器确定第一计算单元支持第一计算单元的输入数据的格式,处理器确定在第一计算单元之前不进行格式转换处理。It can be understood that in the above step S702, the processor may determine whether the first computing unit supports the format of the input data of the first computing unit, and when the processor determines that the first computing unit does not support the format of the input data of the first computing unit, A first format conversion unit is added before the first calculation unit. Optionally, if the processor determines that the first computing unit supports the format of the input data of the first computing unit, the processor determines not to perform format conversion processing before the first computing unit.

第一格式转换单元用于将第一计算单元的输入数据的格式转换为第一计算单元支持的数据格式。The first format converting unit is used for converting the format of the input data of the first computing unit into a data format supported by the first computing unit.

示例性的,在第一计算单元支持一个数据格式的情况下,若第一计算单元支持的数据格式与第一计算单元的输入数据的格式不同,处理器确定第一计算单元不支持第一计算单元的输入数据的格式。Exemplarily, in the case that the first calculation unit supports a data format, if the data format supported by the first calculation unit is different from the format of the input data of the first calculation unit, the processor determines that the first calculation unit does not support the first calculation The format of the cell's input data.

示例性的,在第一计算单元支持多个数据格式的情况下,若第一计算单元支持的多个数据格式不包括第一计算单元的输入数据的格式,处理器确定第一计算单元不支持第一计算单元的输入数据的格式。Exemplarily, in the case that the first computing unit supports multiple data formats, if the multiple data formats supported by the first computing unit do not include the format of the input data of the first computing unit, the processor determines that the first computing unit does not support The format of the input data for the first computing unit.

在第一计算单元不支持第一计算单元的输入数据的格式的情况下,通过在第一计算单元之前添加第一格式转换单元,能够将第一计算单元的输入数据的格式转换为第一计算单元支持的数据格式。In the case that the first calculation unit does not support the format of the input data of the first calculation unit, by adding the first format conversion unit before the first calculation unit, the format of the input data of the first calculation unit can be converted into the first calculation unit The data formats supported by the cell.

一种实现方式中,若第一计算单元为计算网络中的首个计算单元,那么上述第一计算单元的输入数据为计算网络的原始输入数据。即第一计算单元的输入数据的格式为计算网络的原始输入数据的格式。In an implementation manner, if the first computing unit is the first computing unit in the computing network, then the input data of the first computing unit is the original input data of the computing network. That is, the format of the input data of the first computing unit is the format of the original input data of the computing network.

可选的,上述计算网络的原始输入数据可以是网络最开始的输入数据。例如,计算网络的原始输入数据可以为真实的图片数据、语音数据或文本数据等。Optionally, the original input data of the above computing network may be the initial input data of the network. For example, the original input data of the computing network may be real picture data, voice data or text data.

示例性的,当第一计算单元支持一个数据格式,且该第一计算单元支持的数据格式和计算网络的原始输入数据的格式不同时,处理器确定第一计算单元不支持计算网络的原始输入数据的格式。当第一计算单元支持多个数据格式,且该第一计算单元支持的多个数据格式不包括计算网络的原始输入数据的格式时,处理器确定第一计算单元不支持计算网络的原始输入数据的格式。Exemplarily, when the first computing unit supports a data format, and the data format supported by the first computing unit is different from the original input data format of the computing network, the processor determines that the first computing unit does not support the original input data of the computing network The format of the data. When the first computing unit supports multiple data formats, and the multiple data formats supported by the first computing unit do not include the format of the original input data of the computing network, the processor determines that the first computing unit does not support the original input data of the computing network format.

若处理器确定第一计算单元不支持计算网络的原始输入数据的格式,处理器在第一计算单元之前添加第一格式转换单元,以将计算网络的原始输入数据的格式转换为第一计算单元支持的数据格式。If the processor determines that the first computing unit does not support the format of the original input data of the computing network, the processor adds a first format conversion unit before the first computing unit to convert the format of the original input data of the computing network into the first computing unit Supported data formats.

例如,如图8所示,以第一计算单元为Conv1算子,第二计算单元为Relu1算子,计算网络的原始输入数据的格式为NHWC为例,由于Conv算子支持的数据格式为NC1HWC0,即Conv1算子支持的数据格式与原始输入数据的格式NHWC不同(Conv1算子不支持原始输入数据的格式),因此在Conv1算子之前插入格式转换算子,该格式转换算子用于将原始输入数据的格式NHWC转换为Conv1算子支持的数据格式NC1HWC0。For example, as shown in Figure 8, taking the first computing unit as the Conv1 operator, the second computing unit as the Relu1 operator, and the format of the original input data of the computing network as NHWC as an example, since the data format supported by the Conv operator is NC1HWC0 , that is, the data format supported by the Conv1 operator is different from the format NHWC of the original input data (the Conv1 operator does not support the format of the original input data), so a format conversion operator is inserted before the Conv1 operator, which is used to convert The original input data format NHWC is converted to the data format NC1HWC0 supported by the Conv1 operator.

另一种实现方式中,若第一计算单元为计算网络中位于中间位置的计算单元,那么上述第一计算单元的输入数据为第一计算单元之前的计算单元的输出数据。即第一计算单元的输入数据的格式为第一计算单元之前的计算单元的输出数据的格式。In another implementation manner, if the first computing unit is a computing unit located in the middle of the computing network, then the input data of the first computing unit is the output data of the computing unit before the first computing unit. That is, the format of the input data of the first computing unit is the format of the output data of the computing units before the first computing unit.

示例性的,以计算网络中的算子序列依次包括第三计算单元、第一计算单元和第二计算单元为例,即第一计算单元之前的计算单元为第三计算单元。当第一计算单元 支持一个数据格式,且该第一计算单元支持的数据格式和第三计算单元的输出数据的格式不同时,处理器确定第一计算单元不支持第三计算单元的输出数据的格式。当第一计算单元支持多个数据格式,且该第一计算单元支持的多个数据格式不包括第三计算单元的输出数据的格式时,处理器确定第一计算单元不支持第三计算单元的输出数据的格式。Exemplarily, it is taken as an example that the sequence of operators in the computing network includes a third computing unit, a first computing unit, and a second computing unit in sequence, that is, the computing unit before the first computing unit is the third computing unit. When the first computing unit supports a data format, and the data format supported by the first computing unit is different from the output data format of the third computing unit, the processor determines that the first computing unit does not support the output data format of the third computing unit Format. When the first computing unit supports multiple data formats, and the multiple data formats supported by the first computing unit do not include the format of the output data of the third computing unit, the processor determines that the first computing unit does not support the format of the third computing unit The format of the output data.

若处理器确定第一计算单元不支持第三计算单元的输出数据的格式,处理器在第三计算单元和第一计算单元之间添加第一格式转换单元,以将第三计算单元的输出数据的格式转换为第一计算单元支持的数据格式。If the processor determines that the first computing unit does not support the format of the output data of the third computing unit, the processor adds a first format conversion unit between the third computing unit and the first computing unit, so that the output data of the third computing unit The format is converted into a data format supported by the first calculation unit.

S703、若确定第二计算单元支持第一计算单元的输出数据的格式,确定不在第一计算单元和第二计算单元之间进行格式转换处理。S703. If it is determined that the second computing unit supports the output data format of the first computing unit, determine not to perform format conversion processing between the first computing unit and the second computing unit.

可以理解的,上述步骤S703可以由处理器确定第二计算单元是否支持第一计算单元的输出数据的格式,并在处理器确定第二计算单元支持第一计算单元的输出数据的格式时,处理器确定不在第一计算单元和第二计算单元之间进行格式转换处理。可选的,若处理器确定第二计算单元不支持第一计算单元的输出数据的格式时,处理器在第一计算单元和第二计算单元之间添加格式转换处理单元,以将第一计算单元的输出数据的格式转换为第二计算单元支持的数据格式。It can be understood that in the above step S703, the processor may determine whether the second computing unit supports the format of the output data of the first computing unit, and when the processor determines that the second computing unit supports the format of the output data of the first computing unit, process The processor determines not to perform format conversion processing between the first computing unit and the second computing unit. Optionally, if the processor determines that the second computing unit does not support the format of the output data of the first computing unit, the processor adds a format conversion processing unit between the first computing unit and the second computing unit, so that the first computing unit The format of the output data of the unit is converted into a data format supported by the second computing unit.

示例性的,在第二计算单元支持一个数据格式的情况下,若第二计算单元支持的数据格式与第一计算单元的输出数据的格式相同,处理器确定第二计算单元支持第一计算单元的输出数据的格式。Exemplarily, in the case that the second computing unit supports a data format, if the data format supported by the second computing unit is the same as the output data format of the first computing unit, the processor determines that the second computing unit supports the first computing unit The format of the output data.

示例性的,在第二计算单元支持多个数据格式的情况下,若第二计算单元支持的多个数据格式包括第一计算单元的输出数据的格式,处理器确定第二计算单元支持第一计算单元的输出数据的格式。Exemplarily, in the case that the second computing unit supports multiple data formats, if the multiple data formats supported by the second computing unit include the output data format of the first computing unit, the processor determines that the second computing unit supports the first The format of the output data of the compute unit.

在第二计算单元支持第一计算单元的输出数据的格式的情况下,处理器确定不在第一计算单元和第二计算单元之间进行格式转换处理。可以理解的,在第二计算单元支持第一计算单元的输出数据的格式的情况下,第二计算单元可以直接将第一计算单元的输出数据作为该第二计算单元的输入数据,并对其进行处理,不需要再对第一计算单元的输出数据进行格式转换处理,从而能够减少计算网络中的格式处理,提升网络性能。也就是说,本申请实施例在考虑是否进行数据格式转换处理时,考虑了多个算子之间支持的数据格式的连续性,从而能够在后一个算子支持前一个算子的输出数据的格式时,确定不在这两个算子之间进行格式转换处理,从而减少了计算网络中格式处理的数量,提升了网络性能。In case the second computing unit supports the format of the output data of the first computing unit, the processor determines not to perform format conversion processing between the first computing unit and the second computing unit. It can be understood that, in the case that the second computing unit supports the format of the output data of the first computing unit, the second computing unit may directly use the output data of the first computing unit as the input data of the second computing unit, and For processing, it is not necessary to perform format conversion processing on the output data of the first computing unit, thereby reducing format processing in the computing network and improving network performance. That is to say, in the embodiment of the present application, when considering whether to perform data format conversion processing, the continuity of the data formats supported by multiple operators is considered, so that the latter operator can support the output data of the previous operator. format, it is determined not to perform format conversion processing between these two operators, thereby reducing the number of format processing in the computing network and improving network performance.

例如,如图8所示,以第一计算单元为Conv1算子,第二计算单元为Relu1算子为例,若Relu算子在算子信息库中配置的模式类型为格式无关类(比如,op.pattern=formatAgnostic),处理器确定Relu1算子支持任意数据格式,即Relu1算子支持Conv1算子的输出数据的格式,那么处理器确定不在Conv1算子和Relu1算子之间进行格式转换处理,即不在Conv1算子和Relu1算子之间插入格式转换算子。For example, as shown in Figure 8, taking the first computing unit as the Conv1 operator and the second computing unit as the Relu1 operator as an example, if the mode type of the Relu operator configured in the operator information base is a format-independent class (for example, op.pattern=formatAgnostic), the processor determines that the Relu1 operator supports any data format, that is, the Relu1 operator supports the output data format of the Conv1 operator, then the processor determines not to perform format conversion between the Conv1 operator and the Relu1 operator , that is, the format conversion operator is not inserted between the Conv1 operator and the Relu1 operator.

再例如,如图8所示,以第一计算单元为Relu1算子,第二计算单元为Conv2算子为例,由于Conv算子支持的数据格式为NC1HWC0,Relu1算子的输出数据的格式也为NC1HWC0,处理器确定Conv2算子支持Relu1算子的输出数据的格式,那么处 理器确定不在Relu1算子和Conv2算子之间进行格式转换处理,即不在Relu1算子和Conv2算子之间插入格式转换算子。For another example, as shown in Figure 8, taking the first computing unit as the Relu1 operator and the second computing unit as the Conv2 operator as an example, since the data format supported by the Conv operator is NC1HWC0, the format of the output data of the Relu1 operator is also For NC1HWC0, the processor determines that the Conv2 operator supports the format of the output data of the Relu1 operator, then the processor determines not to perform format conversion between the Relu1 operator and the Conv2 operator, that is, not to insert between the Relu1 operator and the Conv2 operator Format conversion operator.

再例如,如图8所示,以第一计算单元为Conv2算子,第二计算单元为Relu2算子为例,若Relu算子在算子信息库中配置的模式类型为格式无关类(比如,op.pattern=formatAgnostic),处理器确定Relu2算子支持任意数据格式,即Relu2算子支持Conv2算子的输出数据的格式,那么处理器确定不在Conv2算子和Relu2算子之间进行格式转换处理,即不在Conv2算子和Relu2算子之间插入格式转换算子。For another example, as shown in Figure 8, taking the first computing unit as the Conv2 operator and the second computing unit as the Relu2 operator as an example, if the mode type of the Relu operator configured in the operator information base is a format-independent class (such as , op.pattern=formatAgnostic), the processor determines that the Relu2 operator supports any data format, that is, the Relu2 operator supports the output data format of the Conv2 operator, then the processor determines not to perform format conversion between the Conv2 operator and the Relu2 operator Processing, that is, do not insert a format conversion operator between the Conv2 operator and the Relu2 operator.

根据本申请实施例的方案,对于连续的两个算子,如果后一个算子支持前一个算子的输出数据的格式,那么处理器确定不在这两个算子之间进行格式转换处理,如果后一个算子不支持前一个算子的输出数据的格式,那么处理器确定在这两个算子之间进行格式转换处理(即在这两个算子之间插入格式转换算子),从而将前一个算子的输出数据的格式转换为后一个算子支持的数据格式。According to the solution of the embodiment of this application, for two consecutive operators, if the latter operator supports the format of the output data of the previous operator, then the processor determines not to perform format conversion between the two operators, if If the latter operator does not support the format of the output data of the former operator, then the processor determines to perform format conversion processing between these two operators (that is, insert a format conversion operator between these two operators), so that Convert the output data format of the previous operator to the data format supported by the latter operator.

可以理解的,本申请实施例提供的数据格式处理方法,通过在第一计算单元不支持第一计算单元的输入数据的格式时,在第一计算单元之前添加第一格式转换单元,在第二计算单元支持第一计算单元的输出数据的格式时,不在第一计算单元和第二计算单元之间进行格式转换处理,因此,减少了网络中格式转换单元的数量,减少了网络中的格式处理,提升了网络性能。It can be understood that in the data format processing method provided by the embodiment of the present application, when the first computing unit does not support the format of the input data of the first computing unit, the first format conversion unit is added before the first computing unit, and the second When the computing unit supports the format of the output data of the first computing unit, format conversion processing is not performed between the first computing unit and the second computing unit, thus reducing the number of format conversion units in the network and reducing the format processing in the network , which improves network performance.

需要说明的是,本申请实施例在进行格式处理时,当第二个算子不支持第一个算子的输出数据的格式时,在第一个算子和第二个算子之间插入数据转换单元,当第三个算子支持第二个算子的输出数据的格式时,不会在第二个算子和第三个算子之间再插入数据转换单元,当第四个算子支持第三个算子的输出数据的格式时,也不会在第三个算子和第四个算子之间再插入数据转换单元,直至第N个算子不支持第N-1个算子的输出数据的格式时,才会在第N-1个算子和第N个算子之间插入数据转换单元,因此本申请考虑了多个算子支持的数据格式的连续性,与现有技术相比,能够大大减少格式转换处理,提升网络性能。It should be noted that, in the embodiment of the present application, when performing format processing, when the second operator does not support the format of the output data of the first operator, insert between the first operator and the second operator Data conversion unit, when the third operator supports the output data format of the second operator, no data conversion unit will be inserted between the second operator and the third operator, when the fourth operator When a child supports the format of the output data of the third operator, no data conversion unit will be inserted between the third operator and the fourth operator until the Nth operator does not support the N-1th operator The data conversion unit will be inserted between the N-1th operator and the Nth operator only when the format of the output data of the operator. Therefore, this application considers the continuity of the data format supported by multiple operators, and Compared with the prior art, format conversion processing can be greatly reduced and network performance can be improved.

(可选的)S704、若确定计算网络的最后一个计算单元的输出数据的格式与计算网络的原始输出数据的格式不同,在计算网络的最后一个计算单元之后添加第二格式转换单元。(Optional) S704. If it is determined that the format of the output data of the last computing unit of the computing network is different from the format of the original output data of the computing network, add a second format converting unit after the last computing unit of the computing network.

可以理解的,上述步骤S704可以由处理器确定计算网络的最后一个计算单元的输出数据的格式与原始输出数据的格式是否相同,并在处理器确定计算网络的最后一个计算单元的输出数据的格式与原始输出数据的格式不同时,在计算网络的最后一个计算单元之后添加第二格式转换单元。It can be understood that in the above step S704, the processor may determine whether the format of the output data of the last computing unit of the computing network is the same as the format of the original output data, and determine the format of the output data of the last computing unit of the computing network by the processor When the format of the original output data is different, a second format conversion unit is added after the last calculation unit of the calculation network.

可选的,上述计算网络的原始输出数据为经过网络处理后的原始输出数据。该计算网络的原始输出数据的格式为未适配硬件的数据格式。例如,Conv算子为了适配硬件,需要将输入数据的格式转换为NC1HWC0格式,该NC1HWC0格式为适配硬件的数据格式,而计算网络的原始输出数据为未适配硬件的数据格式,例如,计算网络的原始输出数据可以为NCHW格式或NHWC格式。Optionally, the original output data of the above computing network is the original output data processed by the network. The format of the original output data of the computing network is a data format not adapted to the hardware. For example, in order to adapt to the hardware, the Conv operator needs to convert the format of the input data to the NC1HWC0 format. The NC1HWC0 format is a data format that adapts to the hardware, while the original output data of the computing network is a data format that is not adapted to the hardware. For example, The original output data of the computing network can be in NCHW format or NHWC format.

可选的,上述计算网络的原始输出数据的格式可以与计算网络的原始输入数据的格式相同,也可以与计算网络的原始输入数据的格式不同,本申请对此并不限定。Optionally, the format of the original output data of the computing network may be the same as that of the original input data of the computing network, or may be different from the format of the original input data of the computing network, which is not limited in this application.

上述第二格式转换单元用于将最后一个计算单元的输出数据的格式转换为计算网络的原始输出数据的格式。The above-mentioned second format conversion unit is used to convert the format of the output data of the last computing unit into the format of the original output data of the computing network.

示例性的,在计算网络的最后一个算子的输出数据的格式与计算网络的原始输出数据的格式不同的情况下,为了确保计算网络输出数据的格式与原始输出数据的格式一致,可以在最后一个计算单元后插入格式转换算子,以将最后一个算子的输出数据的格式转换为原始输出数据的格式。Exemplarily, when the format of the output data of the last operator of the computing network is different from the format of the original output data of the computing network, in order to ensure that the format of the output data of the computing network is consistent with the format of the original output data, you can A format conversion operator is inserted after a calculation unit to convert the format of the output data of the last operator to the format of the original output data.

如图9所示,以计算网络的原始输出数据的格式为NHWC,Relu2算子为计算网络的最后一个算子为例,由于Relu2算子的输出数据的格式为NC1HWC0,与原始输出数据的格式不同,因此,在Relu2算子后添加格式转换算子(第二格式转换单元),将Relu2算子的输出数据的格式转换为NHWC格式,以确保计算网络的输出数据的格式与原始输出数据的格式相同。As shown in Figure 9, taking the original output data format of the computing network as NHWC and the Relu2 operator as the last operator of the computing network as an example, since the output data format of the Relu2 operator is NC1HWC0, it is different from the original output data format different, therefore, a format conversion operator (the second format conversion unit) is added after the Relu2 operator to convert the format of the output data of the Relu2 operator into the NHWC format to ensure that the format of the output data of the computing network is consistent with that of the original output data The format is the same.

可以理解的,本申请实施例提供的数据格式处理方法,通过在第一计算单元不支持第一计算单元的输入数据的格式时,在第一计算单元之前添加第一格式转换单元,在第二计算单元支持第一计算单元的输出数据的格式时,不在第一计算单元和第二计算单元之间进行格式转换处理,因此,减少了网络中格式转换单元的数量,减少了网络中的格式处理,提升了网络性能。而且通过在计算网络的最后一个计算单元的输出数据的格式与原始输出数据的格式不同时,处理器对最后一个计算单元的输出数据的格式进行转换处理,以保持计算网络输出数据的格式与原始输出数据的格式一致。It can be understood that in the data format processing method provided by the embodiment of the present application, when the first computing unit does not support the format of the input data of the first computing unit, the first format conversion unit is added before the first computing unit, and the second When the computing unit supports the format of the output data of the first computing unit, format conversion processing is not performed between the first computing unit and the second computing unit, thus reducing the number of format conversion units in the network and reducing the format processing in the network , which improves network performance. Moreover, when the format of the output data of the last computing unit of the computing network is different from the format of the original output data, the processor converts the format of the output data of the last computing unit to keep the format of the output data of the computing network consistent with the original The format of the output data is consistent.

下面,对本申请实施例上述方案的中间逻辑进行解释说明。Next, the intermediate logic of the above solution in the embodiment of the present application is explained.

示例性的,以图1所示的计算网络为例,该计算网络中的算子序列依次包括Conv1算子、Relu1算子、Conv2算子、和Relu2算子。Exemplarily, taking the computing network shown in FIG. 1 as an example, the sequence of operators in the computing network sequentially includes a Conv1 operator, a Relu1 operator, a Conv2 operator, and a Relu2 operator.

如图1所示,对于Conv1算子,由于原始输入数据的格式为NHWC,Conv1算子支持的数据格式为NC1HWC0,因此Conv1算子不支持原始输入数据的格式,故在Conv1算子之前和Conv1算子之后分别插入格式转换算子。如图10中的(a)所示,Conv1算子之前的格式转换算子用于将原始输入数据的格式NHWC转换为Conv1算子支持的数据格式NC1HWC0,Conv1算子之后的格式转换算子用于将Conv1算子的输出数据的格式NC1HWC0转换为NHWC。As shown in Figure 1, for the Conv1 operator, since the format of the original input data is NHWC, the data format supported by the Conv1 operator is NC1HWC0, so the Conv1 operator does not support the format of the original input data, so before the Conv1 operator and Conv1 Insert the format conversion operator after the operator respectively. As shown in (a) in Figure 10, the format conversion operator before the Conv1 operator is used to convert the format NHWC of the original input data into the data format NC1HWC0 supported by the Conv1 operator, and the format conversion operator after the Conv1 operator uses It is used to convert the format NC1HWC0 of the output data of the Conv1 operator to NHWC.

如图10中的(a)所示,对于Relu1算子,在算子信息库配置的模式为格式无关类,即Relu1算子支持任意数据格式,可以选择与前一个算子(即Conv1算子)相同的数据格式进行处理,故在Relu1算子之前和Relu1算子之后分别插入格式转换算子。如图10中的(b)所示,Relu1算子之前的格式转换算子用于将原始输入数据的格式NHWC转换为NC1HWC0,Relu1算子之后的格式转换算子用于将Relu1算子的输出数据的格式NC1HWC0转换为NHWC。As shown in (a) in Figure 10, for the Relu1 operator, the mode configured in the operator information base is a format-independent class, that is, the Relu1 operator supports any data format, and can choose ) are processed in the same data format, so format conversion operators are inserted before and after the Relu1 operator respectively. As shown in (b) in Figure 10, the format conversion operator before the Relu1 operator is used to convert the original input data format NHWC to NC1HWC0, and the format conversion operator after the Relu1 operator is used to convert the output of the Relu1 operator The format of the data is NC1HWC0 converted to NHWC.

如图10中的(b)所示,由于Conv1算子之后的格式转换算子与Relu1算子之前的格式转换算子的逻辑互逆,因此可以消除,消除后得到图10中的(c)所示的计算网络。可以理解的,本申请通过将硬件格式暴露到FE层面,在FE层面寻找到了格式转换消除的机会,减少了格式转换处理,使得网络性能得到提升。As shown in (b) in Figure 10, since the format conversion operator after the Conv1 operator is logically inverse to the format conversion operator before the Relu1 operator, it can be eliminated, and (c) in Figure 10 can be obtained after elimination Computational network shown. It can be understood that, by exposing the hardware format to the FE level, this application finds an opportunity to eliminate the format conversion at the FE level, reduces the format conversion process, and improves the network performance.

如图10中的(c)所示,对于Conv2算子,由于Conv2算子的输入数据的格式为NHWC,Conv2算子支持的数据格式为NC1HWC0,因此Conv2算子不支持Conv2算 子的输入数据的格式,故在Conv2算子之前和Conv2算子之后分别插入格式转换算子。如图10中的(d)所示,Conv2算子之前的格式转换算子用于将原始输入数据的格式NHWC转换为Conv2算子支持的数据格式NC1HWC0,Conv2算子之后的格式转换算子用于将Conv2算子的输出数据的格式NC1HWC0转换为NHWC。可以理解的,图10中的(c)中的Conv2算子的输入数据为Relu1算子的输出的数据经过格式转换算子转换处理后的数据,故Conv2算子的输入数据的格式为Relu1算子的输出的数据经过格式转换算子转换处理后的数据格式。As shown in (c) in Figure 10, for the Conv2 operator, since the input data format of the Conv2 operator is NHWC, and the data format supported by the Conv2 operator is NC1HWC0, the Conv2 operator does not support the input data of the Conv2 operator format, so the format conversion operator is inserted before the Conv2 operator and after the Conv2 operator. As shown in (d) in Figure 10, the format conversion operator before the Conv2 operator is used to convert the format NHWC of the original input data into the data format NC1HWC0 supported by the Conv2 operator, and the format conversion operator after the Conv2 operator is used It is used to convert the format NC1HWC0 of the output data of the Conv2 operator to NHWC. It can be understood that the input data of the Conv2 operator in (c) in Figure 10 is the output data of the Relu1 operator after the format conversion operator converts the data, so the format of the input data of the Conv2 operator is the Relu1 operator The output data of the child is converted into the data format after the format conversion operator.

如图10中的(d)所示,由于Relu1算子之后的格式转换算子与Conv2算子之前的格式转换算子的逻辑互逆,因此可以消除,消除后得到图10中的(e)所示的计算网络。As shown in (d) in Figure 10, since the logic of the format conversion operator after the Relu1 operator and the format conversion operator before the Conv2 operator are reciprocal, they can be eliminated, and (e) in Figure 10 can be obtained after elimination Computational network shown.

如图10中的(e)所示,对于Relu2算子,由于Relu算子在算子信息库配置的模式为格式无关类,即Relu2算子支持任意数据格式,可以选择与前一个算子(即Conv2算子)相同的数据格式进行处理,故在Relu2算子之前和Relu2算子之后分别插入格式转换算子。如图10中的(f)所示,Relu2算子之前的格式转换算子用于将原始输入数据的格式NHWC转换为NC1HWC0,Relu2算子之后的格式转换算子用于将Relu2算子的输出数据的格式NC1HWC0转换为NHWC。As shown in (e) in Figure 10, for the Relu2 operator, since the mode configured by the Relu operator in the operator information base is a format-independent class, that is, the Relu2 operator supports any data format, and it can be selected to be the same as the previous operator ( That is, the Conv2 operator) is processed in the same data format, so the format conversion operator is inserted before the Relu2 operator and after the Relu2 operator. As shown in (f) in Figure 10, the format conversion operator before the Relu2 operator is used to convert the format NHWC of the original input data to NC1HWC0, and the format conversion operator after the Relu2 operator is used to convert the output of the Relu2 operator The format of the data is NC1HWC0 converted to NHWC.

如图10中的(f)所示,由于Conv2算子之后的格式转换算子与Relu2算子之前的格式转换算子的逻辑互逆,因此可以消除,消除后得到图10中的(g)所示的计算网络。As shown in (f) in Figure 10, since the format conversion operator after the Conv2 operator is logically inverse to the format conversion operator before the Relu2 operator, it can be eliminated, and (g) in Figure 10 can be obtained after elimination Computational network shown.

可以理解的,图10中的(f)所示的计算网络即为采用本申请实施例的方案得到的图9所示的计算网络。该计算网络与图2所示的计算网络相比,不是在算子内部进行格式转换,而是在FE层进行格式转换,因此不需要像图2所示的方案一样,每个Conv算子内部都要进行转换逻辑。该计算网络与图5所示的计算网络相比,本申请实施例的方案不需要在每个Conv算子的前后都分别插入格式转换算子,只有在后一个算子不支持前一个算子的输出数据的格式的情况下,才会插入格式转换算子进行格式转换处理,因此本申请实施例的方案减少了网络中格式转换处理的数量,提升了网络性能。It can be understood that the computing network shown in (f) in FIG. 10 is the computing network shown in FIG. 9 obtained by adopting the solution of the embodiment of the present application. Compared with the computing network shown in Figure 2, this computing network does not perform format conversion inside the operator, but performs format conversion at the FE layer, so it does not need to be like the solution shown in Figure 2, each Conv operator internal Transformation logic is required. Compared with the computing network shown in Figure 5, the computing network in this application embodiment does not need to insert format conversion operators before and after each Conv operator, only when the latter operator does not support the previous operator. Only when the format of the output data is specified, a format conversion operator is inserted for format conversion processing. Therefore, the solution of the embodiment of the present application reduces the number of format conversion processing in the network and improves network performance.

需要说明的是,本申请通过算子信息库配置,将硬件格式暴露到FE层面,在FE层面寻找到了格式转换消除的机会,减少了格式转换处理,使得网络性能得到提升。It should be noted that this application exposes the hardware format to the FE level through the configuration of the operator information base, finds the opportunity to eliminate the format conversion at the FE level, reduces the format conversion process, and improves the network performance.

本申请实施例提供的数据格式处理方法,在确定是否插入格式转换算子时,考虑了多个算子之间支持的数据格式的连续性,如果后一个算子支持前一个算子的输出数据的格式,那么确定不在这两个算子之间插入格式转换算子,如果后一个算子不支持前一个算子的输出数据的格式,那么在这两个算子之间插入格式转换算子,从而能够减少数据转换处理的数量,提升网络性能。The data format processing method provided by the embodiment of the present application considers the continuity of the data formats supported by multiple operators when determining whether to insert a format conversion operator. If the latter operator supports the output data of the previous operator format, then make sure not to insert a format conversion operator between these two operators, if the latter operator does not support the format of the output data of the previous operator, then insert a format conversion operator between these two operators , thereby reducing the amount of data conversion processing and improving network performance.

上述主要从方法步骤的角度对本发明实施例提供的方案进行了介绍。可以理解的是,计算机为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件和计算机软件的结合形式来实现。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出 本发明的范围。The foregoing mainly introduces the solutions provided by the embodiments of the present invention from the perspective of method steps. It can be understood that, in order to realize the above functions, the computer includes hardware structures and/or software modules corresponding to each function. Those skilled in the art should easily realize that the present application can be realized in a combined form of hardware and computer software in combination with the units and algorithm steps of each example described in the embodiments disclosed herein. Skilled artisans may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present invention.

本申请实施例可以根据上述方法示例对计算机进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本发明实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiment of the present application may divide the computer into functional modules according to the above method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules. It should be noted that the division of modules in the embodiment of the present invention is schematic, and is only a logical function division, and there may be another division manner in actual implementation.

图11示出了一种数据格式处理装置1100的组成示意图,该数据格式处理装置1100可以用于实现上述任一实施例涉及的方法和功能。Fig. 11 shows a schematic composition diagram of a data format processing apparatus 1100, and the data format processing apparatus 1100 can be used to implement the methods and functions involved in any of the above-mentioned embodiments.

该数据格式处理装置1100包括:处理单元1101和获取单元1102。示例性的,处理单元1101用于对上述数据格式处理装置的动作进行控制管理,用于执行上述实施例中由处理器进行的处理,可选的,若数据格式处理装置1100包括存储单元,则处理单元1101还可以执行存储在存储器中的程序或指令,以使得数据格式处理装置1100实现上述任一实施例所涉及的方法和功能。The data format processing apparatus 1100 includes: a processing unit 1101 and an obtaining unit 1102 . Exemplarily, the processing unit 1101 is configured to control and manage the actions of the above-mentioned data format processing device, and is used to execute the processing performed by the processor in the above-mentioned embodiment. Optionally, if the data format processing device 1100 includes a storage unit, then The processing unit 1101 may also execute programs or instructions stored in the memory, so that the data format processing apparatus 1100 implements the methods and functions involved in any of the foregoing embodiments.

示例性的,上述处理单元1101可以用于执行图7中的步骤S702-S704,和/或用于本文所描述的技术的其它过程。获取单元1102可以用于执行例如获取第一计算单元和第二计算单元支持的数据格式,和/或用于本文所描述的技术的其它过程。其中,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。Exemplarily, the above-mentioned processing unit 1101 may be used to execute steps S702-S704 in FIG. 7, and/or other processes for the technologies described herein. The obtaining unit 1102 may be configured to perform, for example, obtaining data formats supported by the first computing unit and the second computing unit, and/or other processes for the techniques described herein. Wherein, all relevant content of each step involved in the above method embodiment can be referred to the function description of the corresponding function module, and will not be repeated here.

示例性的,在硬件实现上,可以由一个处理器执行处理单元1101的功能,可以由通信接口执行获取单元1102的功能,例如,可以由算子信息库加载模块的接口获取第一计算单元和第二计算单元支持的数据格式。其中,处理单元1101可以以硬件形式内嵌于或独立于数据格式处理装置1100的处理器中,也可以以软件形式存储于数据格式处理装置1100的存储器中,以便于处理器调用执行以上各个功能单元对应的操作。Exemplarily, in terms of hardware implementation, a processor may execute the function of the processing unit 1101, and a communication interface may execute the function of the acquisition unit 1102, for example, the interface of the operator information library loading module may acquire the first computing unit and The data format supported by the second computing unit. Wherein, the processing unit 1101 can be embedded in or independent of the processor of the data format processing device 1100 in the form of hardware, and can also be stored in the memory of the data format processing device 1100 in the form of software, so that the processor can call and execute the above functions The operation corresponding to the unit.

本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机可以执行图7所示的数据格式处理方法。The embodiment of the present application also provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer can execute the data format processing method shown in FIG. 7 .

本申请实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行图7所示的数据格式处理方法。The embodiment of the present application also provides a computer program product, which causes the computer to execute the data format processing method shown in FIG. 7 when the computer program product is run on the computer.

本申请实施例还提供了一种电子设备,该电子设备包括处理器以及存储器,所述存储器与所述处理器耦合;所述存储器用于存储计算机程序代码;所述计算机程序代码包括计算机指令,当所述处理器执行上述计算机指令时,使得所述电子设备执行图7所示的数据格式处理方法。The embodiment of the present application also provides an electronic device, the electronic device includes a processor and a memory, the memory is coupled to the processor; the memory is used to store computer program code; the computer program code includes computer instructions, When the processor executes the above computer instructions, the electronic device is made to execute the data format processing method shown in FIG. 7 .

本申请实施例还提供了一种电子设备,该电子设备包括中央处理器(CentralProcess Unit,CPU)和神经网络处理器(Neural-network Processing Unit,NPU),所述CPU用于执行图7所示的数据格式处理方法,所述NPU用于执行所述CPU基于所述数据格式处理方法得到的计算网络。The embodiment of the present application also provides an electronic device, the electronic device includes a central processing unit (Central Process Unit, CPU) and a neural network processor (Neural-network Processing Unit, NPU), and the CPU is used to execute the A data format processing method, the NPU is used to execute the computing network obtained by the CPU based on the data format processing method.

结合本申请公开内容所描述的方法或者算法的步骤可以硬件的方式来实现,也可以是由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于随机存取存储器(Random Access Memory,RAM)、闪存、可擦除可编程只读存储器(Erasable Programmable ROM,EPROM)、电可擦可编程只读存 储器(Electrically EPROM,EEPROM)、寄存器、硬盘、移动硬盘、只读光盘(CD-ROM)或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。另外,该ASIC可以位于核心网接口设备中。当然,处理器和存储介质也可以作为分立组件存在于核心网接口设备中。The steps of the methods or algorithms described in connection with the disclosure of this application can be implemented in the form of hardware, or can be implemented in the form of a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (Random Access Memory, RAM), flash memory, erasable programmable read-only memory (Erasable Programmable ROM, EPROM), electrically erasable Programmable read-only memory (Electrically EPROM, EEPROM), registers, hard disk, removable hard disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be a component of the processor. The processor and storage medium can be located in the ASIC. In addition, the ASIC may be located in the core network interface device. Certainly, the processor and the storage medium may also exist in the core network interface device as discrete components.

本领域技术人员应该可以意识到,在上述一个或多个示例中,本发明所描述的功能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在计算机可读介质中或者作为计算机可读介质上的一个或多个指令或代码进行传输。计算机可读介质包括计算机可读存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的任何介质。存储介质可以是通用或专用计算机能够存取的任何可用介质。Those skilled in the art should be aware that, in the above one or more examples, the functions described in the present invention may be implemented by hardware, software, firmware or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer-readable storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.

以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本发明的保护范围之内。The specific embodiments described above have further described the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above descriptions are only specific embodiments of the present invention and are not intended to limit the scope of the present invention. Protection scope, any modification, equivalent replacement, improvement, etc. made on the basis of the technical solution of the present invention shall be included in the protection scope of the present invention.

Claims (15)

  1. A data format processing method, applied to a computing network, where the computing network sequentially includes a first computing unit and a second computing unit, the method comprising:
    Acquiring data formats supported by the first computing unit and the second computing unit;
    if the first computing unit is determined not to support the format of the input data of the first computing unit, adding a first format conversion unit before the first computing unit, wherein the first format conversion unit is used for converting the format of the input data of the first computing unit into a data format supported by the first computing unit;
    if the second computing unit is determined to support the format of the output data of the first computing unit, determining that format conversion processing is not performed between the first computing unit and the second computing unit.
  2. The method of claim 1, wherein, in the case where the first computing unit is a first computing unit in the computing network, the format of the input data of the first computing unit is the format of the original input data of the computing network.
  3. The method according to claim 1, wherein in case the first computing unit is a computing unit located at an intermediate position in the computing network, the format of the input data of the first computing unit is the format of the output data of a computing unit preceding the first computing unit.
  4. A method according to any of claims 1-3, wherein, in case the second computing unit supports a plurality of data formats, determining the format in which the second computing unit supports the output data of the first computing unit comprises:
    and if the plurality of data formats supported by the second computing unit comprise the format of the output data of the first computing unit, determining that the second computing unit supports the format of the output data of the first computing unit.
  5. The method of any of claims 1-4, wherein the obtaining the data formats supported by the first computing unit and the second computing unit comprises:
    acquiring preset mode types of the first computing unit and the second computing unit; the preset mode types comprise a format independent class, a reduced reduction class and a Broadcast class;
    and determining the data formats supported by the first computing unit and the second computing unit according to the preset mode types of the first computing unit and the second computing unit.
  6. The method according to any one of claims 1-5, further comprising:
    if the format of the output data of the last computing unit of the computing network is different from the format of the original output data of the computing network, adding a second format conversion unit after the last computing unit of the computing network, wherein the second format conversion unit is used for converting the format of the output data of the last computing unit into the format of the original output data of the computing network.
  7. A data format processing apparatus, applied to a computing network, the computing network comprising, in order, a first computing unit and a second computing unit, the apparatus comprising: a processing unit and an acquisition unit;
    the acquisition unit is used for acquiring the data formats supported by the first calculation unit and the second calculation unit;
    the processing unit is configured to add a first format conversion unit before the first computing unit if it is determined that the first computing unit does not support the format of the input data of the first computing unit, where the first format conversion unit is configured to convert the format of the input data of the first computing unit into a data format supported by the first computing unit;
    the processing unit is further configured to determine that format conversion processing is not performed between the first computing unit and the second computing unit if it is determined that the second computing unit supports the format of the output data of the first computing unit.
  8. The apparatus of claim 7, wherein, in the case where the first computing unit is a first computing unit in the computing network, the format of the input data of the first computing unit is the format of the original input data of the computing network.
  9. The apparatus of claim 7, wherein, in the case where the first computing unit is a computing unit located at an intermediate position in the computing network, the format of input data of the first computing unit is the format of output data of a computing unit preceding the first computing unit.
  10. The apparatus according to any of claims 7-9, wherein the processing unit is configured to determine that the second computing unit supports the format of the output data of the first computing unit if it is determined that the plurality of data formats supported by the second computing unit includes the format of the output data of the first computing unit.
  11. The device according to any one of claims 7 to 10, wherein,
    the acquisition unit is further used for acquiring preset mode types of the first calculation unit and the second calculation unit; the preset mode types comprise a format independent class, a reduced reduction class and a Broadcast class;
    the processing unit is further configured to determine a data format supported by the first computing unit and the second computing unit according to the preset mode types of the first computing unit and the second computing unit acquired by the acquiring unit.
  12. The apparatus according to any one of claims 7-11, wherein the processing unit is further configured to:
    if the format of the output data of the last computing unit of the computing network is different from the format of the original output data of the computing network, adding a second format conversion unit after the last computing unit of the computing network, wherein the second format conversion unit is used for converting the format of the output data of the last computing unit into the format of the original output data of the computing network.
  13. An electronic device comprising a processor and a memory, the memory coupled to the processor; the memory is used for storing computer program codes; the computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform the method of any of claims 1-6.
  14. A computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method of any of claims 1-6.
  15. A computer program product, characterized in that the computer program product, when run on a computer, causes the computer to perform the method according to any of claims 1-6.
CN202080105412.5A 2020-09-28 2020-09-28 A data format processing method and device Pending CN116325703A (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/118563 WO2022061931A1 (en) 2020-09-28 2020-09-28 Data format processing method and apparatus

Publications (1)

Publication Number Publication Date
CN116325703A true CN116325703A (en) 2023-06-23

Family

ID=80846158

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202080105412.5A Pending CN116325703A (en) 2020-09-28 2020-09-28 A data format processing method and device

Country Status (2)

Country Link
CN (1) CN116325703A (en)
WO (1) WO2022061931A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114896950B (en) * 2022-07-11 2022-10-28 浙江大华技术股份有限公司 Model conversion method, model conversion device, and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1091536A2 (en) * 1999-10-04 2001-04-11 Microsoft Corporation Methods and systems for conversion of data format
CN102413075A (en) * 2011-12-18 2012-04-11 上海量明科技发展有限公司 Method and system for format conversion in data transmission
CN103491135A (en) * 2013-09-02 2014-01-01 用友软件股份有限公司 Device and method for conducting self-matching on data formats
CN111176725A (en) * 2019-12-27 2020-05-19 北京市商汤科技开发有限公司 Data processing method, device, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103955447B (en) * 2014-04-28 2017-04-12 中国人民解放军国防科学技术大学 FFT accelerator based on DSP chip
CN111128402A (en) * 2019-12-20 2020-05-08 天津新开心生活科技有限公司 Data format conversion method and device, storage medium and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1091536A2 (en) * 1999-10-04 2001-04-11 Microsoft Corporation Methods and systems for conversion of data format
CN102413075A (en) * 2011-12-18 2012-04-11 上海量明科技发展有限公司 Method and system for format conversion in data transmission
CN103491135A (en) * 2013-09-02 2014-01-01 用友软件股份有限公司 Device and method for conducting self-matching on data formats
CN111176725A (en) * 2019-12-27 2020-05-19 北京市商汤科技开发有限公司 Data processing method, device, equipment and storage medium

Also Published As

Publication number Publication date
WO2022061931A1 (en) 2022-03-31

Similar Documents

Publication Publication Date Title
CN110738324B (en) Deep learning system and method for processing data for deep learning system
CN113033811B (en) Processing method and device for two-quantum bit logic gate
US11763155B2 (en) Using sub-networks created from neural networks for processing color images
CN110458285B (en) Data processing method, data processing device, computer equipment and storage medium
CN111338695B (en) Data processing method based on pipeline technology and related product
CN114117992B (en) Serialization and deserialization method and device and electronic equipment
CN112862074A (en) Model operation method and device, electronic equipment and storage medium
CN109272567B (en) Three-dimensional model optimization method and device
JP4212676B2 (en) Information processing system and information processing method
CN116325703A (en) A data format processing method and device
CN101986282A (en) Topological adaptation method and device
CN110458286B (en) Data processing method, data processing device, computer equipment and storage medium
CN117764122B (en) Computational graph processing method, device, electronic device and storage medium
CN113111111A (en) Multi-data source database access method
CN113111108A (en) File data source warehousing analysis access method
CN110312990A (en) Configuration method and system
CN113111109A (en) Interface warehousing analysis access method of data source
US20230274158A1 (en) Device and method for neural network computing, and board and readable storage medium
US20230259746A1 (en) Device for forward fusion of neural network, board, method, and readable storage medium
WO2021258964A1 (en) Neural network architecture search method, apparatus and system
CN115629758A (en) Component determination method, device and storage medium
CN116415621A (en) Neural network slicing method, device and electronic equipment
US6941256B1 (en) Bus structure, database and method of designing interface
CN113391810B (en) A parsing method and system based on application scenario graph
CN118939275B (en) Compiling method, calling method, device, equipment and program product of classification parameters

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination