Decoding method and device, electronic device, and computer-readable storage medium
By performing parallel decoding of Huffman coding sequences on the chip and using model training such as neural networks to achieve parallel decoding, the delay problem of Huffman coding and decoding on GPUs and brain-like chips is solved, and the decoding efficiency and speed are improved.
Patent Information
- Application Number
- CN202410636569.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-05-22
AI Technical Summary
Huffman coding and decoding are difficult to adapt to vector matrix computing units such as GPUs and brain-like chips, resulting in high decoding delays and time costs, which offset the performance advantages brought by data compression.
The on-chip decoding model is used for on-chip parallel decoding, the Huffman encoding sequence is decoded in parallel, and model training such as neural networks is used to achieve parallel decoding capabilities.
The decoding delay is reduced, the decoding speed in large model bandwidth compression scenarios is improved, and the decoding efficiency is improved.
Smart Images

Figure CN118249817B
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of decoding technology, and in particular to a decoding method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Huffman coding is an entropy coding method that determines a variable-length coding table based on the statistical characteristics of the data to achieve lossless data compression. Huffman coding is widely used in computer network transmission of files such as pictures to reduce bandwidth requirements.
[0003] However, Huffman decoding is generally serial, and this decoding method is generally difficult to adapt to vector matrix computing units that are widely equipped with GPUs (Graphical Processing Units) and brain-like chips. Therefore, the decoding scheme of Huffman coding will incur a large additional time cost, which will offset part of the performance advantages brought by the compressed bandwidth. Summary of the invention
[0004] The embodiments of the present disclosure provide a decoding method and device, an electronic device, and a computer-readable storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a decoding method, the decoding method comprising:
[0006] Acquire multiple coding sequences based on Huffman coding; the multiple coding sequences are obtained by segmenting the data to be encoded and encoding the multiple segments respectively;
[0007] loading the plurality of coding sequences onto a chip;
[0008] Using the decoding model on the chip, the multiple coding sequences are decoded in parallel on the chip, and the multiple codes within each coding sequence are decoded in parallel;
[0009] The decoding model is a model with parallel decoding capability obtained by training or fitting based on multiple coding sequence samples; the multiple coding sequence samples are obtained by segmenting the data samples to be encoded and then encoding the multiple segments separately.
[0010] In a second aspect, the present disclosure provides a decoding device, the decoding device comprising:
[0011] An acquisition module, used to acquire multiple coding sequences based on Huffman coding; the multiple coding sequences are obtained by segmenting the data to be encoded and then encoding the multiple segments respectively;
[0012] A loading module, used for loading the plurality of coding sequences onto a chip;
[0013] A decoding module, used to use the decoding model on the chip to perform on-chip parallel decoding on the multiple coding sequences, and to perform parallel decoding on multiple codes within each coding sequence;
[0014] The decoding model is a model with parallel decoding capability obtained by training or fitting based on multiple coding sequence samples; the multiple coding sequence samples are obtained by segmenting the data samples to be encoded and then encoding the multiple segments separately.
[0015] In a third aspect, the present disclosure provides an electronic device, including:
[0016] multiple processing cores; and
[0017] An on-chip network is configured to exchange data between the multiple processing cores and external data; wherein one or more instructions are stored in one or more of the processing cores, and one or more of the instructions are executed by one or more of the processing cores, so that one or more of the processing cores can execute the decoding method.
[0018] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned decoding method when executed by a processor / processing core.
[0019] The embodiments provided by the present disclosure use a decoding model on a chip to perform on-chip parallel decoding on multiple coding sequences obtained through Huffman coding, and to perform parallel decoding on multiple codes within each coding sequence, thereby realizing parallel decoding of Huffman coding sequences, thereby reducing decoding delay and improving decoding speed in scenarios such as large model bandwidth compression.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0022] Figure 1 A flowchart of a decoding method provided by an embodiment of the present disclosure;
[0023] Figure 2 A schematic diagram of a decoding method provided by an embodiment of the present disclosure;
[0024] Figure 3 A block diagram of a decoding device provided in an embodiment of the present disclosure;
[0025] Figure 4 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0027] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0028] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0029] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0030] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0031] When deploying a large language model on a chip, especially on an edge chip for inference, the token generation process is mainly serial. This means that every time a token is generated, the entire model weight and other parameters need to be loaded from the memory (video memory) to the chip once. As a result, when a token is generated serially, the memory data transmission bandwidth is much larger than the amount of computation. Therefore, the memory transmission bandwidth is the main bottleneck for improving the inference speed.
[0032] In addition, Huffman coding can be used to compress neural network weights, thereby reducing bandwidth requirements. For example, the information content of chatglm3 weights accounts for about 72% of its storage capacity, so there is potential for compression.
[0033] However, Huffman decoding is generally serial, and the decoding method is generally difficult to adapt to the vector-matrix multiplication computing units that are widely equipped in GPUs (Graphical Processing Units) and brain-like chips. Therefore, the on-chip decoding solution of Huffman coding will incur a large additional time cost, which will offset part of the performance advantages brought by the compressed bandwidth.
[0034] At present, the basic Huffman decoding method is to compare the encoded data bit by bit according to the binary tree constructed according to the encoding table to complete serial decoding. Its main disadvantage is that it is difficult to parallelize, resulting in a long time for decoding long sequences.
[0035] The main disadvantage of the current Huffman decoding is that it is mainly serial and difficult to parallelize. In addition, the decoding method is difficult to adapt to brain-like computing chips or GPUs equipped with large-scale vector-matrix multiplications, making it difficult to use in scenarios such as reducing bandwidth for large model inference.
[0036] The embodiments provided in the present disclosure use a decoding model on a chip to perform on-chip parallel decoding on multiple coding sequences obtained through Huffman coding, and perform parallel decoding on multiple codes within each coding sequence, thereby realizing parallel decoding of Huffman coding sequences, thereby improving decoding efficiency, reducing decoding delay, and increasing decoding speed in scenarios such as large model bandwidth compression.
[0037] The decoding method according to the embodiment of the present disclosure can be executed by an electronic device such as a terminal device or a server. The terminal device can be a vehicle-mounted device, a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The method can be implemented by a processor calling a computer-readable program instruction stored in a memory, or the method can be executed by a server.
[0038] Figure 1 A flowchart of a decoding method provided by an embodiment of the present disclosure. Figure 1 , the method comprises steps S11-S13:
[0039] S11. Acquire multiple coding sequences based on Huffman coding; the multiple coding sequences are obtained by segmenting the data to be encoded and then encoding the multiple segments respectively.
[0040] A Huffman coding table of the data is constructed in advance according to the statistical characteristics of all the data to be encoded and transmitted, including: calculating the number of occurrences (probability) of each character in the data, adding the two smallest numbers of occurrences (probabilities), constructing a binary tree, and using them as the left and right subtrees, repeating this process until the probability value is 1, specifying the left side of each binary tree as 0 and the right side as 1, and sequentially counting the 0s and 1s specified in the path from the top of the binary tree to each character as the Huffman code corresponding to the character, mapping all characters and their corresponding Huffman codes into a table, and obtaining a Huffman coding table.
[0041] In the embodiment of the present disclosure, the data to be encoded may be large model weight data; before obtaining a plurality of encoding sequences based on Huffman coding, the method may further include:
[0042] The large model weight data of each row in the large model weight matrix is respectively used as a data segment to be encoded, and each data segment to be encoded is Huffman encoded to obtain a coding sequence; or,
[0043] The large model weight data in each column of the large model weight matrix is respectively used as a data segment to be encoded, and Huffman encoding is performed on each data segment to be encoded to obtain a coding sequence.
[0044] In the embodiments of the present disclosure, Figure 2 As shown, segmented encoding can be performed for the data to be encoded and transmitted. For example, for the data in a weight matrix, each row of data can be used as a data segment to be encoded, or each column of data can be used as a data segment to be encoded. Huffman encoding is performed on each data segment to obtain a coding sequence. Each coding sequence is a sequence composed of 0 and / or 1, which can be referred to as a 0 / 1 sequence.
[0045] In the embodiment of the present disclosure, before loading the plurality of coding sequences onto the chip, the method may further include:
[0046] Obtaining a first coding sequence with the longest length among multiple coding sequences;
[0047] According to the length of the first coding sequence, the second coding sequences other than the first coding sequence in the multiple coding sequences are padded with bits.
[0048] In the disclosed embodiment, the lengths of the multiple 0 / 1 sequences obtained after encoding may be padded according to the 0 / 1 sequence with the longest length among all 0 / 1 sequences.
[0049] In the embodiment of the present disclosure, the second coding sequence other than the first coding sequence in the plurality of coding sequences is padded with bits according to the length of the first coding sequence, including:
[0050] The second coding sequence is supplemented with 0 and / or 1 according to the length of the first coding sequence.
[0051] In the disclosed embodiment, when padding the length, the last few bits of the 0 / 1 sequence may be padded with all 0s, or all 1s, or a combination of 0 and 1. The detailed padding method is not limited here and can be defined according to the needs. When padding, the padded bits can be clearly distinguished from the original 0 / 1 sequence, so that the decoding model can easily identify the original 0 / 1 sequence to be decoded.
[0052] In the embodiment of the present disclosure, before acquiring multiple coding sequences based on Huffman coding, the method may further include:
[0053] When the data to be encoded is segmented, the difference in the statistical characteristics of each data segment to be encoded is made to be within a preset difference range.
[0054] In the embodiments of the present disclosure, when length padding is performed, in order to minimize the number of padding 0s to reduce invalid transmission, the statistical characteristics of each data segment should be made close as much as possible when the data is segmented (for example, the statistical characteristics of each row (column) of the weight matrix should be close), for example, the data distribution of each segment of data should be close.
[0055] In the embodiments of the present disclosure, the difference range can be defined according to different application scenarios and is not limited here.
[0056] In the embodiment of the present disclosure, for example, when segmenting, statistics are obtained that the large model weight matrix contains data such as 3, 5, 8, and 9, among which the number of 3 and 8 is large, and the number of 5 and 9 is small. Moreover, if segmentation is performed according to each row of the large model weight matrix, the proportion of 3 and 8 in each row of the large model weight data will be more than 95%, and the proportion of 5 and 9 will be less than 5%. For example, the proportion of 3 and 8 in the first row of the large model weight data is 97%, the proportion of 3 and 8 in the second row of the large model weight data is 96%, and the proportion of 3 and 8 in the third row of the large model weight data is 98%. Therefore, the difference range can be determined as 1%-3%. At this time, when the data in the large model weight matrix is segmented by row, the statistical characteristic difference of each data segment to be encoded is within the preset difference range. On the contrary, if the large model weight matrix is segmented according to each column, the proportion of 3 and 8 in the large model weight data of some columns will be about 90%, and the proportion of 5 and 9 will be about 10%. The large model weight data of some columns will have a proportion of 3 and 8 and a proportion of 5 and 9 of about 50%. Therefore, the statistical characteristics of the columns are too different, and the length difference between the data segments is too large, which is not conducive to length filling. Therefore, avoid segmenting according to each column of the large model weight matrix.
[0057] S12. Load multiple coding sequences onto the chip.
[0058] In the embodiment of the present disclosure, based on the on-chip decoding of the decoding model, multiple coding sequences obtained after segmented coding can be loaded onto the chip and decoded in parallel using the decoding model.
[0059] S13. Using a decoding model on the chip, perform on-chip parallel decoding on multiple coding sequences, and perform parallel decoding on multiple codes within each coding sequence; wherein the decoding model is a model with parallel decoding capability obtained by training or fitting multiple coding sequence samples; and the multiple coding sequence samples are obtained by segmenting the data samples to be encoded and then encoding the multiple segments separately.
[0060] In the embodiments of the present disclosure, the decoding model may include but is not limited to a neural network, which can be used to perform any one of image processing tasks, speech processing tasks, text processing tasks, and video processing tasks.
[0061] In the disclosed embodiment, the decoding model can be any model that can perform parallel decoding calculations, data-driven training, and has a small number of parameters. Data-driven refers to the collection of massive amounts of data through the Internet or other related software, organizing the data into itinerary information, and then integrating and refining the relevant information. An automated decision-making model is formed through training and fitting based on the data. In short, it is to make decisions and actions based on data. Among them, in the fields of statistics and machine learning, fitting refers to finding suitable model parameters or function forms so that the model can better describe or predict the characteristics and trends of the data on a given data set. Fitting can be performed by different methods, such as least squares, maximum likelihood estimation, or gradient descent. In the fitting process, different models or function forms are usually tried, and the difference between the model and the data is minimized by adjusting the parameters. The goal of fitting is to find a model that performs well on the entire data set and can be generalized to new data.
[0062] In the embodiment of the present disclosure, when the decoding model includes a neural network, a decoding model on a chip is used to perform on-chip parallel decoding on multiple coding sequences, and to perform parallel decoding on multiple codes within each coding sequence, which may include:
[0063] Multiple encoded sequences are input into one or more neural networks for parallel decoding.
[0064] In the embodiments of the present disclosure, the neural network may include but is not limited to a convolutional neural network, and any other neural network capable of implementing a decoding function may be included in the protection scope of the neural network of the present disclosure.
[0065] In the embodiment of the present disclosure, when the neural network is a one-dimensional neural network, the decoding model may include multiple one-dimensional neural networks; inputting multiple encoding sequences into one or more neural networks for parallel decoding includes:
[0066] Input multiple encoding sequences into multiple one-dimensional neural networks respectively;
[0067] Each one-dimensional neural network decodes a coding sequence respectively, and multiple codes within the corresponding coding sequence are decoded in parallel within each one-dimensional neural network, thereby achieving parallel decoding of multiple coding sequences.
[0068] In the embodiment of the present disclosure, each coding sequence is one-dimensional data, and a one-dimensional neural network can only process one one-dimensional data in the same time period. Therefore, for multiple coding sequences, multiple one-dimensional neural networks can be used to process them simultaneously, thereby achieving the purpose of parallel decoding.
[0069] In the embodiments of the present disclosure, since many neural networks have good parallel computing performance, such as one-dimensional convolutional networks, multiple codes within the corresponding coding sequence can be decoded in parallel within each one-dimensional neural network, thereby realizing a dual parallel decoding scheme of parallel decoding of multiple coding sequences and parallel decoding of multiple codes within each coding sequence, thereby improving decoding efficiency.
[0070] In the embodiment of the present disclosure, when the neural network is a multi-dimensional neural network, multiple encoding sequences are input into one or more neural networks for parallel decoding, including:
[0071] Input multiple encoding sequences into a multidimensional neural network;
[0072] Multiple coding sequences are decoded in parallel through a multi-dimensional neural network, and multiple codes within the corresponding coding sequence are decoded in parallel within each dimensional neural network.
[0073] In the disclosed embodiment, one-dimensional coding sequences in multiple coding sequences can be decoded by one-dimensional neural networks in the multidimensional neural network, respectively, to achieve parallel decoding of multiple coding sequences by the multidimensional neural network. Each dimensional neural network can also have parallel decoding capabilities. For example, each dimensional neural network can have a structure similar to a one-dimensional convolutional network, to achieve parallel decoding of multiple codes within the corresponding coding sequence within each dimensional neural network.
[0074] In the embodiments of the present disclosure, the neural network may include but is not limited to a convolutional neural network. For example, it may be a one-dimensional convolutional neural network. Multiple coding sequences may be decoded in parallel by multiple identical one-dimensional convolutional neural networks.
[0075] In the disclosed embodiment, the advantages of using a one-dimensional convolutional neural network for decoding include:
[0076] 1. Due to weight sharing, the one-dimensional convolutional neural network has fewer parameters, resulting in less additional transmission cost.
[0077] 2. Multiple one-dimensional convolutional neural networks can be calculated in parallel, so that parallel decoding can be completed, and the convolution operation is highly optimized on brain-like chips or GPUs, so it is highly efficient.
[0078] 3. In the large-model bandwidth compression scenario, the amount of computation brought about will not result in a significant cost, because the computational cost of generating a token is relatively low (hundreds of GFLOPS (Giga Floating-point Operations Per Second), and the chip generally has tens of TFLOPS (Floating-point operations per second), and the on-chip computing resources can complete these decoding calculations.
[0079] 4. The design of neural networks needs to deal with the problem of coding alignment. Since the statistical characteristics of the coding stream (i.e., coding sequence) are basically uniform, the coding stream input to the network and the output decoding result are roughly corresponding in position. Therefore, this characteristic of the Huffman coding sequence is suitable for processing by neural networks, especially convolutional neural networks.
[0080] In an embodiment of the present disclosure, on the basis that the decoding model includes a neural network, the neural network may include but is not limited to a residual connection layer and / or a batch normalization layer to achieve computational optimization of the neural network.
[0081] When an input x is forcibly added to the output F(x) of the function, although G(x) can still be used to describe the relationship between the input and the output, this G(x) can be clearly split into the linear superposition of F(x) and x. This is the idea of the skip connect, which expresses the output as the linear superposition of the input and a nonlinear transformation of the input. The role of the skip connect is to solve the gradient vanishing and gradient exploding problems, and can also help the model converge faster. Residual connections are usually used in neural networks with multiple layers, such as residual networks (ResNet) and deformable convolutional networks (DenseNet).
[0082] Batch Normalization (BN) is an algorithm designed to overcome the difficulty of training caused by the deepening of the number of neural network layers. When the distribution of the sample data of the training set is inconsistent with that of the target sample set, the trained model cannot generalize well. When the number of neural network layers increases during training, the overall distribution of the input value of the activation function gradually approaches the upper and lower limits of the activation function's value range, resulting in the disappearance of the gradient of the shallow neural network during back propagation. The role of batch normalization is to pull the increasingly biased distribution back to the standardized distribution through normalization, so that the input value of the activation function falls in the area where the activation function is more sensitive to the input, thereby increasing the gradient, accelerating the learning convergence speed, and avoiding the problem of gradient disappearance.
[0083] In the embodiment of the present disclosure, when the decoding model includes a neural network, before using the decoding model on the chip to perform on-chip parallel decoding on multiple coding sequences and performing parallel decoding on multiple codes within each coding sequence, the method may further include:
[0084] Use multiple encoding sequences as training data to train the neural network;
[0085] When the loss value of the neural network meets the preset conditions, the decoding model is obtained.
[0086] In the disclosed embodiment, in order to ensure that the neural network completes the correct decoding function, the neural network needs to be trained. For example, a training set can be obtained based on all the data to be compressed for training, that is, a coding sequence is obtained after encoding the current data to be compressed, and these coding sequences are used as training data, and the neural network does not need to have the ability to generalize other data, because only the group of data (such as the weight data of a network) needs to be decoded. The neural network can also be trained with other data so that the neural network has the ability to generalize other data.
[0087] In the embodiment of the present disclosure, the data sample to be encoded may include a large model weight data sample; the multiple encoding sequence samples may include multiple encoding sequences obtained by segmenting the large model weight data sample and then performing Huffman encoding on each segment.
[0088] In the embodiments of the present disclosure, a neural network is trained based on multiple coding sequences obtained from large model weight data samples to obtain a decoding model capable of decoding the large model weight data in parallel. Based on the decoding model, in a large model weight data compression scenario, the large model weight data in the large model weight matrix can be segmented to obtain multiple coding sequences, and the multiple coding sequences can be input into the trained decoding model to quickly obtain decoding results, thereby accelerating the data decoding speed in the large model weight data compression scenario.
[0089] In the disclosed embodiment, since the neural network has a strong fitting ability, a higher decoding accuracy can be obtained. Especially in the compression scenario of the neural network weights such as large models, since the network is robust to the error of the weight value, it is not necessary to guarantee 100% decoding accuracy, so it is suitable to use a neural network approximation solution.
[0090] In the embodiment of the present disclosure, Figure 2The original weight matrix in is used as an example to explain the embodiment of the present disclosure in detail. The original weight matrix contains multiple rows of data: the first row, -8, -2, 4, 3, -9; the second row, 1, 5, -3, -1, 7; the third row, -2, -9, 5, 0, -1; the fourth row, -8, -4, 6, 7, -4; the above data can be segmented by row, each row of data is used as a data segment, and Huffman encoding is performed on each data segment. For example, the data segment -8, -2, 4, 3, -9 composed of the first row of data is Huffman encoded to obtain the encoding sequence: 01001110. Following the length padding principle, 0 can be aligned and padded after the code sequence 01001110 to obtain the padded encoding sequence 0100111000. The padded encoding sequence 0100111000 is loaded into the chip and decoded by the neural network on the chip to restore the original weight data: -8, -2, 4, 3, -9. The above operations can be performed for each row of data in the original weight matrix (which can be regarded as a data segment respectively), and after obtaining the Huffman-coded coding sequence of each data segment, multiple coding sequences are loaded onto the chip and decoded in parallel through the neural network, thereby increasing the parallelism of Huffman decoding, reducing decoding delay, and improving the decoding speed in scenarios such as large model bandwidth compression.
[0091] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0092] In addition, the present disclosure also provides a decoding device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any decoding method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to in the corresponding records of the method part and will not be repeated here.
[0093] Figure 3 A block diagram of a decoding device provided in an embodiment of the present disclosure.
[0094] Reference Figure 3 , the embodiment of the present disclosure provides a decoding device 300, which may include:
[0095] The acquisition module 301 is used to acquire multiple coding sequences based on Huffman coding; the multiple coding sequences are obtained by segmenting the data to be encoded and encoding the multiple segments respectively;
[0096] A loading module 302, used to load multiple coding sequences onto the chip;
[0097] The decoding module 303 is used to use the decoding model on the chip to perform on-chip parallel decoding on multiple coding sequences and to perform parallel decoding on multiple codes within each coding sequence;
[0098] The decoding model is a model with parallel decoding capability obtained by training or fitting multiple coding sequence samples; the multiple coding sequence samples are obtained by segmenting the data samples to be encoded and then encoding the multiple segments separately.
[0099] Figure 4 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0100] Reference Figure 4 An embodiment of the present disclosure provides an electronic device, which includes multiple processing cores 401 and an on-chip network 402, wherein the multiple processing cores 401 are connected to the on-chip network 402, and the on-chip network 402 is used to exchange data between the multiple processing cores and external data.
[0101] One or more instructions are stored in one or more processing cores 401 , and the one or more instructions are executed by one or more processing cores 401 , so that the one or more processing cores 401 can execute the above decoding method.
[0102] In some embodiments, the electronic device may be a brain-like chip, and since the brain-like chip can use vectorized computing and needs to load the weight information and other parameters of the neural network model through an external memory such as a double data rate (DDR) synchronous dynamic random access memory, the batch processing in the disclosed embodiment has a higher computing efficiency.
[0103] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above decoding method when executed by a processor / processing core. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0104] The embodiment of the present disclosure also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above decoding method.
[0105] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a transient medium).
[0106] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable program instructions, data structures, program modules or other data. Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is known to those of ordinary skill in the art, communication media typically contain computer readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0107] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0108] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet). In some embodiments, by using the state information of the computer-readable program instructions to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit may execute the computer-readable program instructions, thereby implementing various aspects of the present disclosure.
[0109] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0110] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0111] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0112] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0113] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0114] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A decoding method, characterized in that: The method comprises: Acquire multiple coding sequences based on Huffman coding; the multiple coding sequences are obtained by segmenting the data to be encoded and encoding the multiple segments respectively; the data to be encoded includes: large model weight data; loading the plurality of coding sequences onto a chip; Using the decoding model on the chip, the multiple coding sequences are decoded in parallel on the chip, and the multiple codes within each coding sequence are decoded in parallel; Among them, the decoding model is a model with parallel decoding capability obtained by training or fitting based on multiple coding sequence samples; the multiple coding sequence samples are obtained by segmenting the data samples to be encoded and then encoding the multiple segments separately; the multiple coding sequence samples are obtained after encoding the current data to be compressed, and the decoding model does not need to have the ability to generalize data other than the current data to be compressed; the decoding model includes a neural network; the neural network is used to perform any one of image processing tasks, speech processing tasks, text processing tasks, and video processing tasks.
2. The decoding method according to claim 1, characterized in that: The adopting the decoding model on the chip to perform on-chip parallel decoding on the multiple coding sequences and to perform parallel decoding on the multiple codes within each coding sequence comprises: The multiple encoded sequences are input into one or more neural networks for parallel decoding.
3. The decoding method according to claim 2, characterized in that: The neural network is a one-dimensional neural network, and the decoding model includes a plurality of the one-dimensional neural networks; The step of inputting the plurality of encoding sequences into one or more neural networks for parallel decoding comprises: Inputting the plurality of encoding sequences into the plurality of one-dimensional neural networks respectively; Each of the one-dimensional neural networks decodes one of the coding sequences respectively, and multiple codes within the corresponding coding sequence are decoded in parallel within each of the one-dimensional neural networks, thereby achieving parallel decoding of the multiple coding sequences.
4. The decoding method according to claim 2, characterized in that: The neural network is a multidimensional neural network; The step of inputting the plurality of encoding sequences into one or more neural networks for parallel decoding comprises: Inputting the plurality of encoding sequences into the multidimensional neural network; The multiple coding sequences are decoded in parallel by the multi-dimensional neural network, and the multiple codes within the corresponding coding sequences are decoded in parallel within each dimensional neural network.
5. The decoding method according to claim 2, characterized in that: The neural network includes a convolutional neural network.
6. The decoding method according to claim 1, characterized in that: Before loading the plurality of coding sequences onto the chip, the method further comprises: Obtaining a first coding sequence with the longest length among the multiple coding sequences; According to the length of the first coding sequence, the second coding sequences other than the first coding sequence in the multiple coding sequences are padded with bits.
7. The decoding method according to claim 1, characterized in that: Before obtaining a plurality of coding sequences based on Huffman coding, the method further comprises: When the data to be encoded is segmented, the difference in statistical characteristics of each data segment to be encoded is made to be within a preset difference range.
8. The decoding method according to claim 1, characterized in that: The decoding model includes a neural network; before using the decoding model on the chip to perform on-chip parallel decoding on the multiple coding sequences and performing parallel decoding on multiple codes within each coding sequence, the method further includes: Using the plurality of coding sequence samples as training data, training the neural network; When the loss value of the neural network meets a preset condition, the decoding model is obtained.
9. The decoding method according to claim 8, characterized in that: The data samples to be encoded include: large model weight data samples; The multiple coding sequence samples include: multiple coding sequences obtained by segmenting the large model weight data sample and performing Huffman coding on each segment respectively.
10. The decoding method according to claim 1 or 9, characterized in that: The data to be encoded is large model weight data; Before obtaining a plurality of coding sequences based on Huffman coding, the method further comprises: The large model weight data of each row in the large model weight matrix is respectively used as a data segment to be encoded, and each of the data segments to be encoded is Huffman encoded to obtain a coding sequence; or, The large model weight data in each column of the large model weight matrix is respectively used as a data segment to be encoded, and Huffman encoding is performed on each of the data segments to be encoded to obtain a coding sequence.
11. A decoding device, characterized in that: include: An acquisition module, used for acquiring multiple coding sequences based on Huffman coding; The multiple coding sequences are obtained by segmenting the data to be encoded and encoding the multiple segments respectively; The data to be encoded includes: large model weight data; A loading module, used for loading the plurality of coding sequences onto a chip; A decoding module, used to use the decoding model on the chip to perform on-chip parallel decoding on the multiple coding sequences, and to perform parallel decoding on multiple codes within each coding sequence; Among them, the decoding model is a model with parallel decoding capability obtained by training or fitting based on multiple coding sequence samples; the multiple coding sequence samples are obtained by segmenting the data samples to be encoded and then encoding the multiple segments separately; the multiple coding sequence samples are obtained after encoding the current data to be compressed, and the decoding model does not need to have the ability to generalize data other than the current data to be compressed; the decoding model includes a neural network; the neural network is used to perform any one of image processing tasks, speech processing tasks, text processing tasks, and video processing tasks.
12. An electronic device, characterized in that: include: Multiple processing cores; as well as An on-chip network is configured to exchange data between the multiple processing cores and external data; wherein one or more instructions are stored in one or more of the processing cores, and one or more of the instructions are executed by one or more of the processing cores, so that one or more of the processing cores can execute the decoding method described in any one of claims 1-10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the decoding method according to any one of claims 1 to 10.
