Network deployment method and system

By blocking and compressing the network weight data, the problem of insufficient accuracy of low-bit quantization methods in the end-side network is solved, efficient network deployment is achieved, and the inference speed is improved.

CN118573585APending Publication Date: 2024-08-30WANGYIYOUDAO INFORMATION TECH BEIJING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410658623.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the end-side network structure, although low-bit quantization methods can improve calculation speed, their accuracy cannot meet business needs, resulting in slow inference speed.

Method used

By dividing and compressing the weight data of the network to be deployed, and sending it to the second device for deployment, the accuracy of the network is ensured and the deployment efficiency is improved. Specific steps include obtaining the weight data, compressing the weight elements after dividing into blocks, and sending the compressed blocks to the second device. The second device decompresses and deploys the network after receiving it.

Benefits of technology

While ensuring network accuracy, it improves the deployment efficiency of the second device, solves the problem of insufficient accuracy of low-bit quantization methods, and improves the inference speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118573585A
    Figure CN118573585A
Patent Text Reader

Abstract

The invention discloses a network deployment method and system, and the method is applied to a first device, and comprises the steps: obtaining the weight data of a to-be-deployed network; the weight data is used for matrix operation in the reasoning process; partitioning the weight data to obtain at least two weight blocks; compressing the weight elements in the at least two weight blocks to obtain at least two compressed weight blocks; and sending the at least two compressed weight blocks to a second device to complete deployment of the to-be-deployed network. According to the scheme, the precision and efficiency of network deployment can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to but is not limited to the field of network deployment technology, and in particular to a network deployment method and system. Background Art

[0002] In the related technology, in the network structure on the terminal side, the calculation accuracy of the hexadecimal encoding method is sufficient to meet the needs of the business. Although the lower-bit quantization method can improve the calculation speed, its accuracy cannot meet the business needs. Therefore, there is still the problem that low bits cannot meet the accuracy requirements and the high-precision reasoning speed is slow. Summary of the invention

[0003] In view of this, the embodiments of the present application at least provide a network deployment method and system.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a network deployment method, which is applied to a first device, and includes obtaining weight data of a network to be deployed; the weight data is used for matrix operations in an inference process; the weight data is divided into blocks to obtain at least two weight blocks; the weight elements in the at least two weight blocks are compressed to obtain at least two compressed weight blocks; and the at least two compressed weight blocks are sent to a second device to complete the deployment of the network to be deployed.

[0006] In a second aspect, an embodiment of the present application provides a network deployment method, which is applied to a second device, including receiving at least two compressed weight blocks sent by a first device, and decompressing the at least two compressed weight blocks to obtain at least two pre-compressed weight blocks; and using the at least two pre-compressed weight blocks to deploy the corresponding network to be deployed.

[0007] In a third aspect, an embodiment of the present application provides a compression device, which includes: an acquisition module for acquiring weight data of a network to be deployed; the weight data is used for matrix operations in an inference process; a blocking module for blocking the weight data to obtain at least two weight blocks; a compression module for compressing weight elements in the at least two weight blocks to obtain at least two compressed weight blocks; and a sending module for sending the at least two compressed weight blocks to a second device to complete the deployment of the network to be deployed.

[0008] In a fourth aspect, an embodiment of the present application provides a deployment device, comprising: a decompression module, used to receive at least two compressed weight blocks sent by a first device, and decompress the at least two compressed weight blocks to obtain at least two pre-compressed weight blocks; a deployment module, used to deploy the corresponding network to be deployed using the at least two pre-compressed weight blocks.

[0009] In a fifth aspect, an embodiment of the present application provides a network deployment system, the system comprising a first device and a second device; wherein the first device is used to obtain weight data of a network to be deployed; the weight data is used for matrix operations in an inference process; the weight data is divided into blocks to obtain at least two weight blocks; the weight elements in the at least two weight blocks are compressed to obtain at least two compressed weight blocks; the at least two compressed weight blocks are sent to a second device; the second device is used to receive the at least two compressed weight blocks sent by the first device, and decompress the at least two compressed weight blocks to obtain at least two pre-compression weight blocks; and the corresponding network to be deployed is deployed using the at least two pre-compressed weight blocks.

[0010] In a sixth aspect, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0011] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements some or all of the steps in the above method when executed by a processor.

[0012] In an eighth aspect, an embodiment of the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement some or all of the steps in the above method.

[0013] In an embodiment of the present application, the weight data of the network to be deployed is divided into blocks in the first device, and the separated weight data is compressed and sent to the second device for deployment, thereby improving the deployment efficiency of the second device while ensuring the accuracy of the network deployed by the second device.

[0014] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0016] Figure 1 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0017] Figure 2 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0018] Figure 3 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0019] Figure 4 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0020] Figure 5 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0021] Figure 6 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0022] Figure 7 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0023] Figure 8 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0024] Fig. 9 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application;

[0025] Fig.10 A schematic diagram of an implementation flow of a single-size network deployment method provided in an embodiment of the present application;

[0026] Fig.11 A schematic diagram of the implementation flow of a multi-size network block strategy method provided in an embodiment of the present application;

[0027] Fig.12 A schematic diagram of the structure of a compression device provided in an embodiment of the present application;

[0028] Fig.13 A schematic diagram of the structure of a deployment device provided in an embodiment of the present application;

[0029] Fig.14 A schematic diagram of the structure of a network deployment system provided in an embodiment of the present application;

[0030] Fig.15 A schematic diagram of the hardware entity of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0032] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. The terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific order for the objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing this application and are not intended to limit this application.

[0034] In the related technology, for the network structure of the terminal device, the calculation accuracy of the hexadecimal encoding method can meet the current business needs, but its calculation speed cannot meet the needs; the use of a lower bit quantization method can improve the calculation speed, but the accuracy cannot meet the business needs.

[0035] Based on the above technical problems, an embodiment of the present application provides a network deployment method, which can be executed by a processor of a first device. The first device may refer to a server, a laptop, a tablet computer, a desktop computer, a smart TV, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable gaming device) and other devices with data processing capabilities.

[0036] Figure 1 A schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application, such as Figure 1 As shown, the method includes the following steps S101 to S103, combining Figure 1 The steps shown are explained.

[0037] Step S101, obtaining weight data of the network to be deployed; the weight data is used for matrix operations in the inference process.

[0038] In some embodiments, the first device may be a server, a laptop computer, a desktop computer, etc.

