Data processing method, device and related products

By using descriptors in the processor to indicate tensor shapes, data conflicts between instructions are quickly determined, which solves the problem of low processing efficiency in the existing technology when processing large-scale data, and achieves efficient data processing.

CN113807507BActive Publication Date: 2024-09-27ANHUI CAMBRICON INFORMATION TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202010547359.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-16
Publication Date
2024-09-27
Estimated Expiration
2040-06-16

AI Technical Summary

Technical Problem

When the existing technology processes large-scale data, it is necessary to frequently set data access parameters and determine data conflicts between instructions, resulting in a reduction in processor processing efficiency.

Method used

By introducing descriptors to indicate the shape of the tensor, we can quickly determine whether there is a data conflict between instructions, realize the instruction reordering function, and improve the processing efficiency of the processor.

Benefits of technology

It effectively reduces the complexity of data access and the processing time of the processor, and improves the processing efficiency of the processor.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113807507B
    Figure CN113807507B
Patent Text Reader

Abstract

The present disclosure relates to a data processing method and device and related products, and the products include a board. The board includes a storage device, an interface device, a control device, and a neural network chip for implementing the data processing method of the present disclosure; wherein the neural network chip is connected to the storage device, the control device, and the interface device, respectively; the storage device is used to store data; the interface device is used to realize data transmission between the neural network chip and an external device; the control device is used to monitor the status of the neural network chip. The present disclosure can improve the computing efficiency of related products when performing operations on neural network models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a data processing method and device and related products. Background Art

[0002] With the continuous development of artificial intelligence technology, the amount of data and data dimensions that need to be processed are constantly increasing. In related technologies, the processor usually determines the data address by obtaining the parameters of the instruction, and then completes the reading and use of the data according to the data address. This requires technicians to set the relevant parameters of data access (such as the relationship between data or data dimensions, etc.) when designing parameters. When judging data conflicts between instructions, conversion is required, which reduces the processing efficiency of the processor. Summary of the invention

[0003] In view of this, the present disclosure proposes a data processing technology solution.

[0004] According to one aspect of the present disclosure, there is provided a data processing method, comprising: obtaining a first descriptor in a first processing instruction operand, the first descriptor comprising a first content, the first content being used to indicate a shape of a tensor;

[0005] determining whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content;

[0006] When it is determined that the first processing instruction is not to be executed, the first processing instruction is blocked or cached.

[0007] According to another aspect of the present disclosure, there is provided a data processing apparatus, comprising: a descriptor acquisition circuit, configured to acquire a first descriptor in a first processing instruction operand, wherein the first descriptor comprises a first content, and the first content is used to indicate a shape of a tensor;

[0008] a determination circuit, configured to determine whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content;

[0009] The execution circuit is used to block or cache the first processing instruction when it is determined that the first processing instruction is not to be executed. According to another aspect of the present disclosure, a neural network chip is provided, and the chip includes the data processing device as described above.

[0010] According to another aspect of the present disclosure, an electronic device is provided, comprising the neural network chip as described above.

[0011] According to another aspect of the present disclosure, a board is provided, which includes: a storage device, an interface device and a control device and the neural network chip as described above; wherein the neural network chip is connected to the storage device, the control device and the interface device respectively; the storage device is used to store data; the interface device is used to realize data transmission between the neural network chip and an external device; the control device is used to monitor the status of the neural network chip.

[0012] According to the embodiments of the present disclosure, by introducing a descriptor indicating the shape of a tensor, it is possible to quickly determine whether there is a data conflict between instructions, efficiently and quickly implement the instruction out-of-order function, and improve the processing efficiency of the processor.

[0013] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0015] Figure 1 A schematic diagram showing a data storage space of a data processing device according to an embodiment of the present disclosure.

[0016] Figure 2 A flow chart of a data processing method according to an embodiment of the present disclosure is shown.

[0017] Figure 3 A block diagram of a data processing device according to an embodiment of the present disclosure is shown.

[0018] Figure 4 A structural block diagram of a board according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0019] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0020] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0021] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present disclosure.

[0022] In one possible implementation, a descriptor can be used to indicate the shape of N-dimensional tensor data, where N is a positive integer, such as N=1, 2, or 3. A tensor can contain multiple forms of data composition, and a tensor can be of different dimensions. For example, a scalar can be regarded as a 0-dimensional tensor, a vector can be regarded as a 1-dimensional tensor, and a matrix can be a 2-dimensional or higher tensor. The shape of a tensor includes information such as the dimension of the tensor and the size of each dimension of the tensor. For example, for a tensor:

[0023]

[0024] The shape of the tensor can be described by the descriptor as (2, 4), that is, the two parameters indicate that the tensor is a two-dimensional tensor, and the size of the first dimension (column) of the tensor is 2, and the size of the second dimension (row) is 4. It should be noted that the present application does not limit the way in which the descriptor indicates the shape of the tensor.

[0025] In one possible implementation, the value of N can be determined according to the dimension (order) of the tensor data, or it can be set according to the usage requirements of the tensor data. For example, when the value of N is 3, the tensor data is three-dimensional tensor data, and the descriptor can be used to indicate the shape of the three-dimensional tensor data in three dimensions (e.g., offset, size, etc.). It should be understood that those skilled in the art can set the value of N according to actual needs, and the present disclosure does not limit this.

[0026] In a possible implementation, the descriptor may include an identifier of the descriptor and / or content of the descriptor. The identifier of the descriptor is used to distinguish the descriptor, for example, the identifier of the descriptor may be a number for it; the content of the descriptor may include at least one shape parameter representing the shape of the tensor data. For example, the tensor data is 3D data, and among the three dimensions of the tensor data, the shape parameters of two dimensions are fixed, and the content of its descriptor may include the shape parameter representing another dimension of the tensor data.