[0039] In some embodiments, the network to be deployed refers to a neural network, which may include a convolutional neural network, a recursive neural network, a fuzzy neural network, a recurrent neural network, a self-organizing neural network, a self-attention mechanism neural network, etc.; among them, the self-attention mechanism neural network, i.e., the transformer network, is taken as an example to illustrate the embodiments of the present application.

[0040] In some embodiments, the transformer network includes a single-size transformer network and a multi-size transformer network.

[0041] In some embodiments, the weight data may be stored weight data, transmitted weight data, calculated weight data, etc.

[0042] In some embodiments, the weight data of the transformer network includes general matrix multiplication (GEMM).

[0043] In some embodiments, weight data of the network to be deployed is obtained; the weight data is used for matrix operations in the inference process; it can be understood that the general matrix multiplication of the single-size transformer network or multi-size transformer network to be deployed is obtained, wherein the general matrix multiplication can be the product of multiple matrices or the product of multiple groups of matrices.

[0044] S102: Divide the weight data into blocks to obtain at least two weight blocks.

[0045] In some embodiments, the weight data is divided into blocks; it can be understood that the storage weight data, transmission weight data, and calculation weight data are divided into blocks; illustratively, the storage weight data can be divided into blocks according to the data type and storage method of the storage weight data to obtain at least two storage weight blocks; the transmission weight data can be divided into blocks according to the transmission type, transmission protocol, and data type of the transmission weight data to obtain at least two transmission weight blocks; the calculation weight data can be divided into blocks according to the calculation type of the calculation weight data, the computing power of the hardware device, and the size of the calculation data to obtain at least two calculation weight blocks.

[0046] In an embodiment of the present application, the weight data is divided into blocks to obtain at least two weight blocks; it can be understood that the general matrix multiplication of the transformer network is divided into blocks, and the general matrix multiplication of the transformer network is divided into N matrix multiplication blocks according to the data size, data type and computing power of the hardware device of the general matrix multiplication of the transformer network, where N is a positive integer greater than 1.

[0047] Step S103: compress the weight elements in the at least two weight blocks to obtain at least two compressed weight blocks.

[0048] In some embodiments, the compression method may include lossless compression, lossy compression, real-time compression, non-real-time compression, etc.

[0049] In some embodiments, the weight elements in the at least two weight blocks are compressed; it can be understood that lossless compression or lossy compression or instant compression or non-instant compression is performed on at least two weight blocks of weight data after blocking to obtain at least two compressed weight blocks; exemplarily, lossless compression or lossy compression or instant compression or non-instant compression can be performed on at least two storage weight blocks of weight data after blocking to obtain at least two compressed storage weight blocks; lossless compression or lossy compression or instant compression or non-instant compression is performed on at least two transmission weight blocks of transmission weight data after blocking to obtain at least two compressed transmission weight blocks; lossless compression or lossy compression or instant compression or non-instant compression is performed on at least two calculation weight blocks of calculation weight data after blocking to obtain at least two compressed calculation weight blocks.

[0050] In an embodiment of the present application, lossless compression or lossy compression or real-time compression or non-real-time compression is performed on at least two matrix multiplications after the transformer network is divided into blocks to obtain at least two compressed matrix multiplications.

[0051] Step S104: Send the at least two compressed weight blocks to the second device to complete the deployment of the network to be deployed.

[0052] In some embodiments, the second device represents a terminal device, which may include a mobile phone, a tablet, a smart watch, etc.

[0053] In some embodiments, the first device sends at least two compressed weight blocks to the second device, and the second device performs network deployment based on the at least two compressed weight blocks of the network weight data to be deployed; exemplarily, at least two compressed storage weight blocks are sent to the second device, and the second device performs network deployment based on the at least two compressed storage weight blocks; or at least two compressed transmission weight blocks are sent to the second device, and the second device performs network deployment based on the at least two compressed transmission weight blocks; or at least two compressed calculation weight blocks are sent to the second device, and the second device performs network deployment based on the at least two compressed calculation weight blocks.

[0054] In an embodiment of the present application, the first device sends at least two compressed matrix blocks of the general matrix block of the transformer network to the second device, and the second device deploys the transformer network according to the at least two compressed matrix blocks of the transformer network to be deployed.

[0055] In an embodiment of the present application, the weight data of the network to be deployed is divided into blocks in the first device, and the separated weight data is compressed and sent to the second device for deployment, thereby improving the deployment efficiency of the second device while ensuring the accuracy of the network deployed by the second device.

[0056] Figure 2 1 is a schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application, and the method can be executed by a processor of the first device. Figure 1 , Figure 1 The step S103 in can be updated to step S201 to step S203, combining Figure 2 The steps shown are explained.

[0057] Step S201, determining the exponent part and the mantissa part of each weight element in the weight block.

[0058] In some embodiments, the data format of the weight data of the network to be deployed is a 16-bit floating point format (BrainFloat 16, bf16); bf16 is a hexadecimal encoding method, and the maximum range it can represent is from 0x0000 to 0xFFFF; the bf16 encoding method is to represent numbers and characters in hexadecimal form, which can be used to store and transmit data.

[0059] In some embodiments, before determining the exponent part and the mantissa part of each weight element in the weight block, each element in the bf16 weight block needs to be represented in binary format. For example, the bf16 weight block is represented as N=S×2 E , where N is a binary number, S is the mantissa, and E is the exponent.

[0060] In some embodiments, the exponent part and the mantissa part of each weight element in the weight block are determined; it is understood that each element of each bf16 weight block is converted to binary, and the mantissa and the exponent of each element of each converted weight block are determined; illustratively, each element of at least two bf16 matrix multiplication blocks of the transformer network format as bf16 general matrix multiplication is converted into binary form, such as N = S × 2 E ; Determine the exponent E and mantissa S of each element in at least two binary matrix multiplication blocks.

[0061] Step S202: compress each of the rank code parts to obtain each compressed rank code part and a corresponding compression bit number mark code.

[0062] In some embodiments, each of the order code parts is compressed to obtain each compressed order code part and the corresponding compressed bit number mark code; that is, the order code of each element of each matrix multiplication of the transformer network is compressed; it can be understood that a plurality of binary numbers that can be represented by each element of each weight block are obtained, and a binary number with the smallest order code value among the plurality of binary numbers is obtained; illustratively, any binary element 0000000000010101 of the weight block can be represented as 0.10101×2 0000000000010000 or 0.10101×2 101 , where 0.10101×2 101 is the representation method of the minimum exponent of the element 0000000000010101; then the number of bits of the compressed exponent 101 of the element is 3, and 3 is determined as the marker code of the element.

[0063] In other embodiments, it is also necessary to determine the marking code of the weight block according to the minimum order number that can be represented by all elements in each weight block; it can be understood that if the weight block consists of 10 elements, 8 of which can represent the minimum order number with 5 bits, and the other two elements can represent the minimum order number with 8 bits, then the first marking code of the weight block is determined to be 8 and 5, and the second marking code is determined to be 8; wherein, the number of bits of the minimum order number that can be represented by each element in the weight block is determined by Calculate the compression ratio of the two marking codes of the weight block. If the compression ratio of the first marking code is less than 10% of the compression ratio of the second marking code, determine the first marking code as the marking code of the weight block; if the compression ratio of the first marking code is less than 10% of the compression ratio of the second marking code, determine the second marking code as the marking code of the weight block; wherein X is the compression ratio of the weight block, A is the element marking code of the weight block, and B is the number of elements corresponding to the marking code; illustratively, if the weight block When the marking codes are 8 and 5, the number of bits of the minimum order code that can be represented by 8 elements, 5, and the number of bits of the minimum order code that can be represented by 2 elements, 8, are substituted, and the compression rate X1 corresponding to the first marking code is 35%; if the marking code of the weight block is 8, the compression rate X2 corresponding to the second marking code is 50%. It can be understood that the compression rate X1 of the first marking code is 35%, which is less than 10% of the second marking code X2 of 50%, so the first marking codes 8 and 5 are determined as the marking codes of the weight block.

[0064] Step S203, obtaining the compressed weight block based on the mantissa part, the compressed exponent part and the corresponding compressed bit number mark code of each weight element in the weight block.

[0065] In some embodiments, the compressed weight block is obtained based on the mantissa part, the compressed exponent part and the corresponding compression bit mark code of each weight element in the weight block. It can be understood that the mantissa and exponent of each element of each weight block in the at least two weight blocks are separated, the mantissa of each element is saved, the exponent of each element is compressed and the mark code of the exponent bit compression is determined, and each compressed element is obtained based on the mantissa of each element, the compressed exponent of each element and the mark code of each element, and the mark code of each element is determined based on the mark code of the exponent bit of each element, and each compressed weight block is determined, and each compressed weight block is obtained based on the mark code of each compressed element and each weight block; compressed weight data is obtained based on each compressed weight block.

[0066] Exemplarily, the exponent and mantissa of each binary element of each matrix multiplication in the general matrix multiplication of the transformer network are separated; the mantissa of each binary element of each matrix multiplication is saved; the exponent of each binary element of each matrix multiplication is compressed, and the marking code of each binary element is determined based on the compressed mantissa of the exponent of each binary element; each compressed binary element is obtained based on the mantissa of each binary element, the compressed exponent of each binary element, and the compressed mantissa marking code of each binary element; each compressed matrix multiplication is obtained based on the compressed bit mark code of each binary element and each compressed binary element.

[0067] In an embodiment of the present application, the number of bits of each element is reduced by compressing the exponent of the binary elements of each weight block, and the compressed bit number mark code of each binary element and each weight block is determined to increase the speed of decompression and inference on the second device, thereby improving the deployment efficiency and accuracy of the transformer network.

[0068] Figure 3 1 is a schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application, and the method can be executed by a processor of the first device. Figure 2 , Figure 2 Step S202 in can be updated to step S301 to step S303, combining Figure 3 The steps shown are explained.

[0069] Step S301: Obtain the minimum number of bits corresponding to each of the order code parts.

[0070] In some embodiments, at least one binary number that can be represented by each element in each weight block is traversed, and the minimum number of bits corresponding to the at least one exponent of the at least one binary number is obtained from the at least one exponent corresponding to the at least one binary number; illustratively, each element of each matrix block of the transformer network is traversed, at least one binary number that can be represented by each element is obtained, and the minimum number of bits corresponding to at least one exponent of the at least one binary number is determined.

[0071] For example, any element 0000000000010101 of each matrix block of the transformer network can represent binary numbers including 0.10101×2 0000000000010000 and 0.10101×2 101 , where 0.10101×2 101 This is a representation method of the minimum exponent of the element 0000000000010101. The number of bits of the element exponent can be 16 and 3. 3 is determined as the minimum number of bits corresponding to the element exponent.

[0072] Step S302: Determine a target number of bits for each of the octave parts based on a minimum number of bits corresponding to each of the octave parts.

[0073] In some embodiments, all elements in each weight block are traversed to obtain the minimum number of bits of the exponent code of the binary number that can be represented by all elements, and the target number of bits of each element is determined based on the minimum number of bits of the exponent code of the binary number that can be represented by each element, and the target number of bits of each weight block is determined based on the target number of bits of each element; for example, if the matrix multiplication consists of 10 elements, of which 8 elements can represent the minimum number of bits of the exponent code of the binary number is 5, based on Calculate the compression rate of the weight block, where A is the bit value used by all elements of the weight block, and B is the number of elements corresponding to the same bit value; when the bit numbers of the 10 elements are respectively represented by their respective minimum bit numbers, calculate the first compression rate X1, and when the bit numbers of the 10 elements are represented by 8 bits, calculate the second compression rate X2, and when X1 is less than 10% of X2, use the minimum number of bits of each element as the target number of bits; when X1 is less than 10% of X2, use the maximum number of bits among all elements as the target number of bits.

[0074] Step S303: compress each of the octave parts using the target bit number of each of the octave parts to obtain each compressed octave part and a corresponding compressed bit number mark code.

[0075] In some embodiments, according to The compression rate of the weight block is calculated, and it is found that when the number of bits of the 10 elements are represented by their respective minimum number of bits, the first compression rate X1 is 35%, and when the representation with the largest number of bits among the 10 elements is used, the first compression rate X1 is 35%. In the case that X1 is less than 10% of X2, the minimum number of bits 8 corresponding to 2 elements is used as the target number of bits of the weight block, and the number of bits corresponding to the exponent of the binary numbers that can be represented by all elements in the weight block is compressed to 8, and the number of bits 8 is determined as the marker code of the weight block.

[0076] In an embodiment of the present application, the compression rate of the weight block is determined by the minimum number of bits that each element can represent a binary order code, the target number of bits of the weight block is determined based on the compression rate of the weight block, and the target number of bits of the weight is determined as the weight block compression bit number mark code to improve the compression rate and the network deployment rate on the second device.