[0027] In one possible implementation, the identifier and / or content of the descriptor may be stored in a descriptor storage space (internal memory), such as a register, an on-chip SRAM, or other media cache. The tensor data indicated by the descriptor may be stored in a data storage space (internal memory or external memory), such as an on-chip cache or an off-chip memory. The present disclosure does not limit the specific locations of the descriptor storage space and the data storage space.

[0028] In one possible implementation, the identifier, content, and tensor data indicated by the descriptor of the descriptor can be stored in the same area of ​​the internal memory. For example, a continuous area of ​​the on-chip cache can be used to store the relevant content of the descriptor, and its address is ADDR0-ADDR1023, wherein the address ADDR0-ADDR63 can be used as a descriptor storage space to store the identifier and content of the descriptor, and the address ADDR64-ADDR1023 can be used as a data storage space to store the tensor data indicated by the descriptor. In the descriptor storage space, the identifier of the descriptor can be stored at address ADDR0-ADDR31, and the content of the descriptor can be stored at address ADDR32-ADDR63. It should be understood that the address ADDR is not limited to 1 bit or one byte, and is used here to represent an address, which is an address unit. Those skilled in the art can determine the descriptor storage space, data storage space, and their specific addresses according to actual conditions, and the present disclosure is not limited to this.

[0029] In one possible implementation, the identifier and content of the descriptor and the tensor data indicated by the descriptor can be stored in different areas of the internal memory. For example, a register can be used as a descriptor storage space to store the identifier and content of the descriptor, and an on-chip cache can be used as a data storage space to store the tensor data indicated by the descriptor.

[0030] In one possible implementation, when a register is used to store the identifier and content of a descriptor, the identifier of the descriptor may be represented by the register number. For example, when the register number is 0, the identifier of the descriptor stored therein is set to 0. When the descriptor in the register is valid, an area may be allocated in the cache space for storing the tensor data according to the size of the tensor data indicated by the descriptor.

[0031] In one possible implementation, the identifier and content of the descriptor may be stored in an internal memory, and the tensor data indicated by the descriptor may be stored in an external memory. For example, the identifier and content of the descriptor may be stored on-chip, and the tensor data indicated by the descriptor may be stored off-chip.

[0032] In one possible implementation, the data address of the data storage space corresponding to each descriptor may be a fixed address. For example, a separate data storage space may be divided for tensor data, and the starting address of each tensor data in the data storage space corresponds to the descriptor one by one. In this case, the execution circuit can determine the data address of the data corresponding to the operand in the data storage space according to the descriptor, and then execute the processing instruction.

[0033] In one possible implementation, when the data address of the data storage space corresponding to the descriptor is a variable address, the descriptor can also be used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor may also include at least one address parameter representing the address of the tensor data. For example, the tensor data is 3D data, and when the descriptor points to the address of the tensor data, the content of the descriptor may include an address parameter representing the address of the tensor data, such as the starting physical address of the tensor data, or may include multiple address parameters of the address of the tensor data, such as the starting address + address offset of the tensor data, or the address parameters of the tensor data based on each dimension. Those skilled in the art may set the address parameters according to actual needs, and the present disclosure does not limit this.

[0034] In a possible implementation, the address parameter of the tensor data may include a reference address of the data reference point of the descriptor in the data storage space of the tensor data. The reference address may be different according to the change of the data reference point. The present disclosure does not limit the selection of the data reference point.

[0035] In a possible implementation, the reference address may include the starting address of the data storage space. When the data reference point of the descriptor is the first data block of the data storage space, the reference address of the descriptor is the starting address of the data storage space. When the data reference point of the descriptor is other data other than the first data block in the data storage space, the reference address of the descriptor is the address of the data block in the data storage space.

[0036] In a possible implementation, the shape parameters of the tensor data include at least one of the following: the size of the data storage space in at least one direction of the N dimensional directions, the size of the storage area in at least one direction of the N dimensional directions, the offset of the storage area in at least one direction of the N dimensional directions, the positions of at least two vertices at diagonal positions in the N dimensional directions relative to the data reference point, and the mapping relationship between the data description position of the tensor data indicated by the descriptor and the data address. The data description position is the mapping position of the point or area in the tensor data indicated by the descriptor. For example, when the tensor data is 3D data, the descriptor can use three-dimensional space coordinates (x, y, z) to represent the shape of the tensor data, and the data description position of the tensor data can be the position of the point or area mapped in the three-dimensional space represented by the three-dimensional space coordinates (x, y, z).

[0037] It should be understood that those skilled in the art may select shape parameters representing tensor data according to actual conditions, and the present disclosure does not limit this.

[0038] By using descriptors in the data access process, associations between data can be established, thereby reducing the complexity of data access and improving instruction processing efficiency.

[0039] In one possible implementation, the content of the descriptor of the tensor data can be determined based on the reference address of the data reference point of the descriptor in the data storage space of the tensor data, the size of the data storage space in at least one of the N dimensional directions, the size of the storage area in at least one of the N dimensional directions, and / or the offset of the storage area in at least one of the N dimensional directions. Figure 1 A schematic diagram showing a data storage space of a data processing device according to an embodiment of the present disclosure is shown. Figure 1 As shown, the data storage space 21 stores two-dimensional data in a row-first manner, which can be represented by (x, y) (where the X axis is horizontal to the right and the Y axis is vertically downward), the size in the X axis direction (the size of each row) is ori_x (not shown in the figure), the size in the Y axis direction (the total number of rows) is ori_y (not shown in the figure), and the starting address PA_start (reference address) of the data storage space 21 is the physical address of the first data block 22. The data block 23 is part of the data in the data storage space 21, and its offset 25 in the X axis direction is represented by offset_x, the offset 24 in the Y axis direction is represented by offset_y, the size in the X axis direction is represented by size_x, and the size in the Y axis direction is represented by size_y.