[0077] Figure 4 1 is a schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application, and the method can be executed by a processor of the first device. Figure 1 , Figure 1 Step S102 can be updated to step S401, combining Figure 4 The steps shown are explained.

[0078] Step S401, dividing the weight data into blocks according to a block strategy to obtain at least two weight blocks.

[0079] In some embodiments, for the weight data of a single-size network to be deployed, a blocking strategy for the weight data is determined according to the characteristics of the weight data, and the weight data is blocked to obtain at least two weight blocks according to the blocking strategy for the weight data; illustratively, the blocking strategy for storing the weight data is determined according to the data type and storage method of the stored weight data; the blocking strategy for transmitting the weight data is determined according to the transmission type, transmission protocol, and data type of the transmitted weight data; the blocking strategy for calculating the weight data is determined according to the calculation type of the calculated weight data, the computing power of the hardware device, and the size of the calculated data.

[0080] In an embodiment of the present application, for the general matrix multiplication of a single-size transformer network, a blocking strategy for the general matrix multiplication of the single-size transformer network is determined according to the number of rows and columns of each matrix in the general matrix multiplication, and the general matrix multiplication of the single-size transformer network is blocked based on the blocking strategy to obtain at least two matrix multiplications.

[0081] Figure 5 is a schematic diagram of an implementation flow of a method provided in an embodiment of the present application, and the method can be executed by a processor of a first device. Figure 4 , Figure 4 Step S401 in can be updated to steps S501 to S504, combining Figure 5 The steps shown are explained.

[0082] Step 501: When the network to be deployed is a multi-size network, obtain a preset block strategy corresponding to each single-size network; the multi-size network includes at least two single-size networks.

[0083] In some embodiments, the multi-size network includes multiple single-size networks, and a preset blocking strategy corresponding to each single-size network is obtained; it can be understood that the characteristics of the weight data of each single-size network are obtained, and the blocking strategy of each single-size network is determined based on the characteristics of the weight data of each single-size network and the characteristics of the first device; illustratively, according to the characteristics of each single-size network storing weight data, the blocking strategy for storing weight data is determined according to the data type and storage method of the stored weight data; according to the characteristics of each single-size network transmitting weight data, the blocking strategy for transmitting weight data is determined according to the transmission type, transmission protocol, and data type of the transmitted weight data; according to the characteristics of each single-size network calculating weight data, the blocking strategy for calculating weight data is determined according to the calculation type of the calculated weight data, the computing power of the hardware device, and the size of the calculated data.

[0084] Step S502: Obtain the time consumption corresponding to each single-size network under each preset block strategy.

[0085] In some embodiments, the time consumption corresponding to each of the single-size networks refers to dividing the weight data of each single-size network by different preset block strategies, and the time consumption of the second device deploying each single-size network based on the divided data.

[0086] In some embodiments, the time consumption corresponding to each of the single-size networks under each of the preset blocking strategies is obtained; it can be understood that the weight data of each single-size network is blocked by the blocking strategy corresponding to each single-size network of the multi-size model, and the second device determines the time consumption of each single-size network under different blocking strategies based on the segmentation data of each single-size network under different blocking strategies; exemplarily, if the multi-size network includes 3 single-size networks n1, n2, and n3, each single-size network corresponds to a blocking strategy of tiling1, tiling2, and tiling3 respectively, then the time consumption tiling-n of each single-size network under the 3 different blocking strategies is shown in Table 1.

[0087] Table 1

[0088] tiling-n n1 n2 n3 tiling1 tiling1n1 tiling1n2 tiling1n3 tiling2 tiling2n1 tiling2n2 tiling2n3 tiling3 tiling3n1 tiling3n2 tiling3n3

[0089] Among them, the time consumption of the three single-size models n1, n2, and n3 of the multi-size model under the first blocking strategy is T1=tiling1n1+tiling1n2+tiling1n3; the time consumption of the three single-size models under the second blocking strategy is T2=tiling2n1+tiling2n2+tiling2n3; the time consumption of the three single-size models under the third blocking strategy is T3=tiling3n1+tiling3n2+tiling3n3.

[0090] Step S503: Determine the comprehensive time consumption of each of the block strategies based on the time consumption corresponding to each of the single-size networks and the usage frequency of each of the single-size networks.

[0091] In some embodiments, the usage frequency of each of the single-sized networks refers to the frequency W at which each of the single-sized networks is used in the same application or in the same network environment; a time consumption model is constructed based on the time consumption corresponding to each of the single-sized networks and the usage frequency of each of the single-sized networks, as shown in formula (1).

[0092] H=Σ(tiling n * w) Formula (1)

[0093] Among them, H is the comprehensive time consumption of the multi-size network, tiling is the blocking strategy corresponding to each single-size network, n represents each single-size network; tiling-n refers to the time consumption corresponding to each single-size network, and W represents the usage frequency of each single-size network.

[0094] In some embodiments, combined with Table 1, the comprehensive time consumption of the multi-size network under different block strategies is shown in Table 2.

[0095] Table 2

[0096] H1 H2 H3 W T1*W T2*W T2*W

[0097] Step S504: determine the preset block strategy with the minimum comprehensive time consumption as the block strategy.

[0098] In some embodiments, in combination with what is shown in Table 2, the minimum time consumption among H1, H2, and H3 is obtained, and the blocking strategy corresponding to the minimum time consumption is determined as the blocking strategy of the multi-size network; illustratively, if H1 is 1 second, H2 is 2 seconds, and H3 is 3 seconds, the tling1 blocking strategy corresponding to H1 is determined as the blocking strategy of the multi-size network.

[0099] In an embodiment of the present application, based on the multiple single-size networks included in the multi-size network and the blocking strategy of each single-size network, combined with the usage probability of each single-size network, the blocking strategy of the multi-size network is determined from the blocking strategies corresponding to the multiple single-size networks, and blocking of all sizes can be achieved, thereby improving the efficiency and accuracy of blocking the weight data of the multi-size network.

[0100] Figure 6 1 is a schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application, and the method can be executed by a processor of the first device. Figure 1 , Figure 4 Step S401 in can be updated to steps S601 to S602, combining Figure 6 The steps shown are explained.

[0101] Step S601: When the network to be deployed is a single-size network, obtain matrix operation parameters corresponding to the weight data.