[0040] In a possible implementation, when a descriptor is used to define the data block 23, the data reference point of the descriptor can use the first data block of the data storage space 21, and the reference address of the descriptor can be agreed to be the starting address PA_start of the data storage space 21. Then, the content of the descriptor of the data block 23 can be determined by combining the size ori_x of the data storage space 21 on the X axis, the size ori_y on the Y axis, the offset offset_y of the data block 23 in the Y axis direction, the offset offset_x in the X axis direction, the size size_x in the X axis direction, and the size size_y in the Y axis direction.

[0041] In a possible implementation, the following formula (1) may be used to represent the content of the descriptor:

[0042]

[0043] It should be understood that, although in the above examples, the content of the descriptor represents a two-dimensional space, those skilled in the art may set the specific dimension represented by the content of the descriptor according to actual conditions, and the present disclosure does not limit this.

[0044] In one possible implementation, a reference address of the data reference point of the descriptor in the data storage space can be agreed upon, and based on the reference address, the content of the descriptor of the tensor data is determined according to the positions of at least two vertices at diagonal positions in N dimensional directions relative to the data reference point.

[0045] For example, the reference address PA_base of the data reference point of the descriptor in the data storage space can be agreed upon. For example, a data (e.g., data at position (2, 2)) can be selected in the data storage space 21 as the data reference point, and the physical address of the data in the data storage space is used as the reference address PA_base. The position of the two vertices at the diagonal position relative to the data reference point can be used to determine the reference address PA_base. Figure 1 The content of the descriptor of the data block 23 in the data block 23. First, the positions of at least two vertices at the diagonal positions of the data block 23 relative to the data reference point are determined, for example, the positions of the diagonal vertices from the upper left to the lower right direction relative to the data reference point are used, wherein the relative position of the upper left vertex is (x_min, y_min), and the relative position of the lower right vertex is (x_max, y_max), and then the content of the descriptor of the data block 23 can be determined according to the reference address PA_base, the relative position of the upper left vertex (x_min, y_min), and the relative position of the lower right vertex (x_max, y_max).

[0046] In a possible implementation, the following formula (2) may be used to represent the content of the descriptor (the base address is PA_base):

[0047]

[0048] It should be understood that although the above example uses the vertices at the upper left corner and the lower right corner to determine the content of the descriptor, those skilled in the art can set the specific vertices of at least two vertices at the diagonal positions according to actual needs, and the present disclosure does not limit this.

[0049] In a possible implementation, the content of the descriptor of the tensor data can be determined according to the reference address of the data reference point of the descriptor in the data storage space and the mapping relationship between the data description position and the data address of the tensor data indicated by the descriptor. The mapping relationship between the data description position and the data address can be set according to actual needs. For example, when the tensor data indicated by the descriptor is three-dimensional space data, the function f(x, y, z) can be used to define the mapping relationship between the data description position and the data address.

[0050] In a possible implementation, the following formula (3) may be used to represent the content of the descriptor:

[0051]

[0052] In a possible implementation, the first descriptor and the second descriptor are also used to indicate the address of N-dimensional tensor data, wherein the contents of the first descriptor and the second descriptor also include at least one address parameter representing the address of the tensor data.

[0053] The first descriptor or the second descriptor may further include at least one address parameter representing the address of the tensor data. For example, the first content or the second content may be:

[0054]

[0055] Wherein PA is an address parameter of the first content or the second content. The address parameter may be a logical address or a physical address. The descriptor parsing circuit may use PA as any vertex, middle point or preset point of the vector shape, and combine the shape parameters in the X direction and the Y direction to obtain the corresponding data address.

[0056] In a possible implementation, the address parameter of the tensor data includes a reference address of a data reference point of the descriptor in a data storage space of the tensor data, and the reference address includes a starting address of the data storage space.

[0057] In a possible implementation, the first descriptor or the second descriptor may further include at least one address parameter representing the address of the tensor data. For example, the first content or the second content may be:

[0058]

[0059] Among them, PA_start is the reference address parameter and will not be repeated here.

[0060] It should be understood that those skilled in the art may set the mapping relationship between the data description location and the data address according to actual conditions, and the present disclosure does not limit this.

[0061] In a possible implementation, an agreed reference address can be set in a task, and the descriptors in the instructions under this task all use this reference address, and the content in the descriptor content may include shape parameters based on this reference address. This reference address can be determined by setting the environmental parameters of this task. The relevant description and use of the reference address can be found in the above embodiment. In this implementation, the content of the descriptor can be mapped to a data address more quickly.

[0062] In a possible implementation, the reference address may be included in the content of each descriptor, and the reference address of each descriptor may be different. Compared with the method of setting a common reference address using environmental parameters, each descriptor in this method can describe data more flexibly and use a larger data address space.

[0063] In a possible implementation, the data address of the data corresponding to the operand of the processing instruction in the data storage space can be determined according to the content of the descriptor. The calculation of the data address is automatically completed by hardware, and the calculation method of the data address will be different when the content of the descriptor is expressed in different ways. The present disclosure does not limit the specific calculation method of the data address.

[0064] For example, the content of the descriptor in the operand is expressed using formula (1). The offsets of the tensor data indicated by the descriptor in the data storage space are offset_x and offset_y, respectively, and the size is size_x*size_y. Then, the starting data address PA1 of the tensor data indicated by the descriptor in the data storage space is (x,y) It can be determined using the following formula (4):

[0065] PA1 (x,y) =PA_start+(offset_y-1)*ori_x+offset_x (4)

[0066] The data starting address PA1 is determined according to the above formula (4) (x,y), combined with the offsets offset_x and offset_y, and the sizes size_x and size_y of the storage area, the storage area of ​​the tensor data indicated by the descriptor in the data storage space can be determined.

[0067] In one possible implementation, when the operand also includes a data description position for the descriptor, the data address of the data corresponding to the operand in the data storage space can be determined according to the content of the descriptor and the data description position. In this way, part of the data (e.g., one or more data) in the tensor data indicated by the descriptor can be processed.

[0068] For example, the content of the descriptor in the operand is expressed using formula (1). The offsets of the tensor data indicated by the descriptor in the data storage space are offset_x and offset_y, respectively, and the size is size_x*size_y. The data description position for the descriptor included in the operand is (x q ,y q ), then the data address PA2 of the tensor data indicated by the descriptor in the data storage space (x,y) It can be determined using the following formula (5):

[0069] PA2 (x,y) =PA_start+(offset_y+y q -1)*ori_x+(offset_x+x q ) (5)

[0070] In a possible implementation, a second descriptor may be created for a task, and the second descriptor is stored in the descriptor storage space, and is used to indicate a larger tensor or a tensor set used by the task, and the tensor or tensor set corresponding to the second descriptor may be stored in the data storage area. The operand in the instruction under this task may include the first descriptor. The first descriptor may extract the data address corresponding to the operand based on the second descriptor. The data address corresponding to the operand may be obtained according to the shape parameter in the first descriptor and the shape parameter in the second descriptor. For example, the first descriptor may include a reference address, and the second descriptor may include the shape parameter of each operand. The data address of the operand corresponding to each second descriptor may be obtained according to the above embodiment according to the reference address parameter and the shape parameter in each second descriptor. It is also possible to give a reference address by creating an environment parameter, and the shape parameter in the first descriptor gives a larger tensor, and each second descriptor intercepts data based on the first descriptor. In this way, since the data corresponding to the first descriptor has been stored in the data storage area, the operand required for the instruction under this task does not need to be transferred on-chip or off-chip, which can reduce the data IO bottleneck.

[0071] In one possible implementation, the operand also includes an identifier of a first descriptor, and the descriptor parsing circuit is further configured to determine a second descriptor corresponding to the first descriptor in the descriptor storage space based on the identifier of the first descriptor, and determine a data address in the data storage space of data corresponding to the operand of the processing instruction based on a first content of the first descriptor and a second content of the second descriptor.

[0072] In one possible implementation, multiple second descriptors can be created for a task, and each second descriptor can be distinguished by an identifier. The operand in the instruction under this task may include a first descriptor and may also include an identifier of a second descriptor corresponding to the first descriptor. In this way, the shape of the tensor described by the first descriptor may be smaller than the shape of the tensor described by the corresponding second descriptor. The shape of the tensor described by the first descriptor may also be different from the shape of the tensor described by the corresponding second descriptor but overlap.

[0073] In a possible implementation, the first descriptor may have at least one shape parameter identical to that in the corresponding second descriptor, and the identical shape parameter may not be given in the first descriptor, and only different shape parameters may be given.

[0074] Figure 2 FIG. 1 is a flow chart showing a data processing method according to an embodiment of the present disclosure. Figure 2 As shown, the data processing method includes:

[0075] Step S11, obtaining a first descriptor in a first processing instruction operand, wherein the first descriptor includes a first content, and the first content is used to indicate a shape of a tensor;

[0076] Step S12, determining whether to execute the first processing instruction according to the operand of the second processing instruction in the instruction queue that is not completed before the first processing instruction and the first content;

[0077] Step S13: When it is determined that the first processing instruction is not to be executed, the first processing instruction is blocked or cached.

[0078] In a possible implementation, the data processing method may be applied to a processor, which may include a general-purpose processor (such as a central processing unit (CPU) or a graphics processing unit (GPU)) and a special-purpose processor (such as an artificial intelligence processor, a scientific computing processor, or a digital signal processor, etc.). The present disclosure does not limit the type of processor.

[0079] In one possible implementation, the data address of the data corresponding to the operand of the first processing instruction can be determined according to the parameters used to describe the shape of the tensor in the first content. The operand of the unfinished second processing instruction can be in the form of a traditional data address. It can be determined whether there is a data conflict between the first processing instruction and the second processing instruction based on the data address determined by the first content and the data address in the operand of the unfinished second processing instruction. If there is a data conflict, it is determined not to execute the first processing instruction, and the first processing instruction is blocked or cached.

[0080] In a possible implementation, determining whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that is not completed before the first processing instruction and the first content includes:

[0081] determining, according to the first content, a first storage area for data corresponding to an operand of the first processing instruction;

[0082] determining a second storage area for data corresponding to an operand of the second processing instruction;

[0083] When the first storage area and the second storage area overlap, the first processing instruction is not executed, or

[0084] When the first storage area and the second storage area have no overlap, the first processing instruction is executed.

[0085] In a possible implementation, when there is overlap between the first storage area for data corresponding to the operand of the first processing instruction determined based on the first content and the second storage area for data corresponding to the operand of the second processing instruction, it indicates that there is a data conflict between the first processing instruction and the second processing instruction. The two instructions may perform conflicting read / write operations on data in the same data storage area, so the first processing instruction is not executed when the second processing instruction is not executed. When there is no overlap between the first storage area and the second storage area, the two instructions will not perform conflicting read / write operations on data in the same data storage area, that is, there is no data conflict between the two instructions, and the first processing instruction can be executed.

[0086] In this embodiment, the storage area of ​​the data corresponding to the operand of the first processing instruction can be directly and efficiently determined according to the shape parameter in the first content, and then it can be quickly determined whether the first processing instruction can be executed, thereby improving the processing efficiency of the processor.