[0102] In some embodiments, when the network to be deployed is a single-size transformer network, operation parameters of each matrix multiplication in the general matrix multiplication of the transformer network are obtained, wherein the operation parameters of each matrix multiplication include the number of columns of the matrix input matrix and the output matrix; exemplarily, the matrix multiplication A(m,k)*B(k,n)=C(m,n); wherein A is the first input matrix, m is the number of rows of matrix A, k is the number of columns of matrix A, B is the second input matrix, k is the number of rows of matrix B, n is the number of columns of matrix B, C is the output matrix, m is the number of rows of matrix C, and n is the number of columns of matrix C.

[0103] Step S602: Determine the block strategy based on the matrix operation parameters corresponding to the weight data and the minimum computing unit of the first device.

[0104] In some embodiments, the minimum computing unit of the first device may include the bandwidth frequency of the first device or the minimum computing power of the first device. Exemplarily, the embodiment of the present application is described by taking the minimum computing unit of the first device as computing power 16*16 as an example; if any matrix multiplication of the general matrix multiplication of the transformer network is A(32,32)*B(32,32)=C(32,32), then the minimum computing unit 16*16 of the first setting is used to divide the matrix multiplication into 4 matrix multiplications of A1(16,16)*B1(16,16)=C1(16,16).

[0105] In an embodiment of the present application, the blocking strategy of the single-size network is determined by the number of rows and columns of each matrix in the general matrix multiplication of the single-size network, combined with the minimum computing unit of the first device, thereby improving the accuracy of the blocking and improving the inference speed of the second device on the block data.

[0106] Figure 7 is a schematic diagram of a network deployment method provided in an embodiment of the present application, and the method can be executed by a processor of the second device. The method can also include steps S701 to S702, combining Figure 7 The steps shown are explained.

[0107] Step S701: Receive at least two compressed weight blocks sent by the first device, and decompress the at least two compressed weight blocks to obtain at least two uncompressed weight blocks.

[0108] In some embodiments, the second device receives at least two compressed weight blocks sent by the first device; and identifies the marking codes of the at least two compressed weight blocks, and decompresses the at least two compressed weight blocks according to the marking codes of the at least two compressed weight blocks to obtain at least two weight blocks before compression; it can be understood that the marking code represents the minimum number of bits of the exponent code of the binary data that can be represented by each element in the at least two weight blocks before compression; based on the marking codes of the at least two compressed weight blocks and the mantissa of each element, each element in the compressed weight block is restored to the element before compression.

[0109] Exemplarily, the second device receives at least two matrix blocks of the transformer network sent by the first device, and according to the identification code 9 of each matrix block, restores the binary code of each element of each matrix block to 0000000000001001, and combines the mantissa S of each element to restore each element to the mantissa S*2 0000000000001001, based on each restored element, restore at least two matrix blocks of the transformer network.

[0110] Step S702: Deploy the corresponding network to be deployed using the at least two weight blocks before compression.

[0111] In some embodiments, at least two weight blocks corresponding to each restored element are downloaded to the cache of the second device, and the network to be deployed is deployed on the second device based on the downloaded at least two weight blocks; exemplarily, matrix blocks of at least two transformer networks after restoration are downloaded to the cache of the second device, and the transformer network is deployed in the second device based on the matrix blocks of at least two transformer networks.

[0112] In an embodiment of the present application, at least two weight blocks of the compressed network to be deployed are decompressed in the second device and downloaded to the cache of the second device, and the network to be deployed is deployed on the second device based on the at least two decompressed weight blocks, thereby improving the deployment efficiency of the network to be deployed on the second device.

[0113] Figure 8 1 is a schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application, and the method can be executed by a processor of the second device. Figure 7 , the step 701 can be updated to include step S801, combining Figure 8 The steps shown are explained.

[0114] Step 801: Receive the i-th compressed weight block through the receiving unit, and decompress the i-1-th compressed weight block through the decompression unit, where i is a positive integer.

[0115] In some embodiments, the second device is used to parallelly process the receiving process and the decompression process of at least two compressed weight blocks based on a multi-stage pipeline manner.

[0116] In some embodiments, the second device includes a receiving unit and a decompression unit.

[0117] In some embodiments, the i-th compressed weight block is received by the receiving unit, and the i-1-th compressed weight block is decompressed by the decompression unit, where i is a positive integer; it can be understood that there are 3 compressed weight blocks, the first weight block is received by the receiving unit, and the second weight block is received while the first block is decompressed by the decompression unit.

[0118] In some embodiments, the second device is further used to process the decompression process and the loading process of at least two compressed weight blocks in a parallel pipeline manner.

[0119] In some embodiments, the second device further includes a loading unit.

[0120] In some embodiments, i compressed weight blocks are decompressed by a decompression unit, and i-1 decompressed weight blocks are loaded into a cache of a second device by a loading unit.

[0121] Exemplarily, if there are 5 compressed weight blocks, after the first compressed weight block is received by the receiving unit, the first compressed weight block is decompressed by the decompression unit and the second compressed weight block is received at the same time. After receiving the second compressed weight block, the second compressed weight block is decompressed and the first compressed weight block is loaded and the third compressed weight block is received.

[0122] In an embodiment of the present application, the second device processes the receiving process, the decompression process, and the loading process in a multi-stage parallel pipeline manner, thereby improving the rate of network deployment and the rate of inference weight blocks in the second device.

[0123] Fig. 9 1 is a schematic diagram of an implementation flow of a network deployment method provided in an embodiment of the present application, and the method can be executed by a processor of the second device. Figure 7 , the step 701 can be updated to include step S901 and step 902, which will be combined Fig. 9 The steps shown are explained.

[0124] Step S901: restore the compressed exponent part of each weight element based on the compression bit number mark code of each weight element to obtain the exponent part of each weight element.

[0125] In some embodiments, the compressed weight block includes the mantissa portion of each weight element in the weight block before compression, the compressed exponent portion and the corresponding compressed bit number mark code.

[0126] In some embodiments, the exponent of each compressed element is restored based on the compression bit mark code of each element in each compressed weight block of the general matrix multiplication of the transformer network to obtain the exponent part of the binary data of each element before compression; exemplarily, the second device receives at least two compressed matrix blocks of the transformer network sent by the first device, and according to the compression bit identification code 9 of each compressed matrix block, restores the exponent of the binary number of each compressed element of each compressed matrix block to the exponent 0000000000001001 in the BF16 format before compression.

[0127] Step S902: Based on the exponent part and the mantissa part of each weight element, obtain the weight block before compression.

[0128] In some embodiments, each element before compression is obtained based on the exponent part and the mantissa part of each element of each weight block before compression, each matrix block before compression is obtained based on each element before compression, and the weight data before compression is obtained based on each matrix block before compression.

[0129] Exemplarily, each element of the compressed weight block received by the second device is obtained according to the mantissa of each element and the exponent of each element after restoration; for example, the mantissa of each element before compression is S, and the exponent of each element after restoration is obtained by combining the mantissa of each element after compression S*2 0000000000001001 , based on each element before compression, at least two weight blocks before compression are obtained, and based on at least two weight blocks before compression, the weight data of the network to be deployed is obtained, which is the general matrix multiplication of the transformer network.

[0130] The following describes an exemplary application of the network deployment method provided in an embodiment of the present application in an actual scenario.

[0131] In the related technology, in the transformer network on the terminal side, the calculation accuracy of bf16 or fp16 is sufficient to meet the business needs. The lower bit quantization method can greatly improve the calculation speed, but its accuracy cannot meet the business needs.

[0132] Existing problems: To address the problem that low bits cannot meet the accuracy requirements, and high precision (bf16 or fp16) can meet the accuracy requirements but has a slow inference speed, the bf16 data is compressed. However, for static graphs, decompression consumes performance, and bf16 compression cannot be used for dynamic graphs.

[0133] Based on the above technical problems: the performance consumption problem during decompression is solved through the order code compression method to maximize the performance improvement brought by the compression rate; pseudo-dynamics is achieved through multiple static graphs, and a cost model is constructed to achieve a balance between efficient operator tiling and unified compression.

[0134] Pre-trained language models based on neural networks and deep learning have brought breakthrough developments in natural language processing technology. The Transformer model based on the self-attention mechanism is the basis of pre-trained language models. Based on this model, various applications such as ASR / NMT have been extended and have been applied to multiple fields such as smart cockpits and smart learning hardware.

[0135] Quantization refers to converting model parameters into fewer bits for storage and calculation, which reduces the accuracy of the model. Although quantization loses a certain amount of accuracy, it can greatly improve the training and reasoning speed of the model within an acceptable accuracy range. BF16 is a 16-bit digital precision format designed specifically for accelerating deep learning training. It reduces 16 mantissa bits while retaining the number of FP32 (32-bit floating point) exponent bits. After converting the model parameters from FP32 to BF16, the model can achieve several times the training speed while maintaining similar accuracy.

[0136] In the embodiment of the present application, in the terminal side device, the hardware resources are limited, and the memory, cache and computing power are all limited. Therefore, this solution invents a bf16 lossless compression solution that is compatible with static and dynamic graphs, which reduces memory usage and improves the reasoning speed.

[0137] Fig.10 A schematic diagram of a single-size network deployment method provided in an embodiment of the present application. The method includes steps 1001 to 1004. Fig.10 The steps shown are explained.

[0138] Step S1001: For the GEMM calculation included in the current single-size network, select the optimal tiling scheme according to the characteristics of the GEMM calculation and the characteristics of the hardware.

[0139] In some embodiments, any matrix multiplication in the GEMM calculation is A(m,k)*B(k,n)=C(m,n); the characteristics of its M / K / N are that A is the first input matrix, m is the number of rows of matrix A, k is the number of columns of matrix A, B is the second input matrix, k is the number of rows of matrix B, n is the number of columns of matrix B, C is the output matrix, m is the number of rows of matrix C, and n is the number of columns of matrix C; the hardware characteristics are the minimum computing unit of the first device.

[0140] Exemplarily, the embodiment of the present application is explained by taking the minimum computing unit of the first device as 16*16 as an example; the single-size transformer network contains any matrix multiplication of GEMM calculation A(32,32)*B(32,32)=C(32,32), and the minimum computing unit of the first device 16*16 is used to divide the matrix multiplication into 4 matrix multiplications of A1(16,16)*B1(16,16)=C1(16,16).

[0141] Step S1002: perform bf16 compression on the weight of each block.

[0142] In some embodiments, the data of bf16 is stored in binary, and the exponent and the number of bits are separated; the exponent is compressed; finally, the compressed exponent and the mantissa are stored, and the compressed number of bits is marked; the exponent compression method is as follows: a loop is used to traverse each element in the original data, and the minimum nbit number that can be represented is calculated; then the histogram distribution of nbits in the entire data block is counted, and the length of the compressed data comp_size is calculated to make it a multiple of 16, and the final nbit is recorded. Exemplarily, a binary number is represented as N=S×2 E In the form of , where S is the mantissa and E is the exponent, the exponent is compressed; it can be understood that a loop is used to traverse each element in the single-size transformer network weight data, and the binary number with the smallest exponent bit number in the binary number that can be represented by each element is obtained, and the exponent of the smallest bit number of the binary number is used as the compressed exponent; the exponent and mantissa of each compressed element of each block weight are saved; and the number of bits of the exponent of the compressed element is used as the compressed bit mark code of each block weight. Step S1003, store the compressed bf16 weight data into the network structure.

[0143] Step S1004: deploy the transformer network in the terminal device.

[0144] In some embodiments, the transformer network is deployed as follows: first, the weights of the nth block are decompressed to bf16, and the decompressed weights of the nth block are loaded into the cache again, and the weights of the n+1th block are decompressed to bf16 at the same time; the pipeline of hardware components is implemented.

[0145] In an embodiment of the present application, a single-size transformer network can be deployed through the above steps. By compressing the order code of each element of the weight data of the single-size transformer network, the rate of decompression and inference of compressed data on the terminal device is improved, thereby improving the deployment rate of the single-size transformer network.

[0146] Fig.11 A schematic diagram of a multi-size network partitioning strategy method provided in an embodiment of the present application, the method includes steps 1101 to 1103, combining Fig.11 The steps shown are explained.

[0147] Step S1101: construct a multi-size transformer network time-consuming model.

[0148] In some embodiments, the costmodel is constructed, and the time consumption = Σ(tiling n*w) is to minimize the time consumption of the model. It can be understood that the multi-size transformer network includes multiple single-size transformer networks, and each single-size transformer network corresponds to a tiling strategy.

[0149] Step S1102: Evaluate the time consumption of each model by traversing tiling-n.

[0150] In some embodiments, the inference speed of each single-size transformer model after the tiling strategy corresponding to each single-size transformer model is obtained and then combined with w (the probability of the model being used in an application) of each single-size transformer model, the comprehensive time consumption of the corresponding multi-size transformer model in each tiling-n case is calculated, and the optimal tiling-n is selected.