[0087] In a possible implementation, determining whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that is not completed before the first processing instruction and the first content includes:

[0088] determining, according to the first content, a first operation area for data corresponding to the operand of the first processing instruction, the first operation area being smaller than a first storage area for data corresponding to the operand of the first processing instruction;

[0089] determining a second operation area for data corresponding to the operand of the second processing instruction, the second operation area being smaller than a second storage area for data corresponding to the operand of the second processing instruction;

[0090] When the first operation area and the second operation area overlap, the first processing instruction is not executed, or

[0091] When the first operation area and the second operation area do not overlap, the first processing instruction is executed.

[0092] In a possible implementation, when a processing instruction processes data in a storage area, due to various reasons such as a large amount of computation of the processing instruction or a large amount of data to be processed, the processing instruction may only process part of the data corresponding to the operand at one processing moment. The data storage area may be divided into multiple operation areas, and the processing instruction may sequentially operate on the data in one of the multiple operation areas. The operation area corresponding to the processing instruction at the current moment may be determined by recording the number of beats or time at which the processing instruction is executed. When the storage areas corresponding to the data of the operands of two processing instructions overlap, as long as the operation areas corresponding to the data of the operands of the two processing instructions do not overlap, there is no data conflict between the two processing instructions.

[0093] In a possible implementation, the first operation area corresponding to the first processing instruction at the current moment can be determined according to the first content, and whether there is a data conflict between the first processing instruction and the second processing instruction according to the second operation area corresponding to the second processing instruction at the current moment. When there is no overlap between the first operation area and the second operation area, the first processing instruction can be executed. When there is overlap, the first processing instruction cannot be executed.

[0094] In this embodiment, the operation area of ​​the data corresponding to the operand of the first processing instruction can be directly and efficiently determined based on the shape parameters in the first content, and whether there is a data conflict between the processing instructions can be judged based on the operation area. The execution order of the processing instructions can be managed more finely, thereby improving the processing efficiency of the processor.

[0095] In a possible implementation, the operand of the second processing instruction includes a second descriptor, the second descriptor includes second content, and the second content is used to indicate the shape of the tensor.

[0096] Determining whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that is not completed before the first processing instruction and the first content includes:

[0097] Determine whether to execute the first processing instruction according to shape parameters and / or address parameters of the first content and the second content.

[0098] In a possible implementation, when the operand of the second processing instruction includes the second content, it is possible to directly determine whether there is a data conflict between the two processing instructions based on the shape parameters and / or address parameters in the first content and the second content, without converting the first content or the second content into a storage address or an operation address of the data corresponding to the operand. It is possible to determine whether there is a data conflict between the operand of the first processing instruction and the operand of the second processing instruction based on the parameter values ​​in the shape parameters and / or the address parameters. When the parameter values ​​of the shape parameters and / or the address parameters in the first content and the second content overlap, the first processing instruction is not executed, or when the parameter values ​​of the shape parameters and / or the address parameters in the first content and the second content do not overlap, the first processing instruction is executed.

[0099] In this embodiment, when both processing instructions include descriptors, it is possible to directly determine whether there is a data conflict between the two processing instructions based on the parameter values ​​in the shape parameters and / or address parameters in the descriptors, and then determine whether to execute the first processing instruction without converting the data address of the data corresponding to the operand, thereby improving the processing efficiency of the processor.

[0100] In a possible implementation manner, the first descriptor further includes a first identifier, the second descriptor further includes a second identifier, and the method further includes:

[0101] Determine whether to execute the first processing instruction according to the first identifier and the second identifier.

[0102] In a possible implementation, when the first descriptor includes the first identifier and the second descriptor includes the second identifier, it can be directly determined whether there is a data conflict between the first processing instruction and the second processing instruction based on the first identifier and the second identifier. When the second identifier of the unfinished second processing instruction includes the first identifier of the first processing instruction, it can be determined that there is a data conflict between the two processing instructions.

[0103] In this embodiment, it is possible to quickly determine whether there is a data conflict between two processing instructions according to the identifier of the descriptor.

[0104] In a possible implementation, as described in the above embodiment, the storage area corresponding to the operand can be divided into multiple operation areas so that the processing instruction can perform finer-grained operations. When creating multiple descriptors, the storage areas of the data corresponding to each descriptor may not overlap or may overlap. When the storage areas of the data corresponding to the descriptors are not allowed to overlap, it can be determined whether there is a data conflict between the data corresponding to the two descriptors based on the identifier of the descriptor. When multiple descriptors are created and the storage areas of the data corresponding to the descriptors are allowed to overlap, it is determined whether to execute the first processing instruction based on the parameter values ​​of the shape parameters and / or address parameters in the first content and the second content.

[0105] In a possible implementation, the method according to the embodiment of the present disclosure can be implemented by the hardware structure of the relevant technology. In this case, the processor to which the method is applied may include a control unit and an execution unit, and the control unit is used to perform control, such as reading instructions from a memory or an external input, decoding (decoding) instructions, and sending micro-operation control signals to corresponding components. The execution unit is used to execute specific instructions, and the execution unit may be, for example, an arithmetic and logic unit (ALU), a memory access unit (MAU), an artificial intelligence computing unit (neural functional unit, NFU), etc. The present disclosure does not limit the specific hardware type of the execution unit. The present disclosure does not limit the specific hardware structure used to implement the method of the embodiment of the present disclosure.

[0106] Figure 3 FIG. 1 is a block diagram of a data processing device according to an embodiment of the present disclosure. Figure 3 As shown, the present disclosure also provides a data processing device, including:

[0107] A descriptor acquisition circuit 11 is used to acquire a first descriptor in a first processing instruction operand, wherein the first descriptor includes a first content, and the first content is used to indicate a shape of a tensor;

[0108] A determination circuit 12, configured to determine whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content;

[0109] The execution circuit 13 is used to block or cache the first processing instruction when it is determined that the first processing instruction is not to be executed.

[0110] In a possible implementation manner, the determining circuit is specifically configured to:

[0111] determining, according to the first content, a first storage area for data corresponding to an operand of the first processing instruction;

[0112] determining a second storage area for data corresponding to an operand of the second processing instruction;

[0113] When the first storage area and the second storage area overlap, the first processing instruction is not executed, or

[0114] When the first storage area and the second storage area have no overlap, the first processing instruction is executed.

[0115] In a possible implementation manner, the determining circuit is further configured to:

[0116] determining, according to the first content, a first operation area for data corresponding to the operand of the first processing instruction, the first operation area being smaller than a first storage area for data corresponding to the operand of the first processing instruction;

[0117] determining a second operation area for data corresponding to the operand of the second processing instruction, the second operation area being smaller than a second storage area for data corresponding to the operand of the second processing instruction;

[0118] When the first operation area and the second operation area overlap, the first processing instruction is not executed, or

[0119] When the first operation area and the second operation area do not overlap, the first processing instruction is executed.

[0120] In a possible implementation, the operand of the second processing instruction includes a second descriptor, the second descriptor includes second content, and the second content is used to indicate a shape of a tensor, and the determination circuit is further used to:

[0121] Determine whether to execute the first processing instruction according to shape parameters and / or address parameters of the first content and the second content.

[0122] In one possible implementation, the shape parameters include at least one of the following: the size of the data storage space in at least one direction of N dimensions, the size of the storage area of ​​the tensor data in at least one direction of N dimensions, the offset of the storage area in at least one direction of N dimensions, the positions of at least two vertices at diagonal positions in the N dimensions relative to the data reference point, and the mapping relationship between the data description position of the tensor data indicated by the descriptor and the data address.

[0123] In a possible implementation manner, the first descriptor further includes a first identifier, the second descriptor further includes a second identifier, and the apparatus further includes:

[0124] An identification determination circuit is used to determine whether to execute the first processing instruction according to the first identification and the second identification.

[0125] In a possible implementation, a neural network chip is also disclosed, which includes the above-mentioned data processing device.

[0126] In a possible implementation, a board is also disclosed, which includes a storage device, an interface device, a control device and the above-mentioned neural network chip; wherein the neural network chip is connected to the storage device, the control device and the interface device respectively; the storage device is used to store data; the interface device is used to realize data transmission between the neural network chip and an external device; the control device is used to monitor the status of the neural network chip.

[0127] Figure 4 A structural block diagram of a board according to an embodiment of the present disclosure is shown. Figure 4 In addition to the chip 389, the board may also include other supporting components, including but not limited to: a storage device 390, an interface device 391 and a control device 392;

[0128] The memory device 390 is connected to the neural network chip via a bus for storing data. The memory device may include a plurality of groups of memory cells 393. Each group of the memory cells is connected to the neural network chip via a bus. It is understood that each group of the memory cells may be DDR SDRAM (English: Double Data Rate SDRAM, double rate synchronous dynamic random access memory).

[0129] DDR can double the speed of SDRAM without increasing the clock frequency. DDR allows data to be read out on the rising and falling edges of the clock pulse. The speed of DDR is twice that of standard SDRAM. In one embodiment, the storage device may include 4 groups of storage units. Each group of storage units may include multiple DDR4 particles (chips). In one embodiment, the neural network chip may include 4 72-bit DDR4 controllers, and 64 bits of the above 72-bit DDR4 controllers are used for data transmission and 8 bits are used for ECC verification. It can be understood that when DDR4-3200 particles are used in each group of storage units, the theoretical bandwidth of data transmission can reach 25600MB / s.

[0130] In one embodiment, each group of the storage units includes a plurality of double rate synchronous dynamic random access memories arranged in parallel. DDR can transmit data twice in one clock cycle. A controller for controlling DDR is arranged in the chip to control the data transmission and data storage of each of the storage units.

[0131] The interface device is electrically connected to the neural network chip. The interface device is used to realize data transmission between the neural network chip and an external device (such as a server or a computer). For example, in one embodiment, the interface device can be a standard PCIE interface. For example, the data to be processed is transmitted to the chip by the server through the standard PCIE interface to realize data transfer. Preferably, when the PCIE 3.0X 16 interface is used for transmission, the theoretical bandwidth can reach 16000MB / s. In another embodiment, the interface device can also be other interfaces. This application does not limit the specific forms of the above-mentioned other interfaces. The interface unit can realize the switching function. In addition, the calculation results of the neural network chip are still transmitted back to the external device (such as a server) by the interface device.

[0132] The control device is electrically connected to the neural network chip. The control device is used to monitor the state of the neural network chip. Specifically, the neural network chip and the control device can be electrically connected via an SPI interface. The control device may include a single-chip microcomputer (Micro Controller Unit, MCU). For example, the neural network chip may include multiple processing chips, multiple processing cores or multiple processing circuits, which can drive multiple loads. Therefore, the neural network chip can be in different working states such as multi-load and light load. The control device can realize the regulation of the working states of multiple processing chips, multiple processing and / or multiple processing circuits in the neural network chip.

[0133] In a possible implementation, an electronic device is disclosed, which includes the above-mentioned neural network chip. The electronic device includes a data processing device, a robot, a computer, a printer, a scanner, a tablet computer, a smart terminal, a mobile phone, a driving recorder, a navigator, a sensor, a camera, a server, a cloud server, a camera, a video camera, a projector, a watch, a headset, a mobile storage, a wearable device, a vehicle, a household appliance, and / or a medical device.