[0151] Step S1103: deploy the multi-size network according to the selected block strategy.

[0152] In some embodiments, according to the selected tiling strategy of the multi-size transformer network, the above steps S1001 to 1004 are performed for each single-size transformer network of the multi-size transformer network, so that a balance between the blocking strategy and the compression rate under a single size can be achieved in the multi-size network.

[0153] In the embodiments of the present application, in a single-size network, decompression and data movement can be pipelined in parallel, and in most networks, the compression rate and inference speed are improved in a linear relationship; in a multi-size network, unified tiling and compression of all sizes can be jointly applied, and the performance is better than the customized size separate blocking solution.

[0154] Based on the foregoing embodiments, an embodiment of the present application provides a compression device, which includes the units included and the modules included in the units, which can be implemented by a processor in the first device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0155] Fig.12 A schematic diagram of the structure of a compression device provided in an embodiment of the present application is shown in FIG. Fig.12 As shown, the compression device 1200 includes: an acquisition module 1201, a blocking module 1202, a compression module 1203, and a sending module 1204, wherein: the acquisition module 1201 is used to obtain weight data of the network to be deployed; the weight data is used for matrix operations in the reasoning process; the blocking module 1202 is used to block the weight data to obtain at least two weight blocks; the compression module 1203 is used to compress the weight elements in the at least two weight blocks to obtain at least two compressed weight blocks; the sending module is used to send the at least two compressed weight blocks to the second device to complete the deployment of the network to be deployed.

[0156] In some embodiments, the compression module 1203 is also used to determine the exponent part and the mantissa part of each weight element in the weight block; compress each exponent part to obtain each compressed exponent part and the corresponding compression bit number mark code.

[0157] In some embodiments, the compression module 1203 is also used to obtain the minimum number of bits corresponding to each of the order code parts; based on the minimum number of bits corresponding to each of the order code parts, determine the target number of bits for each of the order code parts; use the target number of bits for each of the order code parts to compress each of the order code parts to obtain each compressed order code part and the corresponding compression bit number mark code.

[0158] In some embodiments, the blocking module 1202 is further used to block the weight data according to a blocking strategy to obtain at least two weight blocks.

[0159] In some embodiments, the blocking module 1202 is also used to obtain a preset blocking strategy corresponding to each single-size network when the network to be deployed is a multi-size network; the multi-size network includes at least two single-size networks; obtain the time consumption corresponding to each single-size network under each preset blocking strategy; determine the comprehensive time consumption of each blocking strategy based on the time consumption corresponding to each single-size network and the usage frequency of each single-size network; and determine the preset blocking strategy with the minimum comprehensive time consumption as the blocking strategy.

[0160] In some embodiments, the blocking module 1202 is also used to obtain the matrix operation parameters corresponding to the weight data when the network to be deployed is a single-size network; and determine the blocking strategy based on the matrix operation parameters corresponding to the weight data and the minimum computing unit of the first device.

[0161] Based on the foregoing embodiments, an embodiment of the present application provides a deployment device, which includes the units included and the modules included in the units, which can be implemented by a processor in the second device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0162] Fig.13 A schematic diagram of the structure of a deployment device provided in an embodiment of the present application is shown in FIG. Fig.13 As shown, the deployment device 1300 includes: a decompression module 1301 and a deployment module 1302, wherein: the decompression module 1301 is used to receive at least two compressed weight blocks sent by the first device, and decompress the at least two compressed weight blocks to obtain at least two pre-compressed weight blocks; the deployment module 1302 is used to deploy the corresponding network to be deployed using the at least two pre-compressed weight blocks.

[0163] In some embodiments, the second device is used to parallelly process the receiving process and decompression process of at least two compressed weight blocks based on a multi-stage pipeline method; the second device includes a receiving unit and a decompression unit; the decompression module 1301 is also used to receive the i-th compressed weight block through the receiving unit, and decompress the i-1-th compressed weight block through the decompression unit, where i is a positive integer.

[0164] In some embodiments, the compressed weight block includes: the mantissa part, the compressed exponent part and the corresponding compressed bit number mark code of each weight element in the weight block before compression; the decompression module 1301 is also used to restore the compressed exponent part of each weight element based on the compressed bit number mark code of each weight element to obtain the exponent part of each weight element; based on the exponent part and mantissa part of each weight element, the weight block before compression is obtained.

[0165] Based on the foregoing embodiments, the embodiments of the present application provide a network deployment system, which includes the units included and the modules included in the units, which can be implemented by the processors in the first device and the second device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0166] Fig.14 A schematic diagram of the structure of a network deployment system provided in an embodiment of the present application is shown in FIG. Fig.14 As shown, the network deployment system 1400 includes: a first device 1401 and a second device 1402, wherein: the first device 1401 is used to obtain weight data of the network to be deployed; the weight data is used for matrix operations in the reasoning process; the weight data is divided into blocks to obtain at least two weight blocks; the weight elements in the at least two weight blocks are compressed to obtain at least two compressed weight blocks; the second device 1402 is used to receive at least two compressed weight blocks sent by the first device, and decompress the at least two compressed weight blocks to obtain at least two uncompressed weight blocks; and the corresponding network to be deployed is deployed using the at least two uncompressed weight blocks.

[0167] In some embodiments, the first device 1401 is also used to determine the exponent part and the mantissa part of each of the weight elements in the weight block; compress each of the exponent parts to obtain each compressed exponent part and the corresponding compressed bit number mark code.

[0168] In some embodiments, the first device 1401 is also used to obtain the minimum number of bits corresponding to each of the octave parts; based on the minimum number of bits corresponding to each of the octave parts, determine the target number of bits for each of the octave parts; and use the target number of bits for each of the octave parts to compress each of the octave parts to obtain each compressed octave part and the corresponding compressed bit number mark code.

[0169] In some embodiments, the first device 1401 is further used to block the weight data according to a block strategy to obtain at least two weight blocks.

[0170] In some embodiments, the first device 1401 is further used to obtain a preset block strategy corresponding to each single-size network when the network to be deployed is a multi-size network; the multi-size network includes at least two single-size networks; obtain the time consumption corresponding to each single-size network under each preset block strategy; determine the comprehensive time consumption of each block strategy based on the time consumption corresponding to each single-size network and the usage frequency of each single-size network; and determine the preset block strategy with the minimum comprehensive time consumption as the block strategy.