[0134] The transportation means include airplanes, ships and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods; the medical equipment includes magnetic resonance imaging, ultrasound machines and / or electrocardiographs.

[0135] The foregoing content can be better understood in accordance with the following terms:

[0136] A1. A data processing method, the method comprising:

[0137] Obtain a first descriptor in a first processing instruction operand, wherein the first descriptor includes a first content, and the first content is used to indicate a shape of a tensor;

[0138] determining whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content;

[0139] When it is determined that the first processing instruction is not to be executed, the first processing instruction is blocked or cached.

[0140] A2. The method according to clause A1, wherein determining whether to execute the first processing instruction based on an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content comprises:

[0141] determining, according to the first content, a first storage area for data corresponding to an operand of the first processing instruction;

[0142] determining a second storage area for data corresponding to an operand of the second processing instruction;

[0143] When the first storage area and the second storage area overlap, the first processing instruction is not executed, or

[0144] When the first storage area and the second storage area have no overlap, the first processing instruction is executed.

[0145] A3. The method according to clause A1, wherein determining whether to execute the first processing instruction based on an operand of a second processing instruction that has not been completed before the first processing instruction in the instruction queue and the first content comprises:

[0146] determining, according to the first content, a first operation area for data corresponding to the operand of the first processing instruction, the first operation area being smaller than a first storage area for data corresponding to the operand of the first processing instruction;

[0147] determining a second operation area for data corresponding to the operand of the second processing instruction, the second operation area being smaller than a second storage area for data corresponding to the operand of the second processing instruction;

[0148] When the first operation area and the second operation area overlap, the first processing instruction is not executed, or

[0149] When the first operation area and the second operation area do not overlap, the first processing instruction is executed.

[0150] A4. The method according to clause A1, wherein the operand of the second processing instruction includes a second descriptor, the second descriptor includes a second content, and the second content is used to indicate the shape of the tensor.

[0151] Determining whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that is not completed before the first processing instruction and the first content includes:

[0152] Determine whether to execute the first processing instruction according to shape parameters and / or address parameters of the first content and the second content.

[0153] A5. According to the method described in clause A4, the shape parameters include at least one of the following: the size of the data storage space in at least one direction of N dimensions, the size of the storage area of ​​the tensor data in at least one direction of N dimensions, the offset of the storage area in at least one direction of N dimensions, the positions of at least two vertices at diagonal positions in the N dimensions relative to the data reference point, and the mapping relationship between the data description position of the tensor data indicated by the descriptor and the data address.

[0154] A6. The method according to clause A4, wherein the first descriptor further includes a first identifier, the second descriptor further includes a second identifier, and the method further includes:

[0155] Determine whether to execute the first processing instruction according to the first identifier and the second identifier.

[0156] A7. A data processing device, comprising:

[0157] A descriptor acquisition circuit is used to acquire a first descriptor in a first processing instruction operand, wherein the first descriptor includes a first content, and the first content is used to indicate a shape of a tensor;

[0158] a determination circuit, configured to determine whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content;

[0159] The execution circuit is used to block or cache the first processing instruction when it is determined that the first processing instruction is not to be executed.

[0160] A8. The apparatus according to clause A7, wherein the determining circuit is specifically configured to:

[0161] determining, according to the first content, a first storage area for data corresponding to an operand of the first processing instruction;

[0162] determining a second storage area for data corresponding to an operand of the second processing instruction;

[0163] When the first storage area and the second storage area overlap, the first processing instruction is not executed, or

[0164] When the first storage area and the second storage area have no overlap, the first processing instruction is executed.

[0165] A9. The apparatus according to clause A7, wherein the determining circuit is further configured to:

[0166] determining, according to the first content, a first operation area for data corresponding to the operand of the first processing instruction, the first operation area being smaller than a first storage area for data corresponding to the operand of the first processing instruction;

[0167] determining a second operation area for data corresponding to the operand of the second processing instruction, the second operation area being smaller than a second storage area for data corresponding to the operand of the second processing instruction;

[0168] When the first operation area and the second operation area overlap, the first processing instruction is not executed, or

[0169] When the first operation area and the second operation area do not overlap, the first processing instruction is executed.

[0170] A10. The apparatus according to clause A7, wherein the operand of the second processing instruction includes a second descriptor, the second descriptor includes a second content, the second content is used to indicate the shape of the tensor, and the determining circuit is further used to:

[0171] Determine whether to execute the first processing instruction according to shape parameters and / or address parameters of the first content and the second content.

[0172] A11. According to the device described in clause A10, the shape parameters include at least one of the following: the size of the data storage space in at least one direction of N dimensions, the size of the storage area of ​​the tensor data in at least one direction of N dimensions, the offset of the storage area in at least one direction of N dimensions, the positions of at least two vertices at diagonal positions in the N dimensions relative to the data reference point, and the mapping relationship between the data description position of the tensor data indicated by the descriptor and the data address.

[0173] A12. The apparatus according to clause A10, wherein the first descriptor further comprises a first identifier, the second descriptor further comprises a second identifier, and the apparatus further comprises:

[0174] An identification determination circuit is used to determine whether to execute the first processing instruction according to the first identification and the second identification.

[0175] A13. A neural network chip, comprising a data processing device as described in any one of clauses A7-A12.

[0176] A14. An electronic device comprising a neural network chip as described in clause A13.

[0177] A15. A board comprising: a storage device, an interface device, a control device, and a neural network chip as described in clause A13;

[0178] Wherein, the neural network chip is connected to the storage device, the control device and the interface device respectively;

[0179] The storage device is used to store data;

[0180] The interface device is used to realize data transmission between the neural network chip and external equipment;

[0181] The control device is used to monitor the state of the neural network chip.

[0182] A16. A card according to clause A15,

[0183] The storage device comprises: a plurality of groups of storage units, each group of the storage units is connected to the neural network chip via a bus, and the storage units are: DDR SDRAM;

[0184] The chip includes: a DDR controller for controlling data transmission and data storage of each storage unit;

[0185] The interface device is: a standard PCIE interface.

[0186] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A data processing method, the method include: Obtain a first descriptor in a first processing instruction operand, wherein the first descriptor includes a first content, and the first content is used to indicate a shape of a tensor; determining whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content; When it is determined that the first processing instruction is not to be executed, the first processing instruction is blocked or cached, and the determining whether to execute the first processing instruction according to the operand of the second processing instruction that is not completed before the first processing instruction in the instruction queue and the first content includes: determining, according to the first content, a first storage area for data corresponding to an operand of the first processing instruction; determining a second storage area for data corresponding to an operand of the second processing instruction; When the first storage area and the second storage area overlap, the first processing instruction is not executed, or When the first storage area and the second storage area do not overlap, executing the first processing instruction; The operand of the second processing instruction includes a second descriptor, the second descriptor includes a second content, the second content is used to indicate the shape of the tensor, and determining whether to execute the first processing instruction according to the operand of the second processing instruction that is not completed before the first processing instruction in the instruction queue and the first content, includes: Determine whether to execute the first processing instruction based on the shape parameters and address parameters or shape parameters of the first content and the second content, and do not execute the first processing instruction when the parameter values ​​of the shape parameters and address parameters in the first content and the second content overlap or the parameter values ​​of the shape parameters overlap, wherein the contents of the first descriptor and the second descriptor also include at least one address parameter representing the address of tensor data, and the address parameter of the tensor data may include a reference address of the data reference point of the descriptor in the data storage space of the tensor data.

2. According to the method according to claim 1, the shape parameters include at least one of the following: the size of the data storage space in at least one direction of N dimensions, the size of the storage area of ​​the tensor data in at least one direction of the N dimensions, the offset of the storage area in at least one direction of the N dimensions, the positions of at least two vertices at diagonal positions in the N dimensions relative to the data reference point, and the mapping relationship between the data description position of the tensor data indicated by the descriptor and the data address.

3. The method according to claim 1, wherein the first descriptor further comprises a first identifier, the second descriptor further comprises a second identifier, and the method further comprises include: Determine whether to execute the first processing instruction according to the first identifier and the second identifier.

4. A data processing device, the device include: A descriptor acquisition circuit is used to acquire a first descriptor in a first processing instruction operand, wherein the first descriptor includes a first content, and the first content is used to indicate a shape of a tensor; a determination circuit, configured to determine whether to execute the first processing instruction according to an operand of a second processing instruction in the instruction queue that has not been completed before the first processing instruction and the first content; The execution circuit is used to block or cache the first processing instruction when it is determined that the first processing instruction is not to be executed, and the determination circuit is specifically used to: determining, according to the first content, a first storage area for data corresponding to an operand of the first processing instruction; determining a second storage area for data corresponding to an operand of the second processing instruction; When the first storage area and the second storage area overlap, the first processing instruction is not executed, or When the first storage area and the second storage area do not overlap, executing the first processing instruction; The operand of the second processing instruction includes a second descriptor, the second descriptor includes a second content, the second content is used to indicate the shape of the tensor, and the determination circuit is further used to: Determine whether to execute the first processing instruction based on the shape parameters and address parameters or shape parameters of the first content and the second content, and do not execute the first processing instruction when the parameter values ​​of the shape parameters and address parameters in the first content and the second content overlap or the parameter values ​​of the shape parameters overlap, wherein the contents of the first descriptor and the second descriptor also include at least one address parameter representing the address of tensor data, and the address parameter of the tensor data may include a reference address of the data reference point of the descriptor in the data storage space of the tensor data.

5. According to the device of claim 4, the shape parameters include at least one of the following: the size of the data storage space in at least one direction of N dimensions, the size of the storage area of ​​the tensor data in at least one direction of the N dimensions, the offset of the storage area in at least one direction of the N dimensions, the positions of at least two vertices at diagonal positions in the N dimensions relative to the data reference point, and the mapping relationship between the data description position of the tensor data indicated by the descriptor and the data address.

6. The device according to claim 4, wherein the first descriptor further comprises a first identifier, the second descriptor further comprises a second identifier, and the device further comprises include: An identification determination circuit is used to determine whether to execute the first processing instruction according to the first identification and the second identification.

7. A neural network chip, comprising a data processing device as described in any one of claims 4 to 6.

8. An electronic device comprising the neural network chip as described in claim 7.

9. A board, the board include: A memory device, an interface device and a control device, and a neural network chip as claimed in claim 7; Wherein, the neural network chip is connected to the storage device, the control device and the interface device respectively; The storage device is used to store data; The interface device is used to realize data transmission between the neural network chip and external equipment; The control device is used to monitor the state of the neural network chip.

10. The board according to claim 9, The storage device include: A plurality of groups of storage units, each group of the storage units is connected to the neural network chip via a bus, and the storage units are: DDR SDRAM; The chip includes: a DDR controller for controlling data transmission and data storage of each storage unit; The interface device is: a standard PCIE interface.

Citation Information

Patent Citations

  • System and methods for expandably wide operand instructions

    CN107077327A

  • Calculation device and board card

    CN109522052A

  • Calculation method and related product

    CN110036369A

  • Processor operation method and device and related products

    CN111857828A

  • Vector and Matrix Computing Device

    US20180329868A1