[0171] In some embodiments, the first device 1401 is further used to obtain matrix operation parameters corresponding to the weight data when the network to be deployed is a single-size network; and determine the blocking strategy based on the matrix operation parameters corresponding to the weight data and the minimum computing unit of the first device.

[0172] In some embodiments, the second device is used to parallelly process the receiving process and decompression process of at least two compressed weight blocks based on a multi-stage pipeline method; the second device includes a receiving unit and a decompression unit; the second device 1402 is also used to receive the i-th compressed weight block through the receiving unit, and decompress the i-1-th compressed weight block through the decompression unit, where i is a positive integer.

[0173] In some embodiments, the compressed weight block includes: the mantissa part, the compressed exponent part and the corresponding compressed bit number mark code of each weight element in the weight block before compression; the second device 1402 is also used to restore the compressed exponent part of each weight element based on the compressed bit number mark code of each weight element to obtain the exponent part of each weight element; based on the exponent part and mantissa part of each weight element, the weight block before compression is obtained.

[0174] The description of the above system embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the system provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the system embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0175] It should be noted that in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0176] An embodiment of the present application provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0177] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0178] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in an electronic device, a processor in the electronic device executes some or all of the steps for implementing the above method.

[0179] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.

[0180] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.

[0181] Fig.15 A schematic diagram of the hardware entity of the computer device provided in the embodiment of the present application is as follows: Fig.15 As shown, the hardware entity of the computer device 1500 includes: a processor 1501 and a memory 1502, wherein the memory 1502 stores a computer program that can be run on the processor 1501, and the processor 1501 implements the steps in the method of any of the above embodiments when executing the program.

[0182] The memory 1502 stores a computer program that can be run on the processor. The memory 1502 is configured to store instructions and applications executable by the processor 1501. It can also cache data to be processed or processed by the processor 1501 and each module in the first device 1500 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0183] When the processor 1501 executes the program, the steps of any of the above methods are implemented. The processor 1501 generally controls the overall operation of the first device 1500.

[0184] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the method of any of the above embodiments.

[0185] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0186] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application are not specifically limited.

[0187] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0188] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.

[0189] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0190] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0191] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0192] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiments are executed; and the above storage medium includes: mobile storage devices, read-only memory (ROM), disks or optical disks, etc. Various media that can store program codes.

[0193] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0194] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A network deployment method, applied to a first device, characterized in that: The method comprises: Obtaining weight data of the network to be deployed; the weight data is used for matrix operations in the inference process; Dividing the weight data into blocks to obtain at least two weight blocks; Compressing the weight elements in the at least two weight blocks to obtain at least two compressed weight blocks; The at least two compressed weight blocks are sent to the second device to complete the deployment of the network to be deployed.

2. The method according to claim 1, characterized in that The step of compressing the weight elements in the at least two weight blocks to obtain at least two compressed weight blocks includes: Determining an exponent part and a mantissa part of each of the weight elements in the weight block; Compressing each of the rank code parts to obtain each compressed rank code part and a corresponding compressed bit number mark code; The compressed weight block is obtained based on the mantissa part, the compressed exponent part and the corresponding compressed bit number mark code of each weight element in the weight block.

3. The method according to claim 2, characterized in that The step of compressing each of the rank code parts to obtain each compressed rank code part and a corresponding compressed bit number mark code comprises: Obtaining the minimum number of bits corresponding to each of the order code parts; Determining a target number of bits for each of the octave parts based on a minimum number of bits corresponding to each of the octave parts; Each of the order code parts is compressed using the target bit number of each order code part to obtain each compressed order code part and a corresponding compressed bit number mark code.

4. The method according to claim 1, characterized in that: The weight data is divided into blocks to obtain at least two weight blocks, including: The weight data is divided into blocks according to a block strategy to obtain at least two weight blocks.

5. The method according to claim 4, characterized in that The method further comprises: In the case where the network to be deployed is a multi-size network, obtaining a preset block strategy corresponding to each single-size network; the multi-size network includes at least two of the single-size networks; Obtaining the time consumption corresponding to each of the single-size networks under each of the preset block strategies; Determine the comprehensive time consumption of each of the block strategies based on the time consumption corresponding to each of the single-size networks and the usage frequency of each of the single-size networks; The preset block strategy with the minimum comprehensive time consumption is determined as the block strategy.

6. The method according to claim 4, characterized in that The weight data is divided into blocks to obtain at least two weight blocks, including: When the network to be deployed is a single-size network, obtaining matrix operation parameters corresponding to the weight data; The block strategy is determined based on the matrix operation parameters corresponding to the weight data and the minimum computing unit of the first device.

7. A network deployment method, applied to a second device, characterized in that: The method comprises: Receiving at least two compressed weight blocks sent by the first device, and decompressing the at least two compressed weight blocks to obtain at least two uncompressed weight blocks; The corresponding network to be deployed is deployed using the at least two weight blocks before compression.

8. The method according to claim 7, characterized in that The second device is used to process the receiving process and decompression process of at least two compressed weight blocks in parallel based on a multi-stage pipeline mode; the second device includes a receiving unit and a decompression unit; the receiving at least two compressed weight blocks sent by the first device, and decompressing the at least two compressed weight blocks to obtain at least two uncompressed weight blocks, including: The i-th compressed weight block is received by the receiving unit, and the i-1-th compressed weight block is decompressed by the decompression unit, where i is a positive integer.

9. The method according to claim 7, characterized in that: The compressed weight block includes: the mantissa part of each weight element in the weight block before compression, the compressed exponent part and the corresponding compressed bit number mark code; the decompression of at least two compressed weight blocks to obtain at least two weight blocks before compression includes: Restoring the compressed exponent part of each weight element based on the compressed bit number mark code of each weight element to obtain the exponent part of each weight element; Based on the exponent part and the mantissa part of each of the weight elements, the weight block before compression is obtained.

10. A network deployment system, characterized in that: The system comprises a first device and a second device; wherein, The first device is used to obtain weight data of the network to be deployed; the weight data is used for matrix operations in the inference process; the weight data is divided into blocks to obtain at least two weight blocks; the weight elements in the at least two weight blocks are compressed to obtain at least two compressed weight blocks; and the at least two compressed weight blocks are sent to the second device; The second device is used to receive at least two compressed weight blocks sent by the first device, and decompress the at least two compressed weight blocks to obtain at least two uncompressed weight blocks; and use the at least two uncompressed weight blocks to deploy the corresponding network to be deployed.