WO2020200244A1 - 数据处理方法及装置以及相关产品 - Google Patents

数据处理方法及装置以及相关产品 Download PDF

Info

Publication number
WO2020200244A1
WO2020200244A1 PCT/CN2020/082775 CN2020082775W WO2020200244A1 WO 2020200244 A1 WO2020200244 A1 WO 2020200244A1 CN 2020082775 W CN2020082775 W CN 2020082775W WO 2020200244 A1 WO2020200244 A1 WO 2020200244A1
Authority
WO
WIPO (PCT)
Prior art keywords
descriptor
data
content
tensor
address
Prior art date
Application number
PCT/CN2020/082775
Other languages
English (en)
French (fr)
Inventor
刘少礼
王秉睿
周晓勇
庄毅敏
兰慧盈
梁军
李震
吴健华
郝勇峥
Original Assignee
中科寒武纪科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN201910272411.9A external-priority patent/CN111782133A/zh
Priority claimed from CN201910272625.6A external-priority patent/CN111782577B/zh
Priority claimed from CN201910272660.8A external-priority patent/CN111782267B/zh
Priority claimed from CN201910320091.XA external-priority patent/CN111831337B/zh
Priority claimed from CN201910319165.8A external-priority patent/CN111831722A/zh
Priority claimed from CN201910340177.9A external-priority patent/CN111857828B/zh
Priority claimed from CN201910341003.4A external-priority patent/CN111857829A/zh
Priority to KR1020207032006A priority Critical patent/KR20210002518A/ko
Priority to KR1020207036492A priority patent/KR102519470B1/ko
Priority to EP20217331.6A priority patent/EP3825847B1/en
Priority to JP2021510522A priority patent/JP7073580B2/ja
Priority to EP20217333.2A priority patent/EP3825848A1/en
Priority to KR1020207036508A priority patent/KR102379406B1/ko
Priority to KR1020207036496A priority patent/KR102522416B1/ko
Application filed by 中科寒武纪科技股份有限公司 filed Critical 中科寒武纪科技股份有限公司
Priority to KR1020207036500A priority patent/KR102579192B1/ko
Priority to KR1020207036505A priority patent/KR102550451B1/ko
Priority to EP20217329.0A priority patent/EP3825843B1/en
Priority to EP20783678.4A priority patent/EP3800547A4/en
Priority to EP20217328.2A priority patent/EP3825842B1/en
Priority to KR1020207036494A priority patent/KR102569336B1/ko
Priority to EP20217332.4A priority patent/EP3828698B1/en
Priority to EP20217330.8A priority patent/EP3825846A1/en
Publication of WO2020200244A1 publication Critical patent/WO2020200244A1/zh
Priority to US17/137,245 priority patent/US20210150325A1/en
Priority to US17/242,209 priority patent/US11836491B2/en
Priority to US17/327,627 priority patent/US11687339B2/en
Priority to US18/369,819 priority patent/US20240004650A1/en
Priority to US18/374,176 priority patent/US20240028334A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30007Arrangements for executing specific machine instructions to perform operations on data operands
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3004Arrangements for executing specific machine instructions to perform operations on memory
    • G06F9/30043LOAD or STORE instructions; Clear instruction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30007Arrangements for executing specific machine instructions to perform operations on data operands
    • G06F9/30036Instructions to perform operations on packed data, e.g. vector, tile or matrix operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30076Arrangements for executing specific machine instructions to perform miscellaneous control operations, e.g. NOP
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30145Instruction analysis, e.g. decoding, instruction word fields
    • G06F9/3016Decoding the operand specifier, e.g. specifier format
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30181Instruction operation extension or modification
    • G06F9/30192Instruction operation extension or modification according to data descriptor, e.g. dynamic data typing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/32Address formation of the next instruction, e.g. by incrementing the instruction counter
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3854Instruction completion, e.g. retiring, committing or graduating
    • G06F9/3856Reordering of instructions, e.g. using queues or age tags

Definitions

  • the present disclosure relates to the field of computer technology, in particular to a data processing method and device and related products.
  • 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 data access related parameters (such as the relationship between data or data dimensions, etc.) when designing parameters, so as to generate instructions and pass them to the processor to complete data access. This method reduces The processing efficiency of the processor.
  • the present disclosure proposes a data processing technical solution.
  • a data processing method including: when the operand of the decoded first processing instruction includes the identifier of the descriptor, acquiring the content of the descriptor according to the identifier of the descriptor The descriptor is used to indicate the shape of the tensor; and the first processing instruction is executed according to the content of the descriptor.
  • a data processing device including: a content acquisition module, configured to: when the operand of the decoded first processing instruction includes the identifier of the descriptor, according to the identifier of the descriptor, Acquire the content of the descriptor, the descriptor is used to indicate the shape of the tensor; an instruction execution module is used to execute the first processing instruction according to the content of the descriptor.
  • a neural network chip is provided, and the chip includes the data processing device described above.
  • an electronic device including the neural network chip as described above.
  • a board card comprising: a storage device, an interface device, a control device, and the neural network chip as described above; wherein the neural network chip and the storage device , The control device and the interface device are respectively connected; 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, It is used to monitor the state of the neural network chip.
  • the corresponding descriptor content can be determined when the operand of the decoded processing instruction includes the descriptor identifier, and the processing instruction can be executed according to the descriptor content, thereby Reduce the complexity of data access and improve the efficiency of data access.
  • Fig. 1a shows a flowchart of a data processing method according to an embodiment of the present disclosure.
  • Fig. 1b shows a block diagram of a data processing device according to an embodiment of the present disclosure.
  • Fig. 1c shows a flowchart of a data synchronization method according to an embodiment of the present disclosure.
  • Figure 1d1 shows a schematic diagram of an application scenario according to an embodiment of the present disclosure.
  • Fig. 1d2 shows a flowchart of a processor operating method according to an embodiment of the present disclosure.
  • Fig. 1e shows a flowchart of a data synchronization method according to an embodiment of the present disclosure.
  • Fig. If shows a flowchart of a data processing method according to an embodiment of the present disclosure.
  • Fig. 1g shows a flowchart of a processor operating method according to an embodiment of the present disclosure.
  • Fig. 2 shows a schematic diagram of a data storage space according to an embodiment of the present disclosure.
  • Fig. 3a shows a block diagram of a data processing device according to an embodiment of the present disclosure.
  • Fig. 3b shows a flowchart of a data processing method according to an embodiment of the present disclosure.
  • Fig. 3c1 shows a flowchart of a data synchronization method according to an embodiment of the present disclosure.
  • Fig. 3c2 shows a flowchart of a data synchronization method according to an embodiment of the present disclosure.
  • Figure 3c3 shows a block diagram of a data synchronization device according to an embodiment of the present disclosure.
  • Figure 3c4 shows a block diagram of a data synchronization device according to an embodiment of the present disclosure.
  • Figure 3c5 shows a block diagram of a data synchronization device according to an embodiment of the present disclosure.
  • Fig. 3d shows a block diagram of a processor operating device according to an embodiment of the present disclosure.
  • Figure 3e shows a block diagram of a data synchronization device according to an embodiment of the present disclosure.
  • Fig. 3f shows a block diagram of a data processing device according to an embodiment of the present disclosure.
  • Fig. 3g shows a block diagram of a processor operating device according to an embodiment of the present disclosure.
  • Fig. 4 shows a structural block diagram of a board according to an embodiment of the present disclosure.
  • 5a and 5b show schematic diagrams of application scenarios of a processor operating method according to an embodiment of the present disclosure.
  • 6a and 6b show schematic diagrams of application scenarios of a processor operation method according to an embodiment of the present disclosure.
  • Figures 7a and 7b show schematic diagrams of application scenarios of a processor operating method according to an embodiment of the present disclosure.
  • Fig. 8 shows a schematic diagram of a circular buffer storage area of a processor operating method according to an embodiment of the present disclosure.
  • a data processing method is provided.
  • Fig. 1a shows a flowchart of a data processing method according to an embodiment of the present disclosure. As shown in Figure 1a, the data processing method includes:
  • step S11a when the operand of the decoded first processing instruction includes the identifier of the descriptor, the content of the descriptor is obtained according to the identifier of the descriptor, and the descriptor is used to indicate the shape of the tensor ;
  • step S12a the first processing instruction is executed according to the content of the descriptor.
  • the corresponding descriptor content can be determined when the operand of the decoded processing instruction includes the descriptor identifier, and the processing instruction can be executed according to the descriptor content, thereby Reduce the complexity of data access and improve the efficiency of data access.
  • the data processing method can be applied to a processor
  • the processor can include general-purpose processors (such as central processing unit CPU, graphics processing unit GPU) and special-purpose processors (such as artificial intelligence processors, scientific computing processors). Or digital signal processor, etc.).
  • general-purpose processors such as central processing unit CPU, graphics processing unit GPU
  • special-purpose processors such as artificial intelligence processors, scientific computing processors. Or digital signal processor, etc.
  • the present disclosure does not limit the type of processor.
  • tensors can be of different dimensions.
  • scalars can be regarded as 0-dimensional tensors
  • vectors can be regarded as 1-dimensional tensors
  • matrices can be tensors of 2 or more dimensions.
  • the shape of a tensor includes information such as the dimensions of the tensor and the size of each dimension of the tensor. For example, for tensors:
  • the shape of the tensor can be described by the descriptor as (2, 4), which means that the tensor is a two-dimensional tensor through two parameters, and the size of the first dimension (column) of the tensor is 2. The size of the second dimension (row) is 4. It should be noted that this application does not limit the manner in which the descriptor indicates the shape of the tensor. When storing tensor data in the memory, the shape of the tensor data cannot be determined according to its data address (or storage area), and the relationship between multiple tensor data cannot be determined. The access efficiency is low.
  • a descriptor (tensor descriptor) can be introduced to indicate the shape of the tensor (N-dimensional tensor data).
  • the value of N can be determined according to the dimensionality (order) of the tensor data, or can be set according to the needs of the tensor data.
  • the tensor data is three-dimensional tensor data
  • the descriptor can be used to indicate the shape of the three-dimensional tensor data in three dimensions (such as offset, size, etc.). It should be understood that those skilled in the art can set the value of N according to actual needs, which is not limited in the present disclosure.
  • the descriptor may include identification and content, etc.
  • the identifier of the descriptor may be used to distinguish the descriptor, for example, a number; the content of the descriptor may include at least one shape representing the shape of the tensor data
  • the parameters (for example, the size in each dimension of the tensor, etc.) may also include at least one address parameter representing the address of the tensor data (for example, the reference address of the data reference point).
  • the present disclosure does not limit the specific parameters included in the content of the descriptor.
  • the shape of tensor data can be expressed, and related information such as the relationship between multiple tensor data can be determined, and the efficiency of accessing tensor data can be improved.
  • the processing instruction when the processing instruction is received, the processing instruction may be decoded (decoded) first.
  • the method further includes: performing decoding processing on the received first processing instruction to obtain the decoded first processing instruction,
  • the decoded first processing instruction includes an operation code and one or more operands, and the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • the decoded first processing instruction (microinstruction) can be obtained.
  • the first processing instruction may include data access instructions, operation instructions, descriptor management instructions, synchronization instructions, and so on.
  • the present disclosure does not limit the specific type of the first processing instruction and the specific decoding method.
  • the decoded first processing instruction may include an operation code and one or more operands.
  • the operation code is used to indicate a processing type corresponding to the first processing instruction, and the operand is used to indicate data to be processed.
  • the instruction can be expressed as: Add; A; B, where Add is an operation code, A and B are operands, and this instruction is used to add A and B.
  • the present disclosure does not limit the number of operands of the decoded instruction and the representation form of the instruction.
  • the descriptor storage space corresponding to the descriptor can be determined by the identifier of the descriptor, and the descriptor storage space The space obtains the content of the descriptor (including information representing the shape and address of the tensor data); then, the first processing instruction can be executed according to the content of the descriptor.
  • step S12a may include:
  • the data address in the data storage space of the data corresponding to the operand identified by the descriptor in the first processing instruction can be calculated, and corresponding processing can be executed according to the data address.
  • the processor can determine the descriptor storage corresponding to TR1 and TR2 according to the descriptor identifiers TR1 and TR2, respectively Space, and read the content in the descriptor storage space (such as shape parameters and address parameters); according to the content of the descriptor, the data addresses of data A and B can be calculated, for example, the data address 1 of A in the memory is ADDR64-ADDR127 , B's data address 2 in the memory is ADDR1023-ADDR1087. Then, the processor can read data from address 1 and address 2 respectively, and perform an addition operation to obtain the operation result (A+B).
  • the method according to the embodiment of the present disclosure may be implemented by a hardware structure of related technologies.
  • the processor applying this method may include a control unit and an execution unit.
  • the control unit is used for control, such as reading instructions from the memory or from the outside, decoding (decoding) the instructions, and sending them to the corresponding components. Send out micro-operation control signals, etc.
  • the execution unit is used to execute specific instructions.
  • the execution unit may be, for example, an arithmetic and logic unit (ALU), a memory access unit (MAU), an artificial functional unit (NFU), etc. .
  • ALU arithmetic and logic unit
  • MAU memory access unit
  • NFU artificial functional unit
  • the present disclosure does not limit the specific hardware type of the execution unit.
  • the instruction can be decoded by the control unit to obtain the decoded first processing instruction; if the operand of the decoded first processing instruction includes the identifier of the descriptor, the control unit can determine and The descriptor storage space corresponding to the descriptor, and the content (shape, address, and other information) of the descriptor is obtained from the descriptor storage space; then, the control unit can send the content of the descriptor and the first processing instruction to the execution unit to make The execution unit executes the first processing instruction according to the content of the descriptor.
  • the execution unit When the execution unit receives the content of the descriptor and the first processing instruction, it can calculate the data address in the data storage space of the data corresponding to the operand identified by the descriptor in the first processing instruction according to the content of the descriptor, and then can The corresponding processing is executed according to the data address.
  • the control unit can determine the descriptor storage space corresponding to TR1 and TR2, and read the descriptor storage space The content (such as shape parameters and address parameters) and send them to the execution unit.
  • the execution unit After the execution unit receives the content of the descriptor, it can calculate the data addresses of data A and B.
  • the address 1 of A in the memory is ADDR64-ADDR127
  • the address 2 of B in the memory is ADDR1023-ADDR1087.
  • the execution unit can read data from address 1 and address 2 respectively, perform an addition (Add) operation, and obtain the operation result (A+B).
  • a tensor control module may be provided in the control unit to implement operations associated with the descriptor, such as registration, modification, and cancellation of the descriptor; reading and writing of the content of the descriptor, etc.
  • the tensor control module may be, for example, a tensor interface unit (TIU), and the present disclosure does not limit the specific hardware type of the tensor control module. In this way, the operations associated with the descriptor can be realized through dedicated hardware, which further improves the access efficiency of tensor data.
  • TTIU tensor interface unit
  • the control unit may send the content of the descriptor and the first processing instruction to the execution unit, so that the execution unit executes the first processing instruction according to the content of the descriptor.
  • the tensor control module can also implement operations associated with the descriptor and the execution of instructions, such as the registration, modification, and cancellation of the descriptor; the reading and writing of the content of the descriptor; the calculation of the data address And the execution of data access instructions.
  • the descriptor storage space corresponding to the descriptor can be determined by the tensor control module; after the descriptor storage space is determined, Obtain the content of the descriptor from the descriptor storage space; according to the content of the descriptor, the tensor control module determines the data address of the data corresponding to the operand of the first processing instruction in the data storage space; according to the data address, pass the tensor The control module executes data processing corresponding to the first processing instruction.
  • the present disclosure does not limit the specific hardware structure used to implement the method of the embodiments of the present disclosure.
  • the content of the descriptor can be obtained from the descriptor storage space, and then the data address can be obtained, without the need to pass an instruction to the address each time it is accessed, thereby improving the data access efficiency of the processor.
  • the identifier and content of the descriptor can be stored in the descriptor storage space, which can be the internal memory of the control unit (for example, registers, on-chip SRAM or other media cache, etc.) Storage space.
  • the data storage space of the tensor data indicated by the descriptor may be the storage space in the internal memory of the control unit (for example, an on-chip cache) or an external memory (off-chip memory) connected to the control unit.
  • the data address in the data storage space may be an actual physical address or a virtual address. The present disclosure does not limit the location of the descriptor storage space and the data storage space, and the type of data address.
  • the identifier and content of the descriptor and the tensor data indicated by the descriptor can be located in the same area.
  • a continuous area of the on-chip cache can be used to store the relevant content of the descriptor
  • the address is ADDR0-ADDR1023, where the address ADDR0-ADDR31 can be used to store the identifier of the descriptor, the address ADDR32-ADDR63 can be used to store the content of the descriptor, and the address ADDR64-ADDR1023 can be used to store the tensor data indicated by the descriptor.
  • the address ADDR is not limited to one bit or one byte. It is used here to indicate an address and is an address unit. Those skilled in the art can determine the storage area and its address according to the actual situation, which is not limited in the present disclosure.
  • the identifier and content of the descriptor and the tensor data indicated by the descriptor can be stored separately in different areas of the internal memory.
  • a register can be used as a descriptor storage space, and the description can be stored in the register.
  • the identifier and content of the symbol use the on-chip cache as the data storage space to store the tensor data indicated by the descriptor.
  • a special register (SR) dedicated to the descriptor can also be set, and the data in the descriptor can be an immediate value or can be obtained from a special register.
  • the number of the register can be used to represent the identifier of the descriptor. For example, when the number of the register is 0, the identifier of the stored descriptor is 0.
  • an area can be allocated in the cache space according to the size of the tensor data indicated by the descriptor (for example, a tensor cache unit is created for each tensor data in the cache) for storing the Tensor data. It should be understood that a preset cache space may also be used to store the tensor data, which is not limited in the present disclosure.
  • the identifier and content of the descriptor can be stored in the internal memory, and the tensor data indicated by the descriptor can be stored in the external memory.
  • a method of storing the identifier and content of the descriptor on the chip, and storing the tensor data indicated by the descriptor off the chip may be adopted.
  • the data address of the data storage space corresponding to the descriptor may be a fixed address.
  • a separate data storage space can be divided for tensor data, and the starting address of each tensor data in the data storage space corresponds to the identifier of the descriptor one-to-one.
  • the execution unit can determine the data address of the data corresponding to the operand according to the content of the descriptor, and then execute the first processing instruction.
  • the descriptor may also be used to indicate the address of N-dimensional tensor data, where the The content of the descriptor may also include at least one address parameter representing the address of the tensor data.
  • tensor data is three-dimensional data.
  • the content of the descriptor may include an address parameter indicating the address of the tensor data, such as the starting address of the tensor data, and It may include multiple address parameters of the address of the tensor data, such as the start address of the tensor data + address offset, or the address parameters of the tensor data based on each dimension.
  • address parameters such as the start address of the tensor data + address offset, or the address parameters of the tensor data based on each dimension.
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the data storage space of the tensor data.
  • the reference address can be different according to the change of the data reference point.
  • the present disclosure does not limit the selection of data reference points.
  • the reference address may include the start address of the data storage space.
  • the reference address of the descriptor is the starting address of the data storage space.
  • the reference address of the descriptor is the physical address of the data block in the data storage space.
  • the shape parameter of the tensor data includes at least one of the following: the size of the data storage space of the tensor data in at least one of the N dimensional directions, and the storage area The size in at least one of the N dimensional directions, the offset of the storage area in at least one of the N dimensional directions, and at least two vertices at diagonal positions in the N dimensional directions relative to the data The position of the reference point, the data description position of the tensor data indicated by the descriptor and the mapping relationship between the data address. Among them, the data description position is the mapping position of the point or region in the tensor data indicated by the descriptor.
  • the descriptor can be represented by 3D space coordinates (x, y, z)
  • the shape of the tensor data and the data description position of the tensor data may be the position of a point or area in the three-dimensional space that the tensor data is mapped to, which is represented by three-dimensional space coordinates (x, y, z).
  • Fig. 2 shows a schematic diagram of a data storage space according to an embodiment of the present disclosure.
  • the data storage space 21 stores a two-dimensional data in a row-first manner, which can be represented by (x, y) (where the X axis goes horizontally to the right, and the Y axis goes vertically downwards), and the X axis direction
  • the size (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)
  • ori_y not shown in the figure
  • the start address of the data storage space 21 is PA_start (reference Address) 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, the offset 25 in the X axis direction is represented as offset_x, the offset 24 in the Y axis direction is represented as offset_y, and the size in the X axis direction is represented Is size_x, and the size in the Y-axis direction is expressed as size_y.
  • 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 is the start of the data storage space 21.
  • the start address PA_start can then be combined with the size ori_x of the data storage space 21 on the X axis, the size ori_y on the Y axis, and the offset of the data block 23 in the Y axis direction offset_y, the offset amount 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 determine the content of the descriptor of the data block 23.
  • the descriptor describes a two-dimensional space
  • those skilled in the art can set the dimension represented by the content of the descriptor according to the actual situation, which is not limited in the present disclosure.
  • At least two vertices at diagonal positions in N dimensions relative to the data reference may be based on the reference address of the data reference point of the descriptor in the data storage space. The position of the point determines the content of the descriptor of the tensor data.
  • the reference address PA_base of the data reference point of the descriptor in the data storage space and the position of the two diagonal vertices relative to the data reference point can be used to determine the descriptor value of the data block 23 in FIG. 2 content.
  • one data (for example, the data at position (2, 2)) can be selected as the data reference point in the data storage space 21 ,
  • the physical address of the data in the data storage space is used as the reference address PA_base; then, determine the position of at least two vertices of the diagonal position of the data block 23 relative to the data reference point, for example, using the upper left to lower right direction pair
  • PA_base the upper left corner vertex
  • the relative position (x_min, y_min) and the relative position (x_max, y_max) of the vertex at the lower right corner determine the content of the descriptor of the data block 23.
  • the data reference point of the descriptor may be based on the reference address in the data storage space, and between the data description position of the tensor data indicated by the descriptor and the data address To determine the content of the descriptor of the tensor data.
  • the mapping relationship between the data description location and the data address can be set according to actual needs. For example, when the tensor data indicated by the descriptor is three-dimensional spatial data, the function f(x, y, z) can be used to define The data describes the mapping relationship between the location and the data address.
  • mapping relationship between the data description location and the data address can be set according to the actual situation, which is not limited in the present disclosure.
  • PA2 (x,y) PA_start+(offset_y+y q -1)*ori_x+(offset_x+x q ) (4)
  • the execution unit can calculate the data address of the tensor data indicated by the descriptor in the data storage space according to the content of the descriptor, and then execute the processing corresponding to the processing instruction according to the address.
  • the management instructions of the descriptor can be used to implement the management of the registration, modification, and cancellation of the descriptor, and corresponding operation codes can be set for these management instructions.
  • the descriptor can be registered (created) by the descriptor registration command (TRCreat); the various parameters (shape, address, etc.) of the descriptor can be modified by the descriptor modification command; and the descriptor can be cancelled (deleted) by the descriptor cancellation command (TRRelease) Descriptors, etc.
  • the present disclosure does not limit the type of the management instruction of the descriptor and the specific setting of the operation code.
  • the method further includes:
  • the registration parameters of the descriptor in the first processing instruction are acquired, and the registration parameters include the identifier of the descriptor, the tensor shape, and the descriptor indicated by the descriptor. At least one of the content of the quantity data;
  • the registration parameters of the descriptor determine the first storage area of the content of the descriptor in the descriptor storage space, and the second storage of the content of the tensor data indicated by the descriptor in the data storage space area;
  • a descriptor registration instruction can be used to register a descriptor, and the instruction can include registration parameters of the descriptor.
  • the registration parameter may include at least one of the identifier (ID) of the descriptor, the tensor shape, and the content of the tensor data indicated by the descriptor.
  • the registration parameters may include the identification as TR0, the tensor shape (the number of dimensions, the size of each dimension, the offset, the starting data address, etc.). This disclosure does not limit the specific content of the registration parameters.
  • a corresponding descriptor can be created according to the registration parameters in the first processing instruction.
  • the corresponding descriptor can be created through the control unit or through the tensor control module, which is not limited in the present disclosure.
  • the first storage area of the content of the descriptor in the descriptor storage space and the second storage of the content of the tensor data indicated by the descriptor in the data storage space can be determined first. area.
  • the first storage area and/or the second storage area can be directly determined. For example, it is preset that the content of the descriptor and the content of the tensor data are stored in the same storage space, and the storage address of the content of the descriptor corresponding to the identifier TR0 of the descriptor is ADDR32-ADDR63, and the storage address of the content of the tensor data is ADDR64-ADDR1023 , You can directly determine that these two addresses are the first storage area and the second storage area.
  • the first storage area can be allocated in the descriptor storage space for the descriptor content, and the second storage area can be allocated in the data storage space for the tensor data content. area.
  • the storage area can be allocated through the control unit or through the tensor control module, which is not limited in the present disclosure.
  • the corresponding relationship between the tensor shape and the address can be established to determine the content of the descriptor, so that the Determine the corresponding data address according to the content of the descriptor during data processing. After determining the content of the descriptor, it can be stored in the first storage area to complete the registration process of the descriptor.
  • the registration parameters may include the start address PA_start (reference address) of the data storage space 21, the offset 25 in the X-axis direction (represented as offset_x), in Y
  • the offset 24 in the axis direction (denoted as offset_y), the size in the X axis direction (denoted as size_x), and the size in the Y axis direction (denoted as size_y).
  • the content of the descriptor can be expressed as formula (1) and stored in the first storage area, thereby completing the registration process of the descriptor.
  • the descriptor can be automatically created according to the descriptor registration instruction, and the correspondence between the tensor indicated by the descriptor and the data address can be realized, so that the data address can be obtained through the content of the descriptor during data processing, and the data of the processor can be improved. Access efficiency.
  • the method further includes:
  • the first processing instruction is a descriptor cancellation instruction, acquiring the identifier of the descriptor in the first processing instruction;
  • the storage area of the descriptor in the descriptor storage space and the storage area of the content of the tensor data indicated by the descriptor in the data storage space are respectively released.
  • the descriptor unregistration instruction can be used to unregister (delete) a descriptor, so as to release the space occupied by the descriptor.
  • the instruction may include at least the identifier of the descriptor.
  • the corresponding descriptor can be cancelled according to the descriptor identifier in the first processing instruction.
  • the corresponding descriptor can be cancelled through the control unit or through the tensor control module, which is not limited in the present disclosure.
  • the storage area of the descriptor in the descriptor storage space can be released, and/or the storage of the content of the tensor data indicated by the descriptor in the data storage space Area, thereby releasing the descriptor's occupation of each storage area.
  • the space occupied by the descriptor can be released after the use of the descriptor ends, the limited storage resources are reused, and the resource utilization efficiency is improved.
  • the method further includes:
  • the modification parameters of the descriptor in the first processing instruction are acquired, and the modification parameters include the identifier of the descriptor, the shape of the tensor to be modified, and the description of the descriptor. At least one of the contents of the indicated tensor data;
  • the content of the descriptor in the descriptor storage space and/or the content of the tensor data in the data storage space is updated.
  • the descriptor modification instruction can be used to modify various parameters of the descriptor, such as the identifier and the tensor shape.
  • the instruction may include a modification parameter, and the modification parameter includes at least one of the identifier of the descriptor, the shape of the tensor to be modified, and the content of the tensor data indicated by the descriptor. This disclosure does not limit the specific content of the modified parameters.
  • the content to be updated of the descriptor can be determined according to the modification parameter in the first processing instruction, For example, changing the dimension of the tensor from 3 dimensions to 2 dimensions, changing the dimensions of the tensor in one or more dimensional directions, etc.
  • the descriptor content in the descriptor storage space and/or the content of the tensor data in the data storage space can be updated, so as to modify the tensor data and make the updated
  • the content of the descriptor can indicate the shape of the modified tensor data.
  • the descriptor can be directly modified, so as to maintain the correspondence between the descriptor and the tensor data, and improve resource utilization efficiency.
  • the method further includes:
  • the second processing instruction includes the one that precedes the first processing instruction in the instruction queue and that has the descriptor in the operand. Marked processing instructions;
  • the first processing instruction is blocked or cached.
  • the dependency between the instructions can be determined based on the descriptor. If the operand of the decoded first processing instruction includes the identifier of the descriptor, it can be determined whether there is an instruction that has a dependency relationship with the first processing instruction among the preamble instructions of the first processing instruction.
  • the pre-order instruction for the instruction before the first processing instruction in the instruction queue (pre-order instruction), if the operand of the pre-order instruction has the identifier of the descriptor, it can be considered that the pre-order instruction is related to the The first processing instruction has a dependent second processing instruction.
  • the dependency relationship corresponding to each descriptor can be determined separately, that is, the operand has at least one of the multiple descriptors
  • the preamble instruction identified by the descriptor serves as the second processing instruction with a dependency relationship.
  • a dependency relationship judgment module can be provided in the control unit to judge the dependency relationship between processing instructions, which is not limited in the present disclosure.
  • the first processing instruction needs to be executed after the second processing instruction is completed.
  • the first processing instruction is an arithmetic instruction for the descriptor TR0 and the second processing instruction is a write instruction for the descriptor TR0
  • the first processing instruction cannot be executed.
  • the second processing instruction includes a synchronization instruction (sync) for the first processing instruction
  • sync synchronization instruction
  • the first processing instruction can be blocked, that is, the execution of the first processing instruction and other subsequent instructions is suspended until the execution of the second processing instruction is completed After that, the first processing instruction and other subsequent instructions are executed.
  • the first processing instruction may be cached, that is, the first processing instruction is stored in a preset cache space without affecting the execution of other instructions. After the execution of the second processing instruction is completed, the first processing instruction in the cache space is executed again.
  • the present disclosure does not limit the processing method of the first processing instruction when there is a second processing instruction that has not been processed.
  • the method further includes:
  • you can set the corresponding table of the state of the descriptor for example, store the corresponding table of the state of the descriptor in the tensor control module), so as to display the current state of the descriptor.
  • the state of the descriptor includes operable state or unavailable Operation status.
  • the current state of the descriptor may be set to an inoperable state. In this state, the first processing instruction cannot be executed, and the first processing instruction can be blocked or cached. Conversely, when there is no pre-order instruction for operating the descriptor, the current state of the descriptor can be set to an operable state. In this state, the first processing instruction can be executed.
  • the state correspondence table of the descriptor can also store the usage of TR, so as to determine whether TR is occupied or occupied. Release to realize the management of limited register resources.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • step S11a includes: when at least one of the source data and the destination data includes the identifier of the descriptor, obtaining the content of the descriptor from the descriptor storage space;
  • step S12a includes: respectively determining a first data address of the source data and/or a second data address of the destination data according to the content of the descriptor; reading and writing data from the first data address Enter the second data address.
  • the operand of a data access instruction includes source data and destination data, and is used to read data from the data address of the source data and write it to the data address of the destination data.
  • the first processing instruction is a data access instruction
  • the tensor data can be accessed through the descriptor.
  • the descriptor storage space of the descriptor can be determined.
  • the first descriptor storage space and the second description of the first descriptor can be determined respectively The second descriptor storage space of the symbol; then read the contents of the first descriptor and the second descriptor from the first descriptor storage space and the second descriptor storage space respectively; according to the first descriptor and the second description
  • the content of the symbol can be calculated separately for the first data address of the source data and the second data address of the destination data; data is read from the first data address and written to the second data address, thereby completing the entire access process.
  • the source data may be off-chip data to be read, the first descriptor of which is identified as 1, the target data is a piece of storage space on the chip, and the second descriptor of which is identified as 2.
  • the content D1 of the first descriptor and the content D2 of the second descriptor can be obtained from the descriptor storage space according to the identification 1 of the first descriptor in the source data and the identification 2 of the second descriptor in the target data.
  • the content D1 of the first descriptor and the content of the second descriptor can be expressed as follows:
  • the starting physical address PA3 of the source data and the starting physical address PA4 of the destination data can be obtained respectively, which are expressed as follows:
  • PA3 PA_start1+(offset_y1-1)*ori_x1+offset_x1
  • PA4 PA_start2+(offset_y2-1)*ori_x2+offset_x2
  • the first data address and the second data address can be determined respectively, and Read data from the first data address and write to the second data address (through the IO path), thereby completing the loading of the tensor data indicated by D1 into the storage space indicated by D2.
  • the first descriptor storage space of the first descriptor can be determined; then the first description is read from the first descriptor storage space The content of the symbol; according to the content of the first descriptor, the first data address of the source data can be calculated; according to the second data address of the destination data in the operand of the instruction, data can be read from the first data address and written to the first data address Two data addresses, thereby completing the entire access process.
  • the second descriptor storage space of the second descriptor can be determined; then the second description is read from the second descriptor storage space According to the content of the second descriptor, the second data address of the destination data can be calculated; according to the first data address of the source data in the operand of the instruction, data can be read from the first data address and written to The second data address, thus completing the entire access process.
  • the descriptor can be used to complete the data access, and there is no need to pass an instruction to the data address during each access, thereby improving the efficiency of data access.
  • the first processing instruction includes an operation instruction
  • step S12a includes:
  • the operation of tensor data can be realized through the descriptor.
  • the operand of the operation instruction includes the identifier of the descriptor
  • the descriptor storage space of the descriptor can be determined, and then the content of the descriptor can be read from the descriptor storage space; according to the content of the descriptor, the corresponding operand can be calculated The address of the data, and then read the data from the data address for calculation, thereby completing the entire calculation process.
  • the descriptor can be used to complete the data reading during the operation, without the need to pass in the data address through the instruction, thereby improving the efficiency of data operation.
  • a descriptor that can indicate the shape of a tensor is introduced, so that the descriptor can be used to determine the address of the data during the execution of the data processing instruction, which simplifies the instruction generation method from the hardware aspect, thereby reducing data The complexity of access and improve the efficiency of the processor to access data.
  • Fig. 3a shows a block diagram of a data processing device according to an embodiment of the present disclosure. As shown in Figure 3a, the present disclosure also provides a data processing device, including:
  • the content obtaining module 31a is configured to obtain the content of the descriptor according to the identifier of the descriptor when the operand of the decoded first processing instruction includes the identifier of the descriptor, and the descriptor is used to indicate a tensor
  • the shape of the instruction execution module 32a is used to execute the first processing instruction according to the content of the descriptor.
  • the instruction execution module includes: an address determination submodule, configured to determine, according to the content of the descriptor, that the data corresponding to the operand of the first processing instruction is in the data storage space The data address; a data processing sub-module for executing data processing corresponding to the first processing instruction according to the data address.
  • the device further includes: a first parameter acquisition module, configured to acquire the registration parameter of the descriptor in the first processing instruction when the first processing instruction is a descriptor registration instruction ,
  • the registration parameter includes at least one of the identifier of the descriptor, the tensor shape, and the content of the tensor data indicated by the descriptor;
  • the region determination module is used to determine the The content of the descriptor is in the first storage area in the descriptor storage space, and the content of the tensor data indicated by the descriptor is in the second storage area in the data storage space;
  • the content determination module is configured to The registration parameters of the descriptor and the second storage area determine the content of the descriptor to establish the corresponding relationship between the descriptor and the second storage area;
  • the content storage module is used to store the description The content of the symbol is stored in the first storage area.
  • the device further includes: an identification acquiring module, configured to acquire the identifier of the descriptor in the first processing instruction when the first processing instruction is a descriptor canceling instruction; and space release The module is used to release the storage area of the descriptor in the descriptor storage space and the storage area of the tensor data indicated by the descriptor in the data storage space according to the identifier of the descriptor.
  • the device further includes: a second parameter acquisition module, configured to acquire the modified parameter of the descriptor in the first processing instruction when the first processing instruction is a descriptor modification instruction
  • the modification parameter includes at least one of the identifier of the descriptor, the shape of the tensor to be modified, and the content of the tensor data indicated by the descriptor; an update content determination module is used to modify the descriptor according to The parameter determines the content to be updated of the descriptor; the content update module is used to update the content of the descriptor in the descriptor storage space and/or the content of the tensor data in the data storage space according to the content to be updated.
  • the device further includes: an instruction determining module, configured to determine whether there is a second processing instruction that has not completed processing according to the identifier of the descriptor, and the second processing instruction includes an instruction queue
  • the first instruction cache module is used to block or cache the processing instruction before the first processing instruction and has the identifier of the descriptor in the operand; The first processing instruction.
  • the device further includes: a state determining module, configured to determine the current state of the descriptor according to the identifier of the descriptor, and the state of the descriptor includes an operable state or an unavailable state. Operating state; a second instruction cache module, used to block or cache the first processing instruction when the descriptor is currently in an inoperable state.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • the content acquisition module includes: a content acquisition sub-module for When at least one of the source data and the destination data includes the identifier of the descriptor, the content of the descriptor is obtained from the descriptor storage space;
  • the instruction execution module includes: a first address determination sub-module for According to the content of the descriptor, the first data address of the source data and/or the second data address of the destination data are respectively determined; an access sub-module is used to read data from the first data address and Write to the second data address.
  • the first processing instruction includes an arithmetic instruction
  • the instruction execution module includes: a second address determining sub-module, configured to determine the second address according to the content of the descriptor.
  • the data address of the data corresponding to the operand of a processing instruction in the data storage space; the operation sub-module is configured to execute the operation corresponding to the first processing instruction according to the data address.
  • the descriptor is used to indicate the shape of N-dimensional tensor data, and N is an integer greater than or equal to zero, wherein the content of the descriptor includes at least the shape of the tensor data A shape parameter.
  • the descriptor is also used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • the address parameter of the tensor data includes the reference address of the data reference point of the descriptor in the data storage space of the tensor data; wherein, the shape of the tensor data
  • the parameters 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 of the tensor data in at least one direction of the N dimensional directions, and the storage area
  • the data describes the mapping relationship between the location and the data address.
  • the device further includes: a decoding module, configured to decode the received first processing instruction to obtain a decoded first processing instruction, wherein the decoded first processing instruction It includes an operation code and one or more operands, where the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • a decoding module configured to decode the received first processing instruction to obtain a decoded first processing instruction, wherein the decoded first processing instruction It includes an operation code and one or more operands, where the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • a neural network chip is also disclosed, which includes the above-mentioned data processing device.
  • a board card which includes a storage device, an interface device, a control device, and the aforementioned neural network chip; wherein, the neural network chip is connected to the storage device and the control device And the interface devices are respectively connected; 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 The state of the neural network chip is monitored.
  • Fig. 4 shows a structural block diagram of a board according to an embodiment of the present disclosure.
  • the board may include other supporting components in addition to the chip 389 described above.
  • the supporting components include, but are not limited to: a storage device 390, Interface device 391 and control device 392;
  • the storage device 390 is connected to the neural network chip through a bus for storing data.
  • the storage device may include multiple groups of storage units 393. Each group of the storage unit and the neural network chip are connected by a bus. It can be understood that each group of the storage unit may be DDR SDRAM (English: Double Data Rate SDRAM, double-rate synchronous dynamic random access memory).
  • the storage device may include 4 groups of the storage units. Each group of the storage unit may include a plurality of DDR4 particles (chips).
  • the neural network chip may include four 72-bit DDR4 controllers. In the 72-bit DDR4 controller, 64 bits 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 the storage unit, the theoretical bandwidth of data transmission can reach 25600MB/s.
  • each group of the storage unit 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 the DDR is provided in the chip for controlling the data transmission and data storage of each storage unit.
  • the interface device is electrically connected with the neural network chip.
  • the interface device is used to implement data transmission between the neural network chip and an external device (such as a server or a computer).
  • the interface device may be a standard PCIE interface.
  • the data to be processed is transferred from the server to the chip through a standard PCIE interface to realize data transfer.
  • the interface device may also be other interfaces. This application does not limit the specific manifestations of the other interfaces mentioned above, as long as the interface unit can realize the switching function.
  • the calculation result of the neural network chip is still transmitted by the interface device back to an external device (such as a server).
  • the control device is electrically connected with the neural network chip.
  • the control device is used to monitor the state of the neural network chip.
  • the neural network chip and the control device may be electrically connected through an SPI interface.
  • the control device may include a single-chip microcomputer (Micro Controller Unit, MCU).
  • MCU Micro Controller Unit
  • the neural network chip may include multiple processing chips, multiple processing cores, or multiple processing circuits, and can drive multiple loads. Therefore, the neural network chip can be in different working states such as multiple load and light load.
  • the control device can realize the regulation and control of the working states of multiple processing chips, multiple processing and or multiple processing circuits in the neural network chip.
  • an electronic device which includes the aforementioned neural network chip.
  • Electronic equipment includes data processing devices, robots, computers, printers, scanners, tablets, smart terminals, mobile phones, driving recorders, navigators, sensors, cameras, servers, cloud servers, cameras, cameras, projectors, watches, headsets , Mobile storage, wearable devices, vehicles, household appliances, and/or medical equipment.
  • 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 nuclear magnetic resonance, B-ultrasound and/or electrocardiograph.
  • a data processing method comprising:
  • the operand of the decoded first processing instruction includes the identifier of the descriptor
  • the first processing instruction is executed.
  • the registration parameters of the descriptor in the first processing instruction are acquired, and the registration parameters include the identifier of the descriptor, the tensor shape, and the descriptor indicated by the descriptor. At least one of the content of the quantity data;
  • the registration parameters of the descriptor determine the first storage area of the content of the descriptor in the descriptor storage space, and the second storage of the content of the tensor data indicated by the descriptor in the data storage space area;
  • the first processing instruction is a descriptor cancellation instruction, acquiring the identifier of the descriptor in the first processing instruction;
  • the storage area of the descriptor in the descriptor storage space and the storage area of the content of the tensor data indicated by the descriptor in the data storage space are respectively released.
  • the modification parameters of the descriptor in the first processing instruction are acquired, and the modification parameters include the identifier of the descriptor, the shape of the tensor to be modified, and the description of the descriptor. At least one of the contents of the indicated tensor data;
  • the content of the descriptor in the descriptor storage space and/or the content of the tensor data in the data storage space is updated.
  • the second processing instruction includes the one that precedes the first processing instruction in the instruction queue and that has the descriptor in the operand. Marked processing instructions;
  • the first processing instruction is blocked or cached.
  • obtaining the content of the descriptor according to the identifier of the descriptor includes:
  • executing the first processing instruction according to the content of the descriptor includes:
  • the content of the descriptor includes at least one shape parameter representing the shape of the tensor data.
  • descriptor is further used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • the address parameter of the tensor data includes the reference address of the data reference point of the descriptor in the data storage space of the tensor data;
  • the shape parameter of the tensor data includes at least one of the following:
  • the size of the data storage space in at least one of the N-dimensional directions, the size of the storage area of the tensor data in at least one of the N-dimensional directions, and the size of the storage area in at least one of the N-dimensional directions The offset in one direction, the position of at least two vertices at diagonal positions in N dimensional directions relative to the data reference point, the data description position of the tensor data indicated by the descriptor and the data address The mapping relationship between.
  • the decoded first processing instruction includes an operation code and one or more operands, and the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • a data processing device comprising:
  • the content obtaining module is used to obtain the content of the descriptor according to the identifier of the descriptor when the operand of the decoded first processing instruction includes the identifier of the descriptor, and the descriptor is used to indicate the tensor shape;
  • the instruction execution module is configured to execute the first processing instruction according to the content of the descriptor.
  • the instruction execution module comprising:
  • the address determination submodule is configured to determine the data address in the data storage space of the data corresponding to the operand of the first processing instruction according to the content of the descriptor;
  • the data processing sub-module is configured to execute data processing corresponding to the first processing instruction according to the data address.
  • A16 The device according to claim A14 or A15, further comprising:
  • the first parameter acquisition module is configured to acquire the registration parameters of the descriptor in the first processing instruction when the first processing instruction is a descriptor registration instruction, where the registration parameters include the identifier and tensor of the descriptor At least one of the shape and the content of the tensor data indicated by the descriptor;
  • the area determining module is used to determine the first storage area in the descriptor storage space where the content of the descriptor is in the descriptor storage space according to the registration parameters of the descriptor, and the content of the tensor data indicated by the descriptor is in the data storage The second storage area in the space;
  • a content determining module configured to determine the content of the descriptor according to the registration parameters of the descriptor and the second storage area, so as to establish a correspondence between the descriptor and the second storage area;
  • the content storage module is configured to store the content of the descriptor in the first storage area.
  • An identifier acquiring module configured to acquire the identifier of the descriptor in the first processing instruction when the first processing instruction is a descriptor canceling instruction;
  • the space release module is used to release the storage area of the descriptor in the descriptor storage space and the storage area of the tensor data indicated by the descriptor in the data storage space according to the identifier of the descriptor. .
  • the second parameter obtaining module is configured to obtain the modification parameter of the descriptor in the first processing instruction when the first processing instruction is a descriptor modification instruction, and the modification parameter includes the identifier of the descriptor and the modification parameter to be modified. At least one of the shape of the tensor and the content of the tensor data indicated by the descriptor;
  • the update content determination module is configured to determine the content to be updated of the descriptor according to the modification parameters of the descriptor
  • the content update module is used to update the content of the descriptor in the descriptor storage space and/or the content of the tensor data in the data storage space according to the content to be updated.
  • the instruction determining module is configured to determine whether there is a second processing instruction that has not completed processing according to the identifier of the descriptor.
  • the second processing instruction includes the one in the instruction queue before the first processing instruction and in the operand A processing instruction with the identifier of the descriptor;
  • the first instruction cache module is configured to block or cache the first processing instruction when there is a second processing instruction that has not been processed.
  • a state determining module configured to determine the current state of the descriptor according to the identifier of the descriptor, and the state of the descriptor includes an operable state or an inoperable state;
  • the second instruction cache module is used to block or cache the first processing instruction when the descriptor is currently in an inoperable state.
  • the content acquisition module includes:
  • the content acquisition sub-module is configured to acquire the content of the descriptor from the descriptor storage space when at least one of the source data and the destination data includes the identifier of the descriptor;
  • the instruction execution module includes:
  • the first address determining submodule is configured to determine the first data address of the source data and/or the second data address of the destination data according to the content of the descriptor;
  • the access sub-module is used to read data from the first data address and write to the second data address.
  • the second address determining submodule is configured to determine the data address in the data storage space of the data corresponding to the operand of the first processing instruction according to the content of the descriptor;
  • the operation sub-module is configured to execute the operation corresponding to the first processing instruction according to the data address.
  • the content of the descriptor includes at least one shape parameter representing the shape of the tensor data.
  • the descriptor is further used to indicate an address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the data storage space of the tensor data;
  • the shape parameter of the tensor data includes at least one of the following:
  • the size of the data storage space in at least one of the N-dimensional directions, the size of the storage area of the tensor data in at least one of the N-dimensional directions, and the size of the storage area in at least one of the N-dimensional directions The offset in one direction, the position of at least two vertices at diagonal positions in N dimensional directions relative to the data reference point, the data description position of the tensor data indicated by the descriptor and the data address The mapping relationship between.
  • the decoding module is used to decode the received first processing instruction to obtain the decoded first processing instruction
  • the decoded first processing instruction includes an operation code and one or more operands, and the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • a neural network chip comprising the data processing device according to any one of claims A14-A26.
  • A28 An electronic device comprising the neural network chip according to claim A27.
  • a board card comprising: a storage device, an interface device, a control device, and the neural network chip according to claim A27;
  • the neural network chip is respectively connected with the storage device, the control device and the interface device;
  • the storage device is used to store data
  • the interface device is used to implement data transmission between the neural network chip and external equipment
  • the control device is used to monitor the state of the neural network chip.
  • the storage device includes: multiple groups of storage units, each group of the storage units is connected to the neural network chip through a bus, and the storage unit is: 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.
  • a data processing apparatus is provided.
  • Fig. 1b shows a block diagram of a data processing device according to an embodiment of the present disclosure.
  • the data processing device includes a control unit 11b and an execution unit 12b, and the control unit 11b is used for:
  • the content of the descriptor is obtained from the descriptor storage space according to the identifier of the descriptor, and the descriptor is used to indicate the shape of the tensor ;
  • control unit obtains the content of the descriptor through the identifier of the descriptor in the operand of the first processing instruction, and sends the content of the descriptor to the execution unit to execute the first processing instruction, so that the processing instruction can be executed through
  • the descriptor is used to obtain the operand, thereby reducing the complexity of data access and improving the data access efficiency of the processor.
  • the data processing device may be applied to a processor, where the processor may include a general-purpose processor (such as a central processing unit CPU, a graphics processing unit GPU) and a dedicated processor (such as artificial intelligence processing).
  • a general-purpose processor such as a central processing unit CPU, a graphics processing unit GPU
  • a dedicated processor such as artificial intelligence processing.
  • processor scientific computing processor or digital signal processor.
  • the present disclosure does not limit the type of processor.
  • control unit 11b may be used to decode the received first processing instruction to obtain the decoded first processing instruction, where the decoded first processing instruction includes an operation code and One or more operands, and the operation code is used to indicate the processing type corresponding to the first processing instruction.
  • the first processing instruction may include data access instructions, operation instructions, descriptor management instructions, synchronization instructions, and so on. The present disclosure does not limit the specific type of the first processing instruction.
  • the control unit 11b decodes the received first processing instruction
  • the description is obtained from the descriptor storage space according to the identifier of the descriptor.
  • the content of the descriptor and the content of the descriptor and the first processing instruction are sent to the execution unit 12b; after receiving the content of the descriptor and the first processing instruction, the execution unit 12b first determines with the content of the descriptor according to the content of the descriptor.
  • the data address of the data corresponding to the operand of a processing instruction in the data storage space, and then according to the data address, the data processing corresponding to the first processing instruction is executed.
  • the data address in the data storage space may be an actual physical address or a virtual address, and the present disclosure does not limit the type of the data address.
  • the descriptor storage space may be the storage space in the internal memory of the control unit 11b
  • the data storage space may be the storage space in the internal memory of the control unit 11b or the external memory connected to the control unit 11b. . This disclosure does not limit this.
  • the descriptor is used to indicate the shape of N-dimensional tensor data
  • tensors can contain multiple forms of data composition
  • tensors can be of different dimensions, for example, scalars can be regarded as 0-dimensional tensors, vectors can be regarded as 1-dimensional tensors, and matrices can be 2-dimensional or 2-dimensional Tensor above dimension.
  • the shape of a tensor includes information such as the dimensions of the tensor and the size of each dimension of the tensor. For example, for tensors:
  • the shape of the tensor can be described by the descriptor as (2, 4), which means that the tensor is a two-dimensional tensor through two parameters, and the size of the first dimension (column) of the tensor is 2. The size of the second dimension (row) is 4. It should be noted that this application does not limit the manner in which the descriptor indicates the shape of the tensor.
  • the value of N can be determined according to the dimensionality (order) of the tensor data, or can be set according to the needs 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 (such as offset, size, etc.). It should be understood that those skilled in the art can set the value of N according to actual needs, which is not limited in the present disclosure.
  • the descriptor may include the identifier of the descriptor and the content of the descriptor.
  • the identifier of the descriptor is used to distinguish the descriptor, for example, the identifier of the descriptor is its number; the content of the descriptor includes at least one shape parameter representing the shape of the tensor data.
  • tensor data is 3-dimensional data. Among the three dimensions of the tensor data, the shape parameters of two dimensions are fixed, and the content of the descriptor may include the shape representing the other dimension of the tensor data parameter.
  • the identifier and content of the descriptor may be stored in the descriptor storage space (internal memory), such as a register, an on-chip SRAM or other media cache.
  • the tensor data indicated by the descriptor can be stored in the data storage space (internal memory or external memory), such as on-chip cache or off-chip memory.
  • the present disclosure does not limit the specific locations of the descriptor storage space and the data storage space.
  • the identifier, content of the descriptor, and the tensor data indicated by the descriptor can be stored in the same area of the internal memory.
  • a continuous area of the on-chip cache can be used to store the relevant descriptors.
  • the content, the address is ADDR0-ADDR1023, where the address ADDR0-ADDR63 can be used as the descriptor storage space to store the identifier and content of the descriptor, and the address ADDR64-ADDR1023 can be used as the data storage space to store the tensor data indicated by the descriptor.
  • addresses ADDR0-ADDR31 can be used to store the identifier of the descriptor
  • addresses ADDR32-ADDR63 can be used to store the content of the descriptor. It should be understood that the address ADDR is not limited to one bit or one byte. It is used here to indicate an address and is an address unit. Those skilled in the art can determine the descriptor storage space, the data storage space, and their specific addresses according to actual conditions, and this disclosure does not limit this.
  • 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, you can use the register as the descriptor storage space, store the identifier and content of the descriptor in the register, and use the on-chip cache as the data storage space to store the tensor data indicated by the descriptor.
  • the number of the register may be used to represent the identifier of the descriptor. For example, when the register number is 0, the identifier of the stored descriptor is set to 0. When the descriptor in the register is valid, an area can be allocated in the cache space for storing the tensor data according to the size of the tensor data indicated by the descriptor.
  • the identifier and content of the descriptor can be stored in the internal memory, and the tensor data indicated by the descriptor can be stored in the external memory.
  • a method of storing the identifier and content of the descriptor on the chip, and storing the tensor data indicated by the descriptor off the chip may be adopted.
  • the data address of the data storage space corresponding to the identifier of the descriptor may be a fixed address.
  • a separate data storage space can be divided for tensor data, and the starting address of each tensor data in the data storage space corresponds to the identifier of the descriptor one-to-one.
  • the execution unit can determine the data address of the data corresponding to the operand in the data storage space according to the content of the descriptor, and then execute the first processing instruction.
  • the descriptor may also be used to indicate the address of N-dimensional tensor data, where the The content of the descriptor may also include at least one address parameter representing the address of the tensor data.
  • tensor data is three-dimensional data.
  • the content of the descriptor may include an address parameter indicating the address of the tensor data, such as the starting physical address of the tensor data, It may also include multiple address parameters of the address of the tensor data, such as the start address of the tensor data + the address offset, or the address parameters of the tensor data based on each dimension. Those skilled in the art can set the address parameters according to actual needs, which is not limited in the present disclosure.
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the data storage space of the tensor data.
  • the reference address can be different according to the change of the data reference point.
  • the present disclosure does not limit the selection of data reference points.
  • the reference address may include the start address of the data storage space.
  • the reference address of the descriptor is the starting address of the data storage space.
  • the reference address of the descriptor is the address of the data block in the data storage space.
  • the shape parameter of the tensor data includes at least one of the following: the size of the data storage space in at least one of the N dimensional directions, and the storage area in the N dimensional directions The size in at least one direction of, the offset of the storage area in at least one of the N dimensional directions, the position of at least two vertices at diagonal positions in the N dimensional directions relative to the data reference point
  • the data description position is the mapping position of the point or region in the tensor data indicated by the descriptor.
  • the descriptor can be represented by 3D space coordinates (x, y, z)
  • the shape of the tensor data and the data description position of the tensor data may be the position of a point or area in the three-dimensional space that the tensor data is mapped to, which is represented by three-dimensional space coordinates (x, y, z). It should be understood that those skilled in the art can select the shape parameter representing the tensor data according to actual conditions, and this disclosure does not limit this.
  • the data reference point of the descriptor may be based on the reference address in the data storage space of the tensor data, and at least one direction of the N dimensions of the data storage space.
  • the size, 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, determine the size of the descriptor of the tensor data content.
  • Fig. 2 shows a schematic diagram of a data storage space according to an embodiment of the present disclosure.
  • the data storage space 21 stores a two-dimensional data in a row-first manner, which can be represented by (x, y) (where the X axis goes horizontally to the right, and the Y axis goes vertically downwards), and the X axis direction
  • the size (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)
  • ori_y not shown in the figure
  • the start address of the data storage space 21 is PA_start (reference Address) 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, the offset 25 in the X axis direction is represented as offset_x, the offset 24 in the Y axis direction is represented as offset_y, and the size in the X axis direction is represented Is size_x, and the size in the Y-axis direction is expressed as size_y.
  • 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 is the start of the data storage space 21.
  • the start address PA_start can then be combined with the size ori_x of the data storage space 21 on the X axis, the size ori_y on the Y axis, and the offset of the data block 23 in the Y axis direction offset_y, the offset amount 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 determine the content of the descriptor of the data block 23.
  • the content of the descriptor represents a two-dimensional space
  • those skilled in the art can set the specific dimensions of the content representation of the descriptor according to the actual situation, which is not limited in this disclosure.
  • At least two vertices at diagonal positions in N dimensions relative to the data reference may be based on the reference address of the data reference point of the descriptor in the data storage space. The position of the point determines the content of the descriptor of the tensor data.
  • the reference address PA_base of the data reference point of the descriptor in the data storage space and the position of the two diagonal vertices relative to the data reference point can be used to determine the descriptor value of the data block 23 in FIG. 2 content.
  • one data (for example, the data at position (2, 2)) can be selected as the data reference point in the data storage space 21 ,
  • the physical address of the data in the data storage space is used as the reference address PA_base; then, determine the position of at least two vertices of the diagonal position of the data block 23 relative to the data reference point, for example, using the upper left to lower right direction pair
  • PA_base the upper left corner vertex
  • the relative position (x_min, y_min) and the relative position (x_max, y_max) of the vertex at the lower right corner determine the content of the descriptor of the data block 23.
  • the data reference point of the descriptor may be based on the reference address in the data storage space, and between the data description position of the tensor data indicated by the descriptor and the data address To determine the content of the descriptor of the tensor data.
  • the mapping relationship between the data description location and the data address can be set according to actual needs. For example, when the tensor data indicated by the descriptor is three-dimensional spatial data, the function f(x, y, z) can be used to define The data describes the mapping relationship between the location and the data address.
  • mapping relationship between the data description location and the data address can be set according to the actual situation, which is not limited in the present disclosure.
  • the execution unit 12 when the execution unit 12 receives the content of the descriptor and the first processing instruction sent by the control unit 11, it can determine that the data corresponding to the operand of the first processing instruction is based on the content of the descriptor.
  • Data address in the data storage space Among them, the calculation of the data address is automatically completed by the hardware, and when the content of the descriptor is expressed in a different manner, the calculation method of the data address will also be different. This disclosure does not limit the specific calculation method of the data address.
  • the content of the descriptor in the operand is expressed by formula (1)
  • the offset of the tensor data indicated by the descriptor in the data storage space is offset_x and offset_y
  • the size is size_x*size_y
  • the starting data address PA1 (x, y) of the tensor data indicated by the descriptor in the data storage space can be determined using the following formula (4):
  • PA1 (x,y) PA_start+(offset_y-1)*ori_x+offset_x (4)
  • the execution unit 12 receives the content of the descriptor and the first processing instruction sent by the control unit 11.
  • the operand also includes the data description position for the descriptor, it can be based on the content of the descriptor and The data description location determines the data address of the data corresponding to the operand in the data storage space. In this way, part of the data (for example, one or more data) in the tensor data indicated by the descriptor can be processed.
  • the content of the descriptor in the operand is expressed by formula (1)
  • the offset of the tensor data indicated by the descriptor in the data storage space is offset_x and offset_y respectively
  • the size is size_x*size_y
  • the operand includes
  • the data description position for the descriptor is (x q , y q )
  • the data address PA2 (x, y) of the tensor data indicated by the descriptor in the data storage space can use the following formula (5) to make sure:
  • PA2 (x,y) PA_start+(offset_y+y q -1)*ori_x+(offset_x+x q ) (5)
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • control unit 11b is configured to obtain the first description from the descriptor storage space when the source data includes the identifier of the first descriptor and the target data includes the identifier of the second descriptor.
  • the execution unit 12b is configured to obtain the first data address of the source data and the second data address of the destination data respectively according to the received content of the first descriptor and the content of the second descriptor. Data address; read data from the first data address and write to the second data address.
  • the source data can be a group of data to be read off the chip, the first descriptor of which is identified as 1, and the destination data is a piece of data on the chip.
  • the identifier of the second descriptor of the storage space is 2.
  • the control unit 11b can obtain the content D1 of the first descriptor and the content D2 of the second descriptor from the descriptor storage space according to the identification 1 of the first descriptor in the source data and the identification 2 of the second descriptor in the target data.
  • the content D1 of the first descriptor, the content D2 of the second descriptor, and the first processing instruction are sent to the execution unit 12b.
  • the content D1 of the first descriptor and the content of the second descriptor can be expressed as follows:
  • the execution unit 12b can obtain the starting physical address PA3 of the source data and the starting physical address PA4 of the destination data, respectively, as follows:
  • PA3 PA_start1+(offset_y1-1)*ori_x1+offset_x1
  • PA4 PA_start2+(offset_y2-1)*ori_x2+offset_x2
  • the execution unit 12b can determine the first data address and the second data according to the starting physical address PA3 of the source data and the starting physical address PA4 of the destination data, as well as the content D1 of the first descriptor and the content D2 of the second descriptor. Address, and then read data from the first data address and write to the second data address (through the IO channel), thereby completing the loading of the tensor data pointed to by D1 into the storage space pointed to by D2, that is, completing the data Loading from the bottom to the top. It should be understood that the transmission of data from on-chip to off-chip is similar to the above-mentioned process and will not be repeated here.
  • the scale of the loaded data can be set when the data is loaded, wherein the scale of the loaded data can be set according to usage needs or the size of the storage space. For example, according to the needs of use, when loading data, you can set the first 10 data loaded into D1. This disclosure does not limit the specific scale of the loaded data.
  • the descriptor can be used to complete data access, and the content of the descriptor is stored in the descriptor storage space. There is no need to pass in the data address through instructions each time it is accessed, thereby improving the data access efficiency of the processor.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • control unit 11b is configured to obtain the content of the third descriptor from the descriptor storage space when the source data includes the identifier of the third descriptor; and send the first descriptor to the execution unit 12b The content of the three descriptors and the first processing instruction;
  • the execution unit 12b is configured to obtain a third data address of the source data according to the content of the received third descriptor; read data from the third data address and write it to the destination The data address of the data.
  • the source data can be a group of data to be read off the chip, the first descriptor of which is identified as 3, and the destination data is a block on the chip. storage.
  • the control unit 11 may obtain the content D3 of the third descriptor from the descriptor storage space according to the identifier 3 of the third descriptor in the source data, and send the content D3 of the third descriptor and the first processing instruction to the execution unit 12b.
  • the content D3 of the third descriptor can be expressed as follows:
  • the execution unit 12b can obtain the starting physical address PA5 of the source data according to the content D3 of the received third descriptor, which is expressed as follows:
  • PA5 PA_start3+(offset_y3-1)*ori_x3+offset_x3
  • the execution unit 12b can calculate the starting physical address of the target data and the data address of the target data according to the address information of the target data in the first processing instruction.
  • the address information of the destination data includes the general register number of the start address and offset. You can first access the general register to obtain the offset, and then add the start address and the offset to obtain the start physical of the target data. Address; Then according to the size of the target data, the data address of the target data can be determined.
  • the execution unit 12b can determine the third data address according to the starting physical address PA5 of the source data and the content D3 of the third descriptor, and then read the data from the third data address and write it to the data address of the destination data (which can be accessed through IO Path), thus completing the loading of the tensor data pointed to by D3 into the storage space of the target data, that is, completing the loading of data from off-chip to on-chip. It should be understood that the transmission of data from on-chip to off-chip is similar to the above-mentioned process and will not be repeated here.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • control unit 11b is configured to obtain the content of the fourth descriptor from the descriptor storage space when the target data includes the identifier of the fourth descriptor; send the first descriptor to the execution unit 12b The content of the four descriptors and the first processing instruction;
  • the execution unit 12b is configured to obtain the fourth data address of the destination data according to the content of the received fourth descriptor; read data from the data address of the source data and write it to the The fourth data address.
  • the source data may be a group of data to be read off the chip, the destination data is a piece of storage space on the chip, and the identifier of the fourth descriptor is 4.
  • the control unit 11b may obtain the content D4 of the fourth descriptor from the descriptor storage space according to the identifier 4 of the fourth descriptor in the target data, and send the content D4 of the fourth descriptor and the first processing instruction to the execution unit 12b.
  • the content D4 of the fourth descriptor can be expressed as follows:
  • the execution unit 12b can obtain the starting physical address PA6 of the target data according to the received content D4 of the fourth descriptor, which is expressed as follows:
  • PA6 PA_start4+(offset_y4-1)*ori_x4+offset_x4
  • the execution unit 12b can calculate the starting physical address of the source data and the data address of the source data according to the address information of the source data in the first processing instruction.
  • the address information of the source data includes the general register of the starting address and the offset. Number, you can first access the general register to get the offset, and then add the start address and the offset to get the start physical address of the source data; then the data address of the source data can be determined according to the size of the source data.
  • the execution unit 12b can determine the fourth data address according to the starting physical address PA6 of the target data and the content D4 of the fourth descriptor, and then reads the data from the data address of the source data and writes it to the fourth data address (via IO Path), thus completing the loading of the source data into the storage space pointed to by D4, that is, completing the loading of data from off-chip to on-chip. It should be understood that the transmission of data from on-chip to off-chip is similar to the above-mentioned process and will not be repeated here.
  • the first processing instruction includes an arithmetic instruction
  • the execution unit executing data processing corresponding to the first processing instruction according to the data address may include: The address reads data and executes the operation corresponding to the operation instruction.
  • the control unit 11 may obtain the content of the descriptor from the descriptor storage space according to the identifier of the descriptor, and The content of the descriptor and the operation instruction are sent to the execution unit 12; the execution unit 12 determines the data address of the data to be calculated according to the content of the received descriptor, reads the data to be calculated from the data address and executes the corresponding operation instruction Operation.
  • the operation instruction is an ADD instruction.
  • the control unit 11 can obtain the content of the descriptor according to the identifier of the descriptor, and send the content of the descriptor and the ADD instruction to the execution unit 12b for execution.
  • the unit 12b can determine the data address of the data to be calculated according to the content of the descriptor, and perform an ADD operation.
  • the execution unit 12b can load the data onto the chip through the IO channel according to the data address, and then read the data from the on-chip data address of the operand and perform an ADD operation.
  • the descriptor can be used to complete the data transmission and improve the data access efficiency of the processor.
  • a descriptor capable of describing the shape of the data is introduced, so that the address of the data can be determined by the descriptor during the execution of the first processing instruction, which simplifies the instruction generation method from the hardware aspect, thereby reducing The complexity of data access and improve the efficiency of the processor to access data.
  • Fig. 3b shows a flowchart of a data processing method according to an embodiment of the present disclosure. As shown in FIG. 3b, the data processing method is applied to a processor, and the method includes:
  • Step S41b when the operand of the decoded first processing instruction includes the identifier of the descriptor, the content of the descriptor is obtained from the descriptor storage space according to the identifier of the descriptor, and the descriptor is used to indicate The shape of the amount;
  • Step S42b determining the data address in the data storage space of the data corresponding to the operand of the first processing instruction according to the content of the descriptor;
  • Step S43b Perform data processing corresponding to the first processing instruction according to the data address.
  • step S42b may include:
  • the data address of the data corresponding to the operand in the data storage space is determined according to the content of the descriptor and the data description position .
  • the descriptor is used to indicate the shape of N-dimensional tensor data, and N is a positive integer,
  • the content of the descriptor includes at least one shape parameter representing the shape of the tensor data.
  • the descriptor is also used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the data storage space of the tensor data;
  • the shape parameter of the tensor data includes at least one of the following:
  • the size of the data storage space in at least one of the N-dimensional directions, the size of the storage area of the tensor data in at least one of the N-dimensional directions, and the size of the storage area in at least one of the N-dimensional directions The offset in one direction, the position of at least two vertices at diagonal positions in N dimensional directions relative to the data reference point, the data description position of the tensor data indicated by the descriptor and the data address The mapping relationship between.
  • the reference address includes a start address of the data storage space.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • step S41b may include: when the source data includes the identifier of the first descriptor, and the destination data includes the identifier of the second descriptor When, obtain the content of the first descriptor and the content of the second descriptor from the descriptor storage space respectively;
  • step S42b may include: respectively acquiring the first data address of the source data and the second data address of the destination data according to the content of the first descriptor and the content of the second descriptor;
  • step S43b may include: reading data from the first data address and writing to the second data address.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • step S41b may include: when the source data includes the identifier of the third descriptor, obtaining the second descriptor from the descriptor storage space The content of the three descriptors;
  • step S42b may include: obtaining a third data address of the source data according to the content of the third descriptor;
  • step S43b may include: reading data from the third data address and writing to the data address of the target data.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • step S41b may include: when the target data includes the identifier of the fourth descriptor, obtaining the second descriptor from the descriptor storage space The content of the four descriptors;
  • step S42b may include: obtaining a fourth data address of the target data according to the content of the fourth descriptor;
  • step S43b may include: reading data from the data address of the source data and writing to the fourth data address.
  • the first processing instruction includes an operation instruction
  • step S43b may include: reading data from the data address and executing an operation corresponding to the operation instruction.
  • the method further includes:
  • the decoded first processing instruction includes an operation code and one or more operands, and the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • the descriptor storage space is a storage space in an internal memory of the processor
  • the data storage space is a storage space in an internal memory or an external memory of the processor.
  • an artificial intelligence chip is also disclosed, which includes the above-mentioned data processing device.
  • a board card which includes a storage device, an interface device, a control device, and the aforementioned artificial intelligence chip; wherein, the artificial intelligence chip and the storage device and the control device And the interface devices are respectively connected; the storage device is used to store data; the interface device is used to implement data transmission between the artificial intelligence chip and external equipment; the control device is used to The state of the artificial intelligence chip is monitored.
  • Fig. 4 shows a structural block diagram of a board according to an embodiment of the present disclosure.
  • the board may include other supporting components in addition to the chip 389 described above.
  • the supporting components include, but are not limited to: a storage device 390, Interface device 391 and control device 392;
  • the storage device 390 is connected to the artificial intelligence chip through a bus for storing data.
  • the storage device may include multiple groups of storage units 393. Each group of the storage unit and the artificial intelligence chip are connected through a bus. It can be understood that each group of the storage unit may be DDR SDRAM (English: Double Data Rate SDRAM, double-rate synchronous dynamic random access memory).
  • the storage device may include 4 groups of the storage units. Each group of the storage unit may include a plurality of DDR4 particles (chips).
  • the artificial intelligence chip may include four 72-bit DDR4 controllers. In the 72-bit DDR4 controller, 64 bits 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 the storage unit, the theoretical bandwidth of data transmission can reach 25600MB/s.
  • each group of the storage unit 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 the DDR is provided in the chip for controlling the data transmission and data storage of each storage unit.
  • the interface device is electrically connected with the artificial intelligence chip.
  • the interface device is used to implement data transmission between the artificial intelligence chip and an external device (such as a server or a computer).
  • the interface device may be a standard PCIE interface.
  • the data to be processed is transferred from the server to the chip through a standard PCIE interface to realize data transfer.
  • the interface device may also be other interfaces. This application does not limit the specific manifestations of the other interfaces mentioned above, as long as the interface unit can realize the switching function.
  • the calculation result of the artificial intelligence chip is still transmitted by the interface device back to an external device (such as a server).
  • the control device is electrically connected with the artificial intelligence chip.
  • the control device is used to monitor the state of the artificial intelligence chip.
  • the artificial intelligence chip and the control device may be electrically connected through an SPI interface.
  • the control device may include a single-chip microcomputer (Micro Controller Unit, MCU).
  • MCU Micro Controller Unit
  • the artificial intelligence chip may include multiple processing chips, multiple processing cores, or multiple processing circuits, and can drive multiple loads. Therefore, the artificial intelligence chip can be in different working states such as multiple 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 artificial intelligence chip.
  • an electronic device which includes the aforementioned artificial intelligence chip.
  • Electronic equipment includes data processing devices, robots, computers, printers, scanners, tablets, smart terminals, mobile phones, driving recorders, navigators, sensors, cameras, servers, cloud servers, cameras, cameras, projectors, watches, headsets , Mobile storage, wearable devices, vehicles, household appliances, and/or medical equipment.
  • 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 nuclear magnetic resonance, B-ultrasound and/or electrocardiograph.
  • a data processing device comprising a control unit and an execution unit, the control unit being used for:
  • the content of the descriptor is obtained from the descriptor storage space according to the identifier of the descriptor, and the descriptor is used to indicate the shape of the tensor ;
  • determining the data address in the data storage space of the data corresponding to the operand of the first processing instruction according to the content of the received descriptor comprising:
  • the data address of the data corresponding to the operand in the data storage space is determined according to the content of the descriptor and the data description position .
  • the content of the descriptor includes at least one shape parameter representing the shape of the tensor data.
  • the descriptor is further used to indicate an address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the data storage space of the tensor data;
  • the shape parameter of the tensor data includes at least one of the following:
  • the size of the data storage space in at least one of the N-dimensional directions, the size of the storage area of the tensor data in at least one of the N-dimensional directions, and the size of the storage area in at least one of the N-dimensional directions The offset in one direction, the position of at least two vertices at diagonal positions in N dimensional directions relative to the data reference point, the data description position of the tensor data indicated by the descriptor and the data address The mapping relationship between.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • control unit is used for:
  • the content of the first descriptor and the second description are obtained from the descriptor storage space respectively The content of the character;
  • execution unit is used for:
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • control unit is used for:
  • execution unit is used for:
  • Data is read from the third data address and written to the data address of the target data.
  • the first processing instruction includes a data access instruction
  • the operand includes source data and destination data
  • control unit is used for:
  • execution unit is used for:
  • Data is read from the data address of the source data and written to the fourth data address.
  • the first processing instruction comprises an arithmetic instruction
  • the executing unit executes data processing corresponding to the first processing instruction according to the data address, including:
  • control unit is further configured to:
  • the decoded first processing instruction includes an operation code and one or more operands, and the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • a data processing method the method being applied to a processor, the method including:
  • the content of the descriptor is obtained from the descriptor storage space according to the identifier of the descriptor, and the descriptor is used to indicate the shape of the tensor ;
  • determining the data address in the data storage space of the data corresponding to the operand of the first processing instruction according to the content of the descriptor includes:
  • the data address of the data corresponding to the operand in the data storage space is determined according to the content of the descriptor and the data description position .
  • A16 The method according to claim A14 or A15, wherein the descriptor is used to indicate the shape of N-dimensional tensor data, where N is a positive integer,
  • the content of the descriptor includes at least one shape parameter representing the shape of the tensor data.
  • descriptor is further used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • address parameter of the tensor data includes the reference address of the data reference point of the descriptor in the data storage space of the tensor data
  • the shape parameter of the tensor data includes at least one of the following:
  • the size of the data storage space in at least one of the N-dimensional directions, the size of the storage area of the tensor data in at least one of the N-dimensional directions, and the size of the storage area in at least one of the N-dimensional directions The offset in one direction, the position of at least two vertices at diagonal positions in N dimensional directions relative to the data reference point, the data description position of the tensor data indicated by the descriptor and the data address The mapping relationship between.
  • obtaining the content of the descriptor from the descriptor storage space according to the identifier of the descriptor includes: when the source data includes the first An identifier of a descriptor, and when the target data includes an identifier of a second descriptor, obtain the content of the first descriptor and the content of the second descriptor from the descriptor storage space;
  • determining the data address in the data storage space of the data corresponding to the operand of the first processing instruction includes: according to the content of the first descriptor and the second description The content of the symbol, respectively acquiring the first data address of the source data and the second data address of the destination data;
  • executing data processing corresponding to the first processing instruction according to the data address includes: reading data from the first data address and writing to the second data address.
  • obtaining the content of the descriptor from the descriptor storage space according to the identifier of the descriptor includes: when the source data includes the first When the identifier of the third descriptor is used, obtain the content of the third descriptor from the descriptor storage space;
  • determining the data address in the data storage space of the data corresponding to the operand of the first processing instruction according to the content of the descriptor includes: acquiring the source data according to the content of the third descriptor The third data address;
  • executing the data processing corresponding to the first processing instruction according to the data address includes: reading data from the third data address and writing to the data address of the target data.
  • obtaining the content of the descriptor from the descriptor storage space according to the identifier of the descriptor includes: when the target data includes the first When the identifier of the fourth descriptor is used, obtain the content of the fourth descriptor from the descriptor storage space;
  • determining the data address in the data storage space of the data corresponding to the operand of the first processing instruction includes:
  • executing data processing corresponding to the first processing instruction according to the data address includes: reading data from the data address of the source data and writing it to the fourth data address.
  • executing data processing corresponding to the first processing instruction includes:
  • the decoded first processing instruction includes an operation code and one or more operands, and the operation code is used to indicate a processing type corresponding to the first processing instruction.
  • An artificial intelligence chip comprising the data processing device according to any one of claims A1-A13.
  • A27 An electronic device comprising the artificial intelligence chip according to claim A26.
  • a board card comprising: a storage device, an interface device, a control device, and the artificial intelligence chip according to claim A26;
  • the artificial intelligence 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 implement data transmission between the artificial intelligence chip and external equipment
  • the control device is used to monitor the state of the artificial intelligence chip.
  • A29 The board according to claim A28, wherein the storage device comprises: multiple groups of storage units, each group of the storage units is connected to the artificial intelligence chip through a bus, and the storage unit is: 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.
  • a data synchronization method is provided.
  • Fig. 1c shows a flowchart of a data synchronization method according to an embodiment of the present disclosure.
  • the data synchronization method can be applied to a first processor, and the first processor can include general-purpose processors (such as central processing unit CPU, graphics processing unit GPU) and special-purpose processors (such as artificial intelligence processors, scientific computing processors) Or digital signal processor, etc.).
  • general-purpose processors such as central processing unit CPU, graphics processing unit GPU
  • special-purpose processors such as artificial intelligence processors, scientific computing processors
  • digital signal processor etc.
  • the present disclosure does not limit the type of the first processor.
  • the data synchronization method includes:
  • a descriptor synchronization instruction is generated according to the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the identifier of the descriptor and/or the content of the descriptor, and the descriptor uses To indicate the shape of the tensor data to be synchronized;
  • step S12c the descriptor synchronization instruction is sent to the second processor, where the descriptor synchronization instruction is used to instruct the second processor to obtain the tensor data to be synchronized according to the descriptor synchronization instruction.
  • Quantities can be of different dimensions.
  • a scalar can be regarded as a 0-dimensional tensor
  • a vector can be regarded as a 1-dimensional tensor
  • a matrix can be a tensor of 2 dimensions or more than 2 dimensions.
  • the shape of a tensor includes information such as the dimensions of the tensor and the size of each dimension of the tensor. For example, for tensors:
  • the shape of the tensor can be described by the descriptor as (2, 4), which means that the tensor is a two-dimensional tensor through two parameters, and the size of the first dimension (column) of the tensor is 2. The size of the second dimension (row) is 4. It should be noted that the present disclosure does not limit the manner in which the descriptor indicates the shape of the tensor. When storing tensor data in the memory, the shape of the tensor data cannot be determined according to its data address (or storage area), and the relationship between multiple tensor data cannot be determined. The access efficiency is low, and the complexity of data synchronization is also greater.
  • a descriptor (tensor descriptor) can be set to indicate the shape of tensor data (N-dimensional tensor data).
  • the value of N can be determined according to the dimensionality (order) of the tensor data, or can be set according to the needs of the tensor data.
  • the tensor data is three-dimensional tensor data
  • the descriptor can be used to indicate the shape of the three-dimensional tensor data in three dimensions (such as offset, size, etc.). It should be understood that those skilled in the art can set the value of N according to actual needs, which is not limited in the present disclosure.
  • the descriptor may include identification and content, etc.
  • the identifier of the descriptor may be used to distinguish the descriptor, for example, a number; the content of the descriptor may include at least one shape representing the shape of the tensor data
  • the parameters (for example, the size in each dimension of the tensor, etc.) may also include at least one address parameter representing the address of the tensor data (for example, the reference address of the data reference point).
  • the present disclosure does not limit the specific parameters included in the content of the descriptor.
  • the shape of tensor data can be expressed, and related information such as the relationship between multiple tensor data can be determined, which improves the efficiency of access to tensor data, thereby reducing The complexity of data synchronization.
  • data synchronization between multiple processors may be required, for example, the calculation result of processor A1 is synchronized to the processor A2 is used as input data for another operation.
  • a descriptor-based data synchronization mechanism can be used to achieve data synchronization.
  • the first processor is the sender of data synchronization
  • the second processor is the receiver of data synchronization.
  • the first processor may generate a descriptor synchronization instruction according to the descriptor of the tensor data in step S11c, and send the description to the second processor to be synchronized in step S12c Symbol synchronization instructions.
  • the second processor may include a general-purpose processor (such as a central processing unit CPU, a graphics processing unit GPU) and a dedicated processor (such as an artificial intelligence processor, a scientific computing processor, or a digital signal processor, etc.).
  • the type of the second processor may be the same as or different from the type of the first processor, and the present disclosure does not limit the type of the second processor.
  • the first processor can actively initiate data synchronization with the second processor. For example, when the first processor completes an operation and obtains the operation result (tensor data), actively initiates the The data of the second processor of the operation result is synchronized.
  • the first processor may also initiate data synchronization to the second processor in response to the synchronization request of the second processor, for example, when receiving the synchronization request instruction of the second processor, initiate the synchronization request to the second processor.
  • the processor's data is synchronized. The present disclosure does not limit the timing of initiating data synchronization.
  • the descriptor of the tensor data may be acquired.
  • the descriptor may be a registered (created) descriptor used to indicate the shape of the tensor data, or a new descriptor may be registered (created) according to the shape parameter of the tensor data, which is not limited in the present disclosure.
  • a descriptor synchronization instruction can be generated according to the descriptor of the tensor data, and the descriptor synchronization instruction includes the identifier of the descriptor and/or the content of the descriptor. If a descriptor indicating the tensor data to be synchronized is already registered in the second processor, the descriptor synchronization instruction may only include the identifier of the descriptor (for example, when the identifier of the descriptor is TR1, the descriptor synchronization instruction indicates Send TR1) to instruct the second processor to synchronize tensor data according to the identifier of the descriptor (TR1); if the descriptor indicating the tensor data to be synchronized is not registered in the second processor, the descriptor The synchronization instruction may include the content of the descriptor, or include both the identifier and content of the descriptor, so as to instruct the second processor to synchronize the tensor data according to the content of the descriptor
  • the descriptor synchronization instruction may be sent to the second processor to instruct the second processor to obtain the to-be-synchronized Zhang according to the descriptor synchronization instruction. ⁇ Volume data. If the descriptor synchronization instruction includes the identifier of the descriptor, the second processor can obtain the content of the descriptor according to the identifier of the descriptor, and then obtain the tensor data indicated by the descriptor according to the content of the descriptor, thereby realizing the tensor data Synchronize. If the descriptor synchronization instruction includes the content of the descriptor, the second processor can directly obtain the tensor data indicated by the descriptor according to the content of the descriptor, thereby achieving synchronization of the tensor data.
  • the descriptor synchronization instruction can be generated according to the descriptor of the tensor data to be synchronized and sent to the second processing
  • the processor sends the instruction to instruct the second processor to obtain the tensor data to be synchronized according to the descriptor synchronization instruction, thereby reducing synchronization overhead, reducing the complexity of data synchronization, and improving the efficiency of data synchronization.
  • the method further includes: determining the descriptor of the tensor data to be synchronized according to the descriptor synchronization request instruction from the second processor.
  • the first processor may initiate data synchronization with the second processor in response to the synchronization request of the second processor.
  • the descriptor synchronization request instruction from the second processor may include information about the tensor data to be synchronized, such as the identifier of the descriptor indicating the tensor data to be synchronized, the data characteristics of the tensor data to be synchronized, etc. .
  • the data characteristics of the tensor data may include information such as the shape, source, and address of the tensor data, and the present disclosure does not limit the specific content of the descriptor synchronization request instruction.
  • the first processor may determine the descriptor of the tensor data to be synchronized, and then generate the descriptor synchronization instruction.
  • the descriptor of the tensor data to be synchronized can be determined according to the synchronization request of the second processor, so as to generate the descriptor synchronization instruction, thereby avoiding unnecessary data synchronization and improving the efficiency of data synchronization.
  • the descriptor synchronization request instruction includes the identifier of the descriptor
  • the step of determining the descriptor of the tensor data to be synchronized according to the descriptor synchronization request instruction from the second processor may include: parsing the descriptor synchronization request instruction to obtain the identifier of the descriptor ; Determine the descriptor of the tensor data to be synchronized according to the identifier of the descriptor.
  • the descriptor synchronization request instruction may include The identifier, for example, when the identifier of the descriptor is TR1, the descriptor synchronization request command is expressed as Receive TR1.
  • the first processor may parse the descriptor synchronization request instruction from the second processor to obtain the identifier of the descriptor; and then determine the descriptor of the tensor data to be synchronized according to the identifier of the descriptor, so as to generate the descriptor synchronization instruction .
  • the descriptor of the tensor data to be synchronized can be determined according to the descriptor identifier in the request instruction, so as to achieve synchronization of the tensor data, thereby reducing the amount of data transmitted during synchronization and improving processing efficiency.
  • the descriptor synchronization request instruction includes the data characteristics of the tensor data to be synchronized
  • the step of determining the descriptor of the tensor data to be synchronized according to the descriptor synchronization request instruction from the second processor may include: parsing the descriptor synchronization request instruction to obtain the tensor data to be synchronized According to the data characteristics of the tensor data to be synchronized, the descriptor of the tensor data to be synchronized is determined.
  • the descriptor synchronization request instruction can be Including the data characteristics of the tensor data to be synchronized.
  • the first processor may parse the descriptor synchronization request instruction from the second processor to obtain the data characteristics of the tensor data to be synchronized; and then determine the tensor data to be synchronized according to the data characteristics of the tensor data to be synchronized And its descriptors in order to generate descriptor synchronization instructions.
  • the data characteristics of the tensor data to be synchronized may include information such as the shape, source, and address of the tensor data.
  • the data source of the tensor data is the Kth sender (the Kth processor)
  • the data source of the tensor data is the result of the convolution operation numbered 200
  • the address of the tensor data is specific
  • the address area for example, addresses ADDR0-ADDR127
  • the shape of the tensor data is a specified shape (for example, a two-dimensional tensor of 20*10), etc.
  • Those skilled in the art can set the data characteristics of the tensor data to be synchronized according to the actual situation, which is not limited in the present disclosure.
  • the first processor can find the tensor data to be synchronized, and determine the descriptor of the tensor data to be synchronized, for example, directly obtain or newly register the corresponding description symbol.
  • a descriptor synchronization instruction can be generated and sent to instruct the second processor to synchronize the tensor data.
  • the descriptor of the tensor data to be synchronized can be determined according to the data characteristics in the request instruction, so as to realize the synchronization of the tensor data, so that the tensor data itself does not need to be transmitted during synchronization, which reduces the amount of data transmitted.
  • synchronization overhead improves processing efficiency.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized, where step S11c may include:
  • a descriptor synchronization instruction is generated to instruct the second processor according to the The content of the descriptor of the synchronized tensor data obtains the tensor data to be synchronized from the shared storage space.
  • multiple processors may have a shared storage space, such as an off-chip memory that can be accessed by both the first processor and the second processor.
  • the shared storage space can be a storage space where multiple cores (multiple processors) can access data, or a storage space where part of cores (part of processors) can access data, and can be preset with inter-core Shared storage space, the present disclosure does not limit the setting method of the shared storage space.
  • the descriptor synchronization instruction may include the content of the descriptor of the tensor data to be synchronized, that is, the descriptor synchronization instruction may be generated according to the content of the descriptor of the tensor data to be synchronized.
  • the second processor After receiving the descriptor synchronization instruction, the second processor can parse the instruction to obtain the content of the descriptor; according to the content of the descriptor, the second processor can determine the data address of the tensor data to be synchronized, and obtain it from the shared storage space The tensor data to be synchronized realizes the entire synchronization process.
  • step S11c may include:
  • a descriptor synchronization instruction is generated to instruct the second processor to obtain the description of the tensor data to be synchronized from the synchronization data storage space The content of the character.
  • multiple processors may have synchronous data storage space dedicated to storing synchronous data.
  • the synchronized data storage space may be the aforementioned shared storage space, or a part of the shared storage space, or may be a storage space different from the shared storage space, which is not limited in the present disclosure.
  • the synchronous data storage space can be a storage space where multiple cores (multiple processors) can access synchronous data, or part of a core (part of processors) can access synchronous data.
  • the storage space is not limited in this disclosure.
  • the first processor may store the content of the descriptor in the synchronized data storage space; and in the synchronized data storage space according to the content of the descriptor In the address, generate and send the descriptor synchronization instruction.
  • the second processor can parse the instruction to obtain the storage address of the content of the descriptor; according to the storage address, the second processor can obtain the descriptor of the tensor data to be synchronized from the synchronization data storage space Then, the data address of the tensor data to be synchronized is determined according to the content of the descriptor, and the tensor data to be synchronized is obtained, thereby realizing the entire synchronization process.
  • step S11c may include:
  • a descriptor synchronization instruction is generated to instruct the second processor to download from the shared storage space according to the content of the descriptor of the tensor data to be synchronized Obtain the tensor data to be synchronized.
  • the first processor may have a non-shared storage space, the first processor can access data in the non-shared storage space, but the second processor cannot access the non-shared storage space of the first processor. Access the data in the non-shared storage space. If the storage address of the tensor data to be synchronized is in a non-shared storage space, the second processor cannot directly obtain the tensor data. In this case, the first processor may dump the tensor data to be synchronized to the shared storage space, so that the second processor can access the tensor data.
  • the first processor may generate a descriptor of the tensor data to be synchronized, that is, register a new descriptor to indicate the tensor data in the shared storage space.
  • the first processor may generate a descriptor synchronization instruction according to the content of the descriptor.
  • the second processor can parse the instruction to obtain the content of the descriptor; according to the content of the descriptor, the second processor can determine the data address of the tensor data to be synchronized, and obtain it from the shared storage space The tensor data to be synchronized realizes the entire synchronization process.
  • the tensor data to be synchronized in the non-shared storage space can be actively dumped to the shared storage space, so that the second processor can obtain the tensor data to be synchronized, thereby reducing the data between processors during synchronization Transmission to improve the processing efficiency of synchronization.
  • step S11c may include:
  • a descriptor synchronization instruction is generated to instruct the second processor to download from the shared storage space according to the content of the descriptor of the tensor data to be synchronized Obtain the tensor data to be synchronized.
  • the first processor may dump the tensor data to be synchronized to the shared storage space. After the dump is completed, if a descriptor indicating the tensor data in the non-shared storage space has been registered in the first processor and the descriptor can be modified (for example, the descriptor is not operated), the first processor can The descriptor of the tensor data to be synchronized is directly modified so that the descriptor indicates the tensor data in the shared storage space.
  • the first processor may generate a descriptor synchronization instruction according to the content of the descriptor.
  • the second processor can parse the instruction to obtain the content of the descriptor; according to the content of the descriptor, the second processor can determine the data address of the tensor data to be synchronized, and obtain it from the shared storage space The tensor data to be synchronized realizes the entire synchronization process.
  • the tensor data to be synchronized in the non-shared storage space can be actively dumped to the shared storage space, reducing the data transmission between processors during synchronization, and improving the processing efficiency of synchronization; and the first processor does not need Creating new descriptors saves limited descriptor resources.
  • Fig. 3c1 shows a flowchart of a data synchronization method according to an embodiment of the present disclosure.
  • the data synchronization method can be applied to the second processor.
  • the data synchronization method includes:
  • step S21c the descriptor synchronization instruction from the first processor is parsed to obtain the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the identifier of the descriptor and/or the content of the descriptor , The descriptor is used to indicate the shape of the tensor data to be synchronized;
  • step S22c the tensor data to be synchronized is obtained according to the descriptor of the tensor data to be synchronized.
  • the first processor can actively initiate data synchronization with the second processor (receiver). For example, when the first processor completes an operation and obtains the result (tensor data), it actively initiates Synchronize the data of the second processor that needs to use the operation result.
  • the second processor when the second processor receives the descriptor synchronization instruction from the first processor, it can parse the descriptor synchronization instruction to obtain the descriptor of the tensor data to be synchronized (for example, descriptor And/or the content of the descriptor).
  • the second processor may internally search for the content of the descriptor corresponding to the identifier of the descriptor, and then obtain the to-be-synchronized descriptor according to the content of the descriptor.
  • Tensor data so as to achieve synchronization of tensor data.
  • the second processor may search for the descriptor corresponding to the identifier of the descriptor, and according to the descriptor in the descriptor synchronization instruction Content, update the original descriptor content; obtain the tensor data to be synchronized according to the updated descriptor content, thereby achieving synchronization of the tensor data.
  • the second processor may register a descriptor indicating the tensor data to be synchronized according to the content of the descriptor, and according to the descriptor The content of obtains the tensor data to be synchronized, so as to realize the synchronization of tensor data.
  • the tensor data to be synchronized can be obtained according to the descriptor indicating the tensor data to be synchronized in the descriptor synchronization instruction, Realize the synchronization of tensor data, thereby reducing synchronization overhead, reducing the complexity of data synchronization, and improving the efficiency of data synchronization.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized, wherein step S22c includes:
  • the tensor data to be synchronized is obtained from the shared storage space.
  • the second processor can access the data from the shared storage space.
  • the descriptor synchronization instruction may include the content of the descriptor of the tensor data to be synchronized.
  • the second processor can parse the instruction to obtain the content of the descriptor; according to the content of the descriptor, the second processor can determine the data address of the tensor data to be synchronized, and obtain it from the shared storage space The tensor data to be synchronized realizes the entire synchronization process.
  • the descriptor synchronization instruction includes the address of the content of the descriptor of the tensor data to be synchronized in the synchronization data storage space, wherein step S22c includes:
  • the tensor data to be synchronized is obtained from the shared storage space.
  • the first processor may store the content of the descriptor in the synchronized data storage space; and generate the address according to the content of the descriptor in the synchronized data storage space And send the descriptor synchronization instruction.
  • the second processor can parse the instruction to obtain the storage address of the content of the descriptor; according to the storage address, the second processor can obtain the descriptor of the tensor data to be synchronized from the synchronization data storage space Then, the data address of the tensor data to be synchronized is determined according to the content of the descriptor, and the tensor data to be synchronized is obtained, thereby realizing the entire synchronization process.
  • Fig. 3c2 shows a flowchart of a data synchronization method according to an embodiment of the present disclosure.
  • the data synchronization method can be applied to the second processor.
  • the data synchronization method includes:
  • step S31c when there is tensor data to be synchronized, a descriptor synchronization request instruction is generated.
  • the descriptor synchronization request instruction is used to instruct the first processor to send the tensor to be synchronized according to the descriptor synchronization request instruction.
  • a descriptor of the data which is used to indicate the shape of the tensor data to be synchronized;
  • step S32c the descriptor synchronization request instruction is sent to the first processor.
  • the descriptor synchronization request instruction may be actively sent to the first processor to obtain the tensor data to be synchronized.
  • the second processor may generate the descriptor synchronization request instruction according to the information of the tensor data to be synchronized, such as the identifier of the descriptor indicating the tensor data to be synchronized, the data characteristics of the tensor data to be synchronized, and so on.
  • the present disclosure does not limit the specific content of the descriptor synchronization request instruction.
  • the first processor may determine the descriptor of the tensor data to be synchronized, and then generate the descriptor synchronization instruction.
  • the descriptor synchronization request instruction includes the identifier of the descriptor and/or the data characteristics of the tensor data to be synchronized, so that the first processor can determine the tensor data to be synchronized .
  • the data characteristics of the tensor data may include information such as the shape, source, and address of the tensor data. Those skilled in the art can set the data characteristics of the tensor data to be synchronized according to the actual situation, which is not limited in the present disclosure.
  • the method further includes:
  • the descriptor synchronization request instruction may include The identifier, for example, when the identifier of the descriptor is TR1, the descriptor synchronization request command is expressed as Receive TR1.
  • the first processor may parse the descriptor synchronization request instruction from the second processor to obtain the identifier of the descriptor; and then determine the descriptor of the tensor data to be synchronized according to the identifier of the descriptor, so as to generate the descriptor synchronization instruction .
  • the second processor when it receives the descriptor synchronization instruction, it can parse the descriptor synchronization instruction to obtain the descriptor of the tensor data to be synchronized (the identifier of the descriptor and/or the descriptor of the descriptor). content). If the descriptor synchronization instruction only includes the identifier of the descriptor, the second processor can internally search for the content of the descriptor corresponding to the identifier of the descriptor, and then obtain the tensor data to be synchronized according to the content of the descriptor, thereby realizing tensor data Synchronization.
  • the second processor may search for the descriptor corresponding to the identifier of the descriptor, and according to the descriptor in the descriptor synchronization instruction Content, update the original descriptor content; obtain the tensor data to be synchronized according to the updated descriptor content, thereby achieving synchronization of the tensor data.
  • the second processor may register a descriptor indicating the tensor data to be synchronized according to the content of the descriptor, and according to the descriptor The content of obtains the tensor data to be synchronized, so as to realize the synchronization of tensor data.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized, wherein the obtaining the descriptor according to the descriptor of the tensor data to be synchronized
  • the steps of tensor data to be synchronized may include:
  • the tensor data to be synchronized is obtained from the shared storage space.
  • the second processor can access the data from the shared storage space.
  • the descriptor synchronization instruction may include the content of the descriptor of the tensor data to be synchronized.
  • the second processor can parse the instruction to obtain the content of the descriptor; according to the content of the descriptor, the second processor can determine the data address of the tensor data to be synchronized, and obtain it from the shared storage space The tensor data to be synchronized realizes the entire synchronization process.
  • the descriptor synchronization instruction includes the address of the content of the descriptor of the tensor data to be synchronized in the synchronization data storage space, wherein, according to the tensor to be synchronized Descriptor of the data, the step of obtaining the tensor data to be synchronized may include:
  • the tensor data to be synchronized is obtained from the shared storage space.
  • the first processor can store the content of the descriptor in the synchronized data storage space; and generate and send the descriptor according to the address of the content of the descriptor in the synchronized data storage space Synchronization instructions.
  • the second processor can parse the instruction to obtain the storage address of the content of the descriptor; according to the storage address, the second processor can obtain the descriptor of the tensor data to be synchronized from the synchronization data storage space Then, the data address of the tensor data to be synchronized is determined according to the content of the descriptor, and the tensor data to be synchronized is obtained, thereby realizing the entire synchronization process.
  • the identifier and content of the descriptor can be stored in the descriptor storage space, which can be the internal memory of the processor (such as registers, on-chip SRAM or other media cache, etc.) Storage space.
  • the data storage space of the tensor data indicated by the descriptor may be a storage space in the internal memory of the processor (for example, on-chip cache) or an external memory (off-chip memory) connected to the processor.
  • the data address in the data storage space may be an actual physical address or a virtual address.
  • the present disclosure does not limit the location of the descriptor storage space and the data storage space, and the type of data address.
  • the identifier and content of the descriptor and the tensor data indicated by the descriptor can be located in the same area.
  • a continuous area of the on-chip cache can be used to store the relevant content of the descriptor
  • the address is ADDR0-ADDR1023, where the address ADDR0-ADDR31 can be used to store the identifier of the descriptor, the address ADDR32-ADDR63 can be used to store the content of the descriptor, and the address ADDR64-ADDR1023 can be used to store the tensor data indicated by the descriptor.
  • the address ADDR is not limited to one bit or one byte. It is used here to indicate an address and is an address unit. Those skilled in the art can determine the storage area and its address according to the actual situation, which is not limited in the present disclosure.
  • the identifier and content of the descriptor and the tensor data indicated by the descriptor can be stored separately in different areas of the internal memory.
  • a register can be used as a descriptor storage space, and the description can be stored in the register.
  • the identifier and content of the symbol use the on-chip cache as the data storage space to store the tensor data indicated by the descriptor.
  • a special register (SR) dedicated to the descriptor can also be set, and the data in the descriptor can be an immediate value or can be obtained from a special register.
  • the number of the register can be used to represent the identifier of the descriptor. For example, when the number of the register is 0, the identifier of the stored descriptor is 0.
  • an area can be allocated in the cache space according to the size of the tensor data indicated by the descriptor (for example, a tensor cache unit is created for each tensor data in the cache) for storing the Tensor data. It should be understood that a preset cache space may also be used to store the tensor data, which is not limited in the present disclosure.
  • the identifier and content of the descriptor can be stored in the internal memory, and the tensor data indicated by the descriptor can be stored in the external memory.
  • a method of storing the identifier and content of the descriptor on the chip, and storing the tensor data indicated by the descriptor off the chip may be adopted.
  • the data address of the data storage space corresponding to the descriptor may be a fixed address.
  • a separate data storage space can be divided for tensor data, and the starting address of each tensor data in the data storage space corresponds to the identifier of the descriptor one-to-one.
  • the processor can determine the data address of the tensor data based on the content of the descriptor.
  • the descriptor may also be used to indicate the address of N-dimensional tensor data, where the descriptor
  • the content of may also include at least one address parameter representing the address of the tensor data.
  • tensor data is three-dimensional data.
  • the content of the descriptor may include an address parameter indicating the address of the tensor data, such as the starting address of the tensor data, and It may include multiple address parameters of the address of the tensor data, such as the start address of the tensor data + address offset, or the address parameters of the tensor data based on each dimension.
  • address parameters such as the start address of the tensor data + address offset, or the address parameters of the tensor data based on each dimension.
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the data storage space of the tensor data.
  • the reference address can be different according to the change of the data reference point.
  • the present disclosure does not limit the selection of data reference points.
  • the reference address may include the start address of the data storage space.
  • the reference address of the descriptor is the starting address of the data storage space.
  • the reference address of the descriptor is the physical address of the data block in the data storage space.
  • the shape parameter of the tensor data includes at least one of the following: the size of the data storage space of the tensor data in at least one of the N dimensional directions, and the storage area The size in at least one of the N dimensional directions, the offset of the storage area in at least one of the N dimensional directions, and at least two vertices at diagonal positions in the N dimensional directions relative to the data The position of the reference point, the data description position of the tensor data indicated by the descriptor and the mapping relationship between the data address. Among them, the data description position is the mapping position of the point or region in the tensor data indicated by the descriptor.
  • the descriptor can be represented by 3D space coordinates (x, y, z)
  • the shape of the tensor data and the data description position of the tensor data may be the position of a point or area in the three-dimensional space that the tensor data is mapped to, which is represented by three-dimensional space coordinates (x, y, z).
  • Fig. 2 shows a schematic diagram of a data storage space according to an embodiment of the present disclosure.
  • the data storage space 21 stores a two-dimensional data in a row-first manner, which can be represented by (x, y) (where the X axis goes horizontally to the right, and the Y axis goes vertically downwards), and the X axis direction
  • the size (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)
  • ori_y not shown in the figure
  • the start address of the data storage space 21 is PA_start (reference Address) is the physical address of the first data block 22.
  • PA_start reference Address
  • the offset 25 in the X-axis direction is represented as offset_x
  • the offset 24 in the Y-axis direction is represented as offset_y
  • the size in the X-axis direction is represented Is size_x
  • the size in the Y-axis direction is expressed as size_y.
  • 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 is the start of the data storage space 21.
  • the start address PA_start can then be combined with the size ori_x of the data storage space 21 on the X axis, the size ori_y on the Y axis, and the offset of the data block 23 in the Y axis direction offset_y, the offset amount 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 determine the content of the descriptor of the data block 23.
  • the descriptor describes a two-dimensional space
  • those skilled in the art can set the dimension represented by the content of the descriptor according to the actual situation, which is not limited in the present disclosure.
  • At least two vertices at diagonal positions in N dimensions relative to the data reference may be based on the reference address of the data reference point of the descriptor in the data storage space. The position of the point determines the content of the descriptor of the tensor data.
  • the reference address PA_base of the data reference point of the descriptor in the data storage space and the position of the two diagonal vertices relative to the data reference point can be used to determine the descriptor value of the data block 23 in FIG. 2 content.
  • one data (for example, the data at position (2, 2)) can be selected as the data reference point in the data storage space 21 ,
  • the physical address of the data in the data storage space is used as the reference address PA_base; then, determine the position of at least two vertices of the diagonal position of the data block 23 relative to the data reference point, for example, using the upper left to lower right direction pair
  • PA_base the upper left corner vertex
  • the relative position (x_min, y_min) and the relative position (x_max, y_max) of the vertex at the lower right corner determine the content of the descriptor of the data block 23.
  • the data reference point of the descriptor may be based on the reference address in the data storage space, and between the data description position of the tensor data indicated by the descriptor and the data address To determine the content of the descriptor of the tensor data.
  • the mapping relationship between the data description location and the data address can be set according to actual needs. For example, when the tensor data indicated by the descriptor is three-dimensional spatial data, the function f(x, y, z) can be used to define The data describes the mapping relationship between the location and the data address.
  • mapping relationship between the data description location and the data address can be set according to the actual situation, which is not limited in the present disclosure.
  • PA2 (x,y) PA_start+(offset_y+y q -1)*ori_x+(offset_x+x q ) (4)
  • the processor can calculate the data address of the tensor data indicated by the descriptor in the data storage space according to the content of the descriptor, and then perform corresponding processing (such as data operation, data synchronization, etc.) according to the address, Therefore, the complexity of data access can be reduced, and the processing efficiency of the processor can be improved.
  • Figure 3c3 shows a block diagram of a data synchronization device according to an embodiment of the present disclosure.
  • the data synchronization device is applied to the first processor, as shown in FIG. 3c3, the data synchronization device includes:
  • the synchronization instruction generating module 51c is configured to generate a descriptor synchronization instruction according to the descriptor of the tensor data to be synchronized, and the descriptor synchronization instruction includes the identifier of the descriptor and/or the content of the descriptor.
  • the descriptor is used to indicate the shape of the tensor data to be synchronized;
  • the synchronization instruction sending module 52c is configured to send the descriptor synchronization instruction to the second processor, where the descriptor synchronization instruction is used to instruct the second processor to obtain the tensor data to be synchronized according to the descriptor synchronization instruction .
  • the device further includes: a first descriptor determining module, configured to determine the descriptor of the tensor data to be synchronized according to a descriptor synchronization request instruction from the second processor.
  • the descriptor synchronization request instruction includes the identifier of the descriptor
  • the first descriptor determining module includes:
  • the first parsing submodule is used to parse the descriptor synchronization request instruction to obtain the identifier of the descriptor;
  • the first determining submodule is configured to determine the descriptor of the tensor data to be synchronized according to the identifier of the descriptor.
  • the descriptor synchronization request instruction includes the data characteristics of the tensor data to be synchronized
  • the first descriptor determining module includes:
  • the second parsing submodule is used to parse the descriptor synchronization request instruction to obtain the data characteristics of the tensor data to be synchronized;
  • the second determining submodule is configured to determine the descriptor of the tensor data to be synchronized according to the data characteristics of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the synchronization instruction generation module includes:
  • the first generation sub-module is used to generate a descriptor synchronization instruction according to the content of the descriptor of the tensor data to be synchronized when the storage address of the tensor data to be synchronized is in the shared storage space to instruct the
  • the second processor obtains the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the synchronization instruction generation module includes:
  • the first storage submodule is used to store the content of the descriptor of the tensor data to be synchronized in the synchronized data storage space;
  • the second generation sub-module is configured to generate a descriptor synchronization instruction according to the address of the content of the descriptor in the synchronization data storage space to instruct the second processor to obtain the synchronization data storage space.
  • the synchronization instruction generation module includes:
  • the second storage sub-module is configured to store the tensor data to be synchronized in the shared storage space when the storage address of the tensor data to be synchronized is in the non-shared storage space;
  • a descriptor generation sub-module for generating a descriptor of the tensor data to be synchronized according to the address of the tensor data to be synchronized in the shared storage space;
  • the third generation sub-module is used to generate a descriptor synchronization instruction according to the content of the descriptor of the tensor data to be synchronized, so as to instruct the second processor according to the descriptor of the tensor data to be synchronized Content, obtaining the tensor data to be synchronized from the shared storage space.
  • the synchronization instruction generation module includes:
  • the third storage submodule is configured to store the tensor data to be synchronized in the shared storage space when the storage address of the tensor data to be synchronized is in the non-shared storage space;
  • the descriptor modification sub-module is used to modify the descriptor of the tensor data to be synchronized according to the address of the tensor data to be synchronized in the shared storage space;
  • the fourth generation sub-module is used to generate a descriptor synchronization instruction according to the content of the descriptor of the tensor data to be synchronized, so as to instruct the second processor according to the descriptor of the tensor data to be synchronized Content, obtaining the tensor data to be synchronized from the shared storage space.
  • Figure 3c4 shows a block diagram of a data synchronization device according to an embodiment of the present disclosure.
  • the data synchronization device is applied to the second processor, as shown in FIG. 3c4, the data synchronization device includes:
  • the first parsing module 61c is configured to parse the descriptor synchronization instruction from the first processor to obtain the descriptor of the tensor data to be synchronized, and the descriptor synchronization instruction includes the identifier of the descriptor and/or the description The content of the symbol, the descriptor is used to indicate the shape of the tensor data to be synchronized;
  • the first data obtaining module 62c is configured to obtain the tensor data to be synchronized according to the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the first data acquisition module includes:
  • the first data acquisition submodule is configured to acquire the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the address of the content of the descriptor of the tensor data to be synchronized in the synchronization data storage space
  • the first data acquisition module includes:
  • the first content obtaining submodule is used to obtain the description of the tensor data to be synchronized from the synchronized data storage space according to the address of the content of the descriptor of the tensor data to be synchronized in the synchronized data storage space The content of the character;
  • the second data acquisition submodule is configured to acquire the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • Figure 3c5 shows a block diagram of a data synchronization device according to an embodiment of the present disclosure.
  • the data synchronization device is applied to the second processor, as shown in FIG. 3c5, the data synchronization device includes:
  • the request command generation module 71c is configured to generate a descriptor synchronization request command when there is tensor data to be synchronized.
  • the descriptor synchronization request command is used to instruct the first processor to send the synchronization request command according to the descriptor synchronization request command.
  • Descriptor of the tensor data the descriptor is used to indicate the shape of the tensor data to be synchronized;
  • the request instruction sending module 72c is configured to send the descriptor synchronization request instruction to the first processor.
  • the descriptor synchronization request instruction includes the identifier of the descriptor and/or the data characteristic of the tensor data to be synchronized.
  • the device further includes:
  • the second parsing module is used to parse the descriptor synchronization instruction from the first processor to obtain the descriptor of the tensor data to be synchronized, and the descriptor synchronization instruction includes the identifier of the descriptor and/or the descriptor Content;
  • the second data acquisition module is configured to acquire the tensor data to be synchronized according to the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the second data acquisition module includes:
  • the third data acquisition submodule is configured to acquire the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the address of the content of the descriptor of the to-be-synchronized tensor data in the synchronization data storage space
  • the second data acquisition module includes:
  • the second content obtaining submodule is used to obtain the description of the tensor data to be synchronized from the synchronized data storage space according to the address of the content of the descriptor of the tensor data to be synchronized in the synchronized data storage space The content of the character;
  • the fourth data acquisition submodule is configured to acquire the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • an artificial intelligence chip is also disclosed, which includes the above-mentioned data synchronization device.
  • a board card which includes a storage device, an interface device, a control device, and the aforementioned artificial intelligence chip; wherein, the artificial intelligence chip and the storage device and the control device And the interface devices are respectively connected; the storage device is used to store data; the interface device is used to implement data transmission between the artificial intelligence chip and external equipment; the control device is used to The state of the artificial intelligence chip is monitored.
  • a data synchronization method applied to a first processor including: generating a descriptor synchronization instruction according to a descriptor of tensor data to be synchronized, the descriptor synchronization instruction including an identifier of the descriptor And/or the content of the descriptor, the descriptor is used to indicate the shape of the tensor data to be synchronized; the descriptor synchronization instruction is sent to the second processor, and the descriptor synchronization instruction is used to indicate the second The processor obtains the tensor data to be synchronized according to the descriptor synchronization instruction.
  • A2 The method according to claim A1, further comprising: determining the descriptor of the tensor data to be synchronized according to a descriptor synchronization request instruction from the second processor.
  • the descriptor synchronization request instruction includes an identifier of the descriptor, wherein the tensor data to be synchronized is determined according to the descriptor synchronization request instruction from the second processor
  • the descriptor includes: parsing the descriptor synchronization request instruction to obtain the identifier of the descriptor; and determining the descriptor of the tensor data to be synchronized according to the identifier of the descriptor.
  • the descriptor synchronization request instruction includes data characteristics of the tensor data to be synchronized
  • the descriptor synchronization request instruction from the second processor determines the The descriptor of the tensor data to be synchronized includes: parsing the descriptor synchronization request instruction to obtain the data characteristics of the tensor data to be synchronized; and determining the data characteristics of the tensor data to be synchronized Descriptor of tensor data.
  • A5. The method according to any one of claims A1-A4, wherein the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized, wherein the descriptor according to the tensor data to be synchronized ,
  • Generating a descriptor synchronization instruction includes: when the storage address of the tensor data to be synchronized is in a shared storage space, generating a descriptor synchronization instruction according to the content of the descriptor of the tensor data to be synchronized to indicate all
  • the second processor obtains the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • A6 The method according to any one of claims A1-A4, wherein the generating a descriptor synchronization instruction according to the descriptor of the tensor data to be synchronized includes: converting the descriptor of the tensor data to be synchronized The content of the descriptor is stored in the synchronous data storage space; according to the address of the content of the descriptor in the synchronous data storage space, a descriptor synchronization instruction is generated to instruct the second processor to obtain all data from the synchronous data storage space Describe the content of the descriptor of the tensor data to be synchronized.
  • the generating a descriptor synchronization instruction according to the descriptor of the tensor data to be synchronized includes: when the storage address of the tensor data to be synchronized is not When in the shared storage space, store the tensor data to be synchronized in the shared storage space; generate a descriptor of the tensor data to be synchronized according to the address of the tensor data to be synchronized in the shared storage space According to the content of the descriptor of the tensor data to be synchronized, a descriptor synchronization instruction is generated to instruct the second processor to download from the shared storage according to the content of the descriptor of the tensor data to be synchronized Space obtains the tensor data to be synchronized.
  • generating a descriptor synchronization instruction according to the descriptor of the tensor data to be synchronized includes: when the storage address of the tensor data to be synchronized is not When in the shared storage space, store the tensor data to be synchronized in the shared storage space; modify the descriptor of the tensor data to be synchronized according to the address of the tensor data to be synchronized in the shared storage space
  • a descriptor synchronization instruction is generated to instruct the second processor to download from the shared storage according to the content of the descriptor of the tensor data to be synchronized Space obtains the tensor data to be synchronized.
  • a data synchronization method applied to a second processor comprising: parsing a descriptor synchronization instruction from the first processor to obtain a descriptor of the tensor data to be synchronized, the descriptor synchronization instruction including The identifier of the descriptor and/or the content of the descriptor, where the descriptor is used to indicate the shape of the tensor data to be synchronized; the descriptor of the tensor data to be synchronized is used to obtain the The tensor data.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the obtaining of the descriptor according to the descriptor of the tensor data to be synchronized includes: obtaining the tensor data to be synchronized from a shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes an address of the content of the descriptor of the tensor data to be synchronized in the synchronization data storage space
  • the Descriptor of tensor data, obtaining the tensor data to be synchronized including: obtaining from the synchronized data storage space according to the address of the content of the descriptor of the tensor data to be synchronized in the synchronized data storage space
  • the content of the descriptor of the tensor data to be synchronized; and the tensor data to be synchronized is obtained from a shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • a data synchronization method applied to a second processor including: when there is tensor data to be synchronized, generating a descriptor synchronization request instruction, the descriptor synchronization request instruction being used to instruct the first processing
  • the device sends a descriptor of the tensor data to be synchronized according to the descriptor synchronization request instruction, where the descriptor is used to indicate the shape of the tensor data to be synchronized; and sends the descriptor synchronization request to the first processor instruction.
  • descriptor synchronization request instruction includes the identifier of the descriptor and/or the data characteristic of the tensor data to be synchronized.
  • A14 The method according to claim A12 or A13, the method further comprising: parsing the descriptor synchronization instruction from the first processor to obtain a descriptor of the tensor data to be synchronized, the descriptor synchronization instruction including all The identifier of the descriptor and/or the content of the descriptor; obtain the tensor data to be synchronized according to the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the obtaining the descriptor according to the descriptor of the tensor data to be synchronized includes: obtaining the tensor data to be synchronized from a shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the address of the content of the descriptor of the to-be-synchronized tensor data in the synchronization data storage space
  • the Descriptor of tensor data, obtaining the tensor data to be synchronized including: obtaining from the synchronized data storage space according to the address of the content of the descriptor of the tensor data to be synchronized in the synchronized data storage space
  • the content of the descriptor of the tensor data to be synchronized; and the tensor data to be synchronized is obtained from a shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • a data synchronization device which is applied to a first processor, and includes: a synchronization instruction generation module, configured to generate a descriptor synchronization instruction according to a descriptor of tensor data to be synchronized, the descriptor synchronization instruction Including the identifier of the descriptor and/or the content of the descriptor, the descriptor is used to indicate the shape of the tensor data to be synchronized; a synchronization instruction sending module is used to send the descriptor to the second processor A synchronization instruction, where the descriptor synchronization instruction is used to instruct the second processor to obtain the tensor data to be synchronized according to the descriptor synchronization instruction.
  • the device according to claim A17 further comprising: a first descriptor determining module, configured to determine the description of the tensor data to be synchronized according to a descriptor synchronization request instruction from the second processor symbol.
  • the descriptor synchronization request instruction includes an identifier of a descriptor
  • the first descriptor determining module includes: a first parsing sub-module for parsing the descriptor synchronization The request instruction obtains the identifier of the descriptor; the first determining sub-module is configured to determine the descriptor of the tensor data to be synchronized according to the identifier of the descriptor.
  • the descriptor synchronization request instruction includes the data characteristics of the tensor data to be synchronized
  • the first descriptor determining module includes: a second parsing submodule, Analyze the descriptor synchronization request instruction to obtain the data characteristics of the tensor data to be synchronized; the second determining sub-module is used to determine the data characteristics of the tensor data to be synchronized according to the data characteristics of the tensor data to be synchronized Descriptor.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the synchronization instruction generation module includes: a first generator A module for generating a descriptor synchronization instruction according to the content of the descriptor of the tensor data to be synchronized when the storage address of the tensor data to be synchronized is in the shared storage space to instruct the second processor Acquire the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the synchronization instruction generating module comprises: a first storage sub-module for storing the content of the descriptor of the tensor data to be synchronized to the synchronization Data storage space; a second generation sub-module for generating a descriptor synchronization instruction according to the address of the content of the descriptor in the synchronization data storage space to instruct the second processor to store the synchronization data
  • the space obtains the content of the descriptor of the tensor data to be synchronized.
  • the synchronization instruction generation module comprises: a second storage submodule, which is used for when the storage address of the tensor data to be synchronized is in a non-shared storage space , Store the to-be-synchronized tensor data in a shared storage space; a descriptor generation sub-module for generating the to-be-synchronized tensor data according to the address of the to-be-synchronized tensor data in the shared storage space The descriptor; the third generation sub-module is used to generate a descriptor synchronization instruction according to the content of the descriptor of the tensor data to be synchronized to instruct the second processor to instruct the second processor according to the tensor data to be synchronized The content of the descriptor for obtaining the tensor data to be synchronized from the shared storage space.
  • the synchronization instruction generation module comprises: a third storage sub-module, which is used when the storage address of the tensor data to be synchronized is in a non-shared storage space , Store the tensor data to be synchronized in a shared storage space; a descriptor modification sub-module for modifying the tensor data to be synchronized according to the address of the tensor data to be synchronized in the shared storage space The descriptor; the fourth generation sub-module is used to generate a descriptor synchronization instruction according to the content of the descriptor of the tensor data to be synchronized to instruct the second processor to instruct the second processor according to the tensor data to be synchronized The content of the descriptor for obtaining the tensor data to be synchronized from the shared storage space.
  • a data synchronization device applied to a second processor, and comprising: a first parsing module for parsing a descriptor synchronization instruction from the first processor to obtain a descriptor of tensor data to be synchronized,
  • the descriptor synchronization instruction includes the identifier of the descriptor and/or the content of the descriptor, the descriptor is used to indicate the shape of the tensor data to be synchronized;
  • the first data acquisition module is used to Descriptor of the tensor data to be synchronized to obtain the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the first data acquisition module includes: a first data acquisition submodule, It is used to obtain the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes the address of the content of the descriptor of the tensor data to be synchronized in a synchronized data storage space
  • the first data acquisition module includes :
  • the first content obtaining submodule is used to obtain the description of the tensor data to be synchronized from the synchronized data storage space according to the address of the content of the descriptor of the tensor data to be synchronized in the synchronized data storage space
  • the content of the symbol; the second data acquisition submodule is used to acquire the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • a data synchronization device which is applied to a second processor and includes: a request instruction generation module, configured to generate a descriptor synchronization request instruction when there is tensor data to be synchronized, the descriptor synchronization request The instruction is used to instruct the first processor to send the descriptor of the tensor data to be synchronized according to the descriptor synchronization request instruction, the descriptor is used to indicate the shape of the tensor data to be synchronized; the request instruction sending module is used for Sending the descriptor synchronization request instruction to the first processor.
  • descriptor synchronization request instruction includes the identifier of the descriptor and/or the data characteristic of the tensor data to be synchronized.
  • A30 The device according to claim A28 or A29, the device further comprising: a second parsing module for parsing the descriptor synchronization instruction from the first processor to obtain the descriptor of the tensor data to be synchronized, so The descriptor synchronization instruction includes the identifier of the descriptor and/or the content of the descriptor; the second data acquisition module is configured to acquire the tensor data to be synchronized according to the descriptor of the tensor data to be synchronized ⁇ Volume data.
  • the descriptor synchronization instruction includes the content of the descriptor of the tensor data to be synchronized
  • the second data acquisition module includes: a third data acquisition submodule, It is used to obtain the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • the descriptor synchronization instruction includes an address of the content of the descriptor of the tensor data to be synchronized in a synchronized data storage space
  • the second data acquisition module includes :
  • the second content obtaining submodule is used to obtain the description of the tensor data to be synchronized from the synchronized data storage space according to the address of the content of the descriptor of the tensor data to be synchronized in the synchronized data storage space
  • the content of the symbol; the fourth data acquisition sub-module is used to obtain the tensor data to be synchronized from the shared storage space according to the content of the descriptor of the tensor data to be synchronized.
  • An artificial intelligence chip comprising the data synchronization device according to any one of claims A17-A32.
  • A34 An electronic device comprising the artificial intelligence chip according to claim A33.
  • a board card comprising: a storage device, an interface device, and a control device, and the artificial intelligence chip according to claim A33; wherein the artificial intelligence chip is related to the storage device and the control device And the interface devices are respectively connected; the storage device is used to store data; the interface device is used to implement data transmission between the artificial intelligence chip and external equipment; the control device is used to The state of the artificial intelligence chip is monitored.
  • the storage device comprises: multiple groups of storage units, each group of the storage unit is connected to the artificial intelligence chip through a bus, and the storage unit is: DDR SDRAM;
  • the chip includes a DDR controller, which is used to control the data transmission and data storage of each storage unit;
  • the interface device is a standard PCIE interface.
  • FIG. 1d1 shows a schematic diagram of an application scenario according to an embodiment of the present disclosure.
  • the processor 100 may be a general-purpose processor (such as a central processing unit CPU, a graphics processor GPU), or a dedicated processor (such as an artificial intelligence processor, a scientific computing processor, or a digital signal processor, etc.). There is no restriction on the type of processor.
  • the storage device 200 includes at least one target storage area 210, where the target storage area 210 may be a storage area for tensor data indicated by the descriptor.
  • the processor can access a certain target storage area 210 by performing a read operation or a write operation, and the processor performs a read operation for a certain target storage area 210, which may mean that the processor obtains the target storage area 210 through a descriptor.
  • the processor executes a write operation for a certain target storage area 210, it may mean that the processor writes the tensor data indicated by the descriptor into the target storage area 210.
  • the processor can perform multiple operations in parallel, in order to avoid conflicts, when multiple operations performed by the processor in parallel are operations on a certain target storage area 210, the processor will only perform the multiple operations One of them, blocking other operations at the same time, which will reduce the efficiency of the processor.
  • the processor operation method provided by the present disclosure further divides the target storage area 210 into multiple fine-grained areas 211. When multiple operations performed by the processor in parallel are all operations on a certain target storage area 210, the processor can determine the Whether the fine-grained regions 211 targeted by multiple operations overlap, if the fine-grained regions 211 targeted by each operation do not overlap, the multiple operations can be executed in parallel, thus greatly improving the efficiency of the processor.
  • the storage device 200 may be arranged inside the processor (for example, on-chip cache or register, etc.), or may be arranged outside the processor and may communicate with the processor (for example, off-chip memory, etc.).
  • the present disclosure does not limit the type of storage device.
  • the operations involved in the present disclosure may be basic operations supported by the processor hardware, or may be microinstructions (for example, request signals, etc.) after the basic operations are analyzed.
  • the present disclosure does not limit the specific types of operations.
  • the processor of the present disclosure may perform two operations in parallel, or may perform more than two operations in parallel, and the present disclosure does not limit the number of operations performed in parallel.
  • Fig. 1d2 shows a flowchart of a processor operating method according to an embodiment of the present disclosure.
  • the processor operating method can be applied to a processor.
  • the processor operation method includes:
  • Step S11d when the first operation is an operation on the descriptor, obtain the target storage area of the tensor data indicated by the descriptor.
  • the first operation may be a read operation or a write operation for the descriptor.
  • the present disclosure does not limit the specific type of the first operation.
  • Descriptors can be used to indicate the shape of the tensor.
  • tensors can contain multiple forms of data composition, tensors can be of different dimensions, for example, scalars can be regarded as 0-dimensional tensors, vectors can be regarded as 1-dimensional tensors, and matrices can be 2-dimensional or 2-dimensional Tensor above dimension.
  • the shape of a tensor includes information such as the dimensions of the tensor and the size of each dimension of the tensor. For example, for tensors:
  • the shape of the tensor can be described by the descriptor as (2, 4), which means that the tensor is a two-dimensional tensor through two parameters, and the size of the first dimension (column) of the tensor is 2. The size of the second dimension (row) is 4. It should be noted that the present disclosure does not limit the manner in which the descriptor indicates the shape of the tensor.
  • the operand of the first operation may be one or more descriptors.
  • the target storage area can be the storage area of the tensor data indicated by one or more descriptors in the operand of the first operation, or the storage area of the tensor data indicated by any descriptor in the operand of the first operation space.
  • the overall storage area where the target storage area is located may be the internal memory of the processor (for example, on-chip cache or register, etc.), or may be an external memory connected to the processor (for example, off-chip memory, etc.).
  • the target storage area may include at least one fine-grained area.
  • the method for determining the size and/or number of the fine-grained area may include the method determined according to the hardware design, the method determined according to the relevant operation of the tensor data indicated by the descriptor, and the method defined according to the relevant parameters in the operation. One or any combination of.
  • the method determined according to the hardware design that is, the size of the fine-grained area is determined during hardware design, for example, one or more rows of the target storage area are determined to be a fine-grained area.
  • the method determined according to the related operations of the tensor data indicated by the descriptor including the method determined according to the processing requirements, storage method, or transmission method of the tensor data indicated by the descriptor, such as the tensor indicated by the descriptor
  • the data is a two-dimensional matrix data, the scale of which is M*Q (M and Q are both positive integers), indicating the number of bytes occupied by storage, that is, one row of M bytes, and a total of Q rows. It can be determined that M bytes are a fine Granularity area.
  • the target storage area corresponding to the tensor data indicated by the descriptor includes Q fine-grained areas.
  • the method of defining according to the relevant parameters in the operation includes dividing the target storage area into multiple fine-grained areas according to the fine-grained size and/or quantity carried in the operation.
  • the sizes of the multiple fine-grained regions may be the same or different.
  • the number of data bits in each fine-grained area may be 64 bits, 256 bits, 512 bits, etc., respectively.
  • the size and/or number of each fine-grained area can be determined according to requirements. This disclosure does not limit this.
  • the target storage area of the tensor data indicated by the descriptor can be obtained through the descriptor targeted by the first operation, thereby determining The target storage area for the first operation.
  • Step S12d It is judged whether there is an ongoing second operation on the target storage area.
  • the second operation may be a read operation or a write operation, and the present disclosure does not limit the specific type of the second operation.
  • the second operation may include one or more operands, and the operands of the second operation may be various data such as descriptors, immediates, tensor data, etc.
  • the present disclosure does not limit the specific number and types of operands of the second operation .
  • the processor may determine whether there is an ongoing second operation on the target storage area based on the occupancy state of the target storage area. For example, the processor may determine whether the target storage area is occupied by querying the occupied status list. If it is occupied, the determination result is that there is an ongoing second operation on the target storage area.
  • the occupied state list may be preset and stored in the memory, or it may be generated before the processor starts to execute a certain task, and log off after the task is completed. When the occupied state of each storage area changes, the processor updates the content of the occupied state list to record the occupied state of each storage area.
  • the second operation may be an operation on the descriptor
  • the descriptor targeted by the second operation may be the same as the descriptor targeted by the first operation
  • the descriptor of the descriptor targeted by the second operation The storage area is consistent with the target storage area.
  • the second operation is not completed, there is a second operation for the target storage area; or the storage area of the descriptor targeted by the second operation overlaps with the target storage area, when the second operation When an operation is performed on the overlapping area, there is a second operation on the target storage area.
  • the first operation on the target storage area before the first operation on the target storage area is performed, it may be determined whether there is an ongoing second operation on the target storage area.
  • the execution of the first operation on the target storage area it may also be determined whether there is an ongoing second operation on the target storage area.
  • Step S13d when the second operation exists, determine whether the first fine-grained area in the target storage area currently targeted by the first operation and the target storage area currently targeted by the second operation Is there any overlap between the second fine-grained regions of.
  • the first fine-grained region and the second fine-grained region may be any fine-grained regions among the multiple fine-grained regions in the target storage area. It may be that the overall storage area where the target storage area is located is divided into fine-grained areas, and the sizes of the fine-grained areas targeted by operations on the overall storage area are the same.
  • each operation divides the storage area targeted by the operand into fine-grained divisions according to the fine-grained division information carried in each operation, and then different operations can be divided into different granularities for the same storage area.
  • the first fine-grained area can be the first operation to divide the target storage area into any of the fine-grained areas
  • the second fine-grained area can be the second operation to fine-grain the storage area where the operand is located. Any fine-grained area obtained later.
  • the size of the first fine-grained region and the second fine-grained region may be different.
  • the first operation can carry the first fine-grained size (the number of data bits in each fine-grained area), and the first fine-grained size can be set to 64 bits
  • the second operation can carry the second fine-grained size (For example, the number of data bits in each fine-grained area), and the second fine-grained size can be set to 256 bits. That is, when the first operation is performed, every 64 bits is regarded as a fine-grained area, and when the second operation is performed, every 256 bits are regarded as a fine-grained area.
  • the fine-grained size (for example, the number of data bits in each fine-grained area) carried by the first operation and the second operation are both 512 bits.
  • the first operation may also carry the first fine-grained quantity (for example, set to 4), and the second operation may carry the second fine-grained quantity (for example, set to 8). That is, when the first operation is performed, the target storage area is divided into 4 fine-grained areas, and when the second operation is performed, the target storage area is divided into 8 fine-grained areas. It can be understood that the two parameters of fine-grained size and quantity can also be carried in the operation. The size and/or number of each fine-grained region can be determined according to requirements, which is not limited in the present disclosure.
  • the operation on the target storage area is the operation on each fine-grained area in the target storage area.
  • the target storage area A is from row 1 to row 10
  • each row is a fine-grained area
  • the target storage area A includes 10 fine-grained areas.
  • the write operation to the target storage area A can be regarded as the write operation to the 10 fine-grained areas.
  • the execution process can be: write the first fine-grained area (line 1), write the second fine-grained area (line 2) after the first fine-grained area is written, and after the second fine-grained area is written Write the third fine-grained area (line 3), and so on, until the tenth fine-grained area (line 10) is written, and the write operation of the target storage area A is completed.
  • the state of the fine-grained area in the target storage area may include the completed state of the operation, the state of being operated, and the state of not being operated.
  • the state of the fine-grained area currently targeted by the operation is the operation in progress state.
  • the fine-grained area being operated is the fine-grained area currently targeted by the operation.
  • the first fine-grained area in the target storage area currently targeted by the first operation may include the fine-grained area in the target storage area targeted by the first operation to be executed, usually the first operation.
  • a fine-grained area may also include a fine-grained area in the target storage area currently targeted by the first operation being executed, and may be any fine-grained area.
  • the second fine-grained area in the target storage area currently targeted by the second operation may be a fine-grained area in the target storage area currently targeted by the second operation being executed, and may be any fine-grained area.
  • the first fine-grained area in the target storage area currently targeted by the first operation and the current targeted storage area of the second operation can be determined based on the physical address, pointer position, fine-grained area identification, etc. Whether the second fine-grained areas in the target storage area overlap.
  • the current physical address of each operation can be recorded, and the current physical address of the first operation and the current physical address of the second operation, as well as the correspondence between the physical address and the fine-grained area, can be used to determine the current physical address of the first operation.
  • the first fine-grained area in the target storage area and the second fine-grained area in the target storage area currently targeted by the second operation and then it is determined whether the first fine-grained area and the second fine-grained area overlap.
  • the physical address may include one or any combination of the start address, end address, set location address, or real-time operation address of the fine-grained area.
  • a pointer can be set for each operation, and the pointer points to the fine-grained area currently targeted by the operation. According to the pointer position of the first operation and the pointer position of the second operation, respectively determine the first fine-grained area in the target storage area currently targeted by the first operation and the second fine-grained area in the target storage area currently targeted by the second operation.
  • Granularity area determines whether the first fine-grained area overlaps with the second fine-grained area. For another example, it is also possible to set an identifier for each fine-grained region, and determine whether the first fine-grained region overlaps with the second fine-grained region by recording the identifier of the fine-grained region currently targeted by the recording operation.
  • the logo can include any combination of letters, numbers, or symbols. It is also possible to determine whether the first fine-grained region and the second fine-grained region overlap in other ways. The present disclosure does not limit the basis for determining whether the first fine-grained region and the second fine-grained region overlap.
  • Step S14d when there is no overlap between the first fine-grained region and the second fine-grained region, perform the first operation.
  • the first operation A fine-grained area can be a fine-grained area where the second operation has been completed, or a fine-grained area where the second operation does not need to be operated. At this time, executing the first operation will not affect the operation process and operation result of the second operation. If it has an impact, you can perform the first operation.
  • the target storage area of the tensor data indicated by the descriptor can be obtained, and when there is an ongoing second operation on the target storage area, it is possible to determine the first operation. Whether there is an overlap between the first fine-grained area in the target storage area currently targeted by an operation and the second fine-grained area in the target storage area currently targeted by the second operation. If there is no overlap between the two, perform the first operation . In this way, the fine-grained regions of the current operation of the first operation and the second operation can be executed without overlapping, so that the first operation and the second operation can operate on the target storage area at the same time, which improves the processing efficiency of the processor.
  • the method may further include: blocking the first operation when the first fine-grained region overlaps with the second fine-grained region.
  • the first fine-grained region and the second fine-grained region overlap, including the first fine-grained region and the second fine-grained region completely overlap or partially overlap.
  • the operation of the first operation for the overlapped part of the area can affect the execution of the second operation and cause the operation result of the second operation to be inaccurate.
  • the execution of the first operation may be affected and the operation result of the first operation may be inaccurate.
  • the first operation can be blocked, that is, the execution of the first operation can be suspended, and the first operation can be executed after the second operation completes the operation on the second fine-grained area in the target storage area currently targeted. That is, when the first fine-grained area and the second fine-grained area do not overlap, the first operation is performed.
  • the first operation when the first fine-grained region overlaps with the second fine-grained region, the first operation is blocked, which can avoid operation errors and inaccurate operation results caused by the overlap of the fine-grained regions of each operation, and ensure The correctness of each operation.
  • the overall storage area 20d includes a target storage area 21d.
  • the target storage area 21d is divided into 4 fine-grained areas, which are in turn the fine-grained area 22d, the fine-grained area 23d, and the fine-grained area. 24d and fine-grained area 25d.
  • the write pointer wp is used to indicate the fine-grained area in the target storage area 21d currently targeted by the write operation.
  • the write pointer wp points to the fine-grained area 22d, and it can be judged whether there is a second operation in progress for the target storage area 21d. If the judgment result is that there is no second operation, then start the fine-grained area 22d performs a write operation; when the write operation to the fine-grained area 22d is completed, the write pointer wp increases, that is, wp++, and points to the next fine-grained area 23d.
  • the write operation to the fine-grained area 23d is started;
  • the write pointer wp increases and points to the next fine-grained area 24d.
  • the write operation to the fine-grained area 24d is started.
  • the read operation is the first operation and the write operation is the second operation.
  • the write pointer wp of the write operation and the read pointer rp of the read operation use the write pointer wp of the write operation and the read pointer rp of the read operation to respectively indicate the fine-grained area currently targeted by the write operation and the read operation.
  • the read operation (first operation)
  • rp increases, that is, rp++, and points to the next fine-grained region 23d.
  • the first operation starts to operate on the fine-grained region 23d; when the fine-grained region 23d is completed After the read operation of the region 23d, rp increases and points to the next fine-grained region 24d. In this case, continue to determine whether the first fine-grained area and the second fine-grained area overlap.
  • the target storage area 21d currently targeted by the first operation is If the first fine-grained area of is overlapped with the second fine-grained area in the target storage area 21d currently targeted by the second operation, the first operation cannot be performed, and the first operation is blocked.
  • the second operation completes the operation on the fine-grained region 24d, wp increases and points to the next fine-grained region 25d, and the number of the fine-grained region is different (24d and 25d) or the pointer rp ⁇ wp, the first operation can be performed.
  • At least one of the first operation and the second operation may be a write operation. That is, when the operation of the operand is read after write (the second operation is a write operation, the first operation is a read operation), read after write (the second operation is a read operation, and the first operation is a write operation) or write after write (The second operation and the first operation are both write operations), the method in the embodiment of the present disclosure can be used.
  • the first operation is a read operation for the descriptor and the second operation is a write operation
  • the tensor data indicated by the descriptor that needs to be read by the first operation needs to be the data after the write operation of the second operation
  • the second operation If the number of the second fine-grained area in the target storage area is 8, the first operation can only read the data of the fine-grained area whose number is before 8. That is, if the first fine-grained area in the target storage area currently targeted by the first operation is any one of the fine-grained areas numbered 1 to 7, the first operation can be performed.
  • the first operation and the second operation are both read operations, the relationship between the fine-grained regions of the first operation and the second operation will not affect the operation result, and the embodiments of the present disclosure may be adopted In the method in, you can also directly execute the first operation without making a fine-grained area judgment.
  • the target storage area of the tensor data indicated by the descriptor is divided into One or more fine-grained regions, and operations are performed in units of fine-grained regions, so that operations such as read-write, read-write, and write-after-write operations can be performed correctly, get accurate execution results, and reduce the number of operations The waiting time between time, improve the execution efficiency of the processor.
  • the size and/or the number of the fine-grained regions may be determined according to at least one of the area where the data of the set length is located and the area where the data of the set dimension is located.
  • determining the size and/or number of the fine-grained regions may be preset before the operation is generated, or may be determined in real time when each operation is generated.
  • pre-setting the size and/or quantity of the fine-grained area before the operation may include determining the size and/or the size of the fine-grained area according to at least one of the area where the data of the preset length is located and the area where the data of the preset dimension is located /Or quantity.
  • the data of the set length and the data of the preset dimension may be independent of the operands of each operation, or may be comprehensively determined according to the operands of each operation in advance, and may be determined according to requirements.
  • the real-time determination of the size and/or quantity of the fine-grained area when each operation is generated may include determining data of a set length or data of a set dimension according to the operands of each operation, that is, according to the operands of each operation At least one of the area where the data of the set length is located and the area where the data of the set dimension is located are determined in real time, and the size and/or quantity of the fine-grained area is determined.
  • the size and/or number of the fine-grained area can be determined according to the size of the area where the data of the set length is located.
  • the size of the fine-grained area can be set according to the size of the target storage area where the data of the set length in the tensor data indicated by the descriptor is located, and the area can be a fixed bit width.
  • the tensor data B indicated by the descriptor is 20*10*5 three-dimensional data, and its storage method in the target storage area is 40*25 (that is, 40-bit data per row, 25 rows in total), then you can set
  • the fixed length is set to 40 bits, and each row of the target storage area is set as a fine-grained area.
  • the target storage area of tensor data B indicated by the descriptor can be divided into 25 fine-grained areas; the target storage can also be Every 5 rows of the area are set as a fine-grained area, and the target storage area of the tensor data B indicated by the descriptor can be divided into 5 fine-grained areas. This disclosure does not limit this.
  • the size and/or number of the fine-grained area can be determined in the target storage area according to at least one of the area where the data of the set length is located and the area where the data of the set dimension is located, or the size and/or quantity of the fine-grained area may be determined in the target storage area. Determine the size and/or number of fine-grained areas in the overall storage area where the area is located, and determine the size and/or number of fine-grained areas in other areas in the overall storage area.
  • the above example only gives one of the cases.
  • the present disclosure does not limit the determination of the size and/or quantity of the fine-grained area based on at least one of the area where the data of the set length is located and the area where the data of the set dimension is located. range.
  • the size and/or number of the fine-grained area may also be determined according to the size of the area where the data of the set dimension is located.
  • the tensor data C indicated by the descriptor is 20*10 two-dimensional data
  • the target storage area of the tensor data C indicated by the descriptor can be set according to the data whose dimension is 1 dimension and the length is 20. Divided into 10 fine-grained areas.
  • the size and/or quantity of the fine-grained area can be determined simultaneously according to the size of the area where the data of the set length and the size of the area where the data of the set dimension are located in the target storage area of the tensor data indicated by the descriptor.
  • a fine-grained area can be divided according to the data with a set dimension of 2 dimensions and a size of 4*2, so as to store the target of the tensor data C indicated by the descriptor The area is divided into 25 fine-grained areas.
  • the size and/or quantity of the fine-grained area by determining the size and/or quantity of the fine-grained area according to the size of the area where the data of the set length is located and/or the size of the area where the data of the set dimension is located, it can be done based on the data characteristics.
  • the division of fine-grained regions can improve the flexibility of fine-grained region division, thereby improving the efficiency of the execution of multiple operations, and also make the results of fine-grained region division more in line with the characteristics of different operands, thereby adapting to different types of operands
  • the processing requirements of the system further improve the overall execution efficiency of multiple operations.
  • the size and/or number of the fine-grained regions may be determined according to at least one of hardware computing capability and hardware bandwidth.
  • the hardware computing capability may be the amount of data processed in parallel by the hardware in one computing cycle
  • the hardware bandwidth may be the data transmission capability, such as the amount of data transmitted per unit time.
  • the hardware computing capability is to process 100 bits of data in parallel in one calculation cycle, and the hardware bandwidth is to transmit 200 bits of data per unit time.
  • the target storage area can be divided into 10 fine-grained areas according to the hardware computing capabilities, where each fine-grained area includes 100 bits of data; the target storage area can also be divided into 5 fine-grained areas according to the hardware bandwidth, among which, Each fine-grained area includes 200 bits of data.
  • hardware computing capability and hardware bandwidth may be different according to different processor hardware, and the present disclosure does not limit the hardware computing capability and hardware bandwidth.
  • the size and/or number of fine-grained areas can be determined in the target storage area, and the fine-grained areas can also be determined in the overall storage area where the target storage area is located.
  • the size and/or number of areas, and other areas in the overall storage area determine the size and/or number of fine-grained areas.
  • the foregoing example only gives one of the cases, and the present disclosure does not limit the applicable division range for determining the size and/or number of the fine-grained region according to at least one of hardware computing capability and hardware bandwidth.
  • the size and/or number of the fine-grained regions can be determined according to the processing capabilities (hardware computing power and/or hardware bandwidth) of the processor, so that the results of the fine-grained regions are more in line with different hardware usage environments.
  • the demand makes the operations performed according to the fine-grained area tend to be synchronized with the processing capability of the processor, and the execution efficiency of the hardware can be exerted as much as possible, thereby improving the processing efficiency of the processor.
  • the first operation may be an operation in a first processing instruction
  • the second operation may be an operation in a second processing instruction
  • the second processing instruction may be an operation in an instruction queue. The processing instruction before the first processing instruction.
  • the first processing instruction and the second processing instruction may include one or more of data access instructions, operation instructions, synchronization instructions, and communication instructions.
  • the instructions are read and operation instructions.
  • the present disclosure does not limit the specific types of the first processing instruction and the second processing instruction.
  • the first instruction may have a dependency relationship with the second instruction, for example, the first instruction needs to use a dependency relationship such as a calculation result of the second instruction.
  • the first instruction may also have no dependency relationship with the second instruction.
  • the first operation and the second operation may be operations in different instructions.
  • the instruction execution efficiency can be improved.
  • the first operation and the second operation may also be two operations in the same processing instruction, the second operation may be independent of the first operation, or the second operation may be based on the result of the first operation.
  • the processing instruction may include one or more of data access instructions, operation instructions, synchronization instructions, and communication instructions. For example, if the instruction is a "read and add" operation instruction, the first operation is a read operation, and the second operation It is an addition operation.
  • the present disclosure does not limit the specific type of the processing instruction.
  • the method may further include: recording the first location information of the first fine-grained area currently operated by the first operation and the second fine-grained area currently operated by the second operation. Second location information,
  • Step S14d may include: performing the first operation when the first position information is inconsistent with the second position information.
  • the location information may include identification information of a fine-grained area.
  • the identification information can include any combination of numbers, letters and symbols. This disclosure does not limit this.
  • the location information can be represented by the number information of the fine-grained area, and the target storage area can be divided into 6 fine-grained areas, whose numbers are sequentially 0-5.
  • the first location information for example, number 2
  • the second location information of the fine-grained area for example, the number is 5
  • the relationship between the number information (2 ⁇ 5) it can be seen that the first location information is inconsistent with the second location information; at this time, the first operation can be performed .
  • the location information may include fine-grained area address information.
  • the address information may include at least one of the start address information of the fine-grained area, the end address information, the address information of the preset position in the fine-grained area, and the address offset information.
  • the location information of the fine-grained area is ADDR1515-ADDR1531.
  • the location information can be used to directly and efficiently determine whether the first fine-grained area and the second fine-grained area overlap, and determine whether to perform the first operation, which can improve the execution efficiency of the processor.
  • the first location information may include a first number of fine-grained regions where the first operation has been completed
  • the second location information may include the fine-grained regions where the second operation has been completed.
  • executing the first operation may include: when the first operation is an operation after the second operation, and the first number is less than When the second number is reached, the first operation is performed.
  • the first operation is an operation after the second operation, and its target storage area is divided into 6 fine-grained regions, and its location information can be represented by the number of fine-grained regions that have been completed.
  • the first number of fine-grained regions for example, the first number is 3
  • the second number of granular regions for example, the second number is 5
  • the target storage area may include an operable area and a non-operable area
  • step S13d may include: when the second operation exists, and the first operation is currently targeted at the When the first fine-grained area in the target storage area is located in the operable area, it is determined that the first fine-grained area in the target storage area currently targeted by the first operation and the second operation currently targeted at Whether there is overlap between the second fine-grained areas in the target storage area.
  • the target storage area may include one or more inoperable areas, and may also include continuous or discontinuous inoperable areas.
  • the target storage area may include one or more operable areas, and may also include continuous or discontinuous operable areas. This disclosure does not limit this.
  • the target storage area of the tensor data indicated by the descriptor may be obtained first, and then it is determined whether there is an ongoing second operation for the target storage area.
  • Second operation when there is a second operation, determine whether the first fine-grained area in the target storage area targeted by the first operation is located in the operable area; when there is a second operation, and the target storage area targeted by the first operation
  • the first fine-grained area in is located in the operable area, then determine the first fine-grained area in the target storage area targeted by the first operation and the second fine-grained area in the target storage area targeted by the second operation Whether there is overlap between them; when there is no overlap between the first fine-grained area and the second fine-grained area, perform the first operation.
  • the non-operable area may include a prohibited operation area and a non-prohibited operation area. If the first operation is a write operation for the descriptor, when part of the data in the tensor data indicated by the descriptor cannot be modified, the storage area where the part of the data is located can be set as a prohibited operation area to avoid incorrectly modifying the data Part of the data; if the second operation in progress is a read operation (read and write) that reads the data before the first operation, one or more fine-grained areas where the second operation is located can be set as a non-prohibited operation area After the second operation completes the reading of the non-prohibited operation area, the non-prohibited operation area can be changed to an operable area.
  • the present disclosure does not limit the classification and division of non-operable areas.
  • the non-operational area may be a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is within the non-operational area
  • the position of is updated with the operation position of the second operation
  • the method may further include: after the second fine-grained area in the target storage area targeted by the second operation moves out of the non-operational area, Update the position of the non-operational area.
  • the non-operable areas of multiple fine-grained areas including the second fine-grained area may not be updated with the update of the second fine-grained area in the target storage area targeted by the second operation. After the second fine-grained area in the target storage area targeted by the operation is moved out of the non-operational area, the position of the non-operational area is updated.
  • the non-operable area may be R fine-grained areas including the second fine-grained area (R is an integer greater than 1), and the current non-operable area includes the 2nd to 2nd+R-1 Fine-grained areas.
  • the non-operational region of includes 2+R to 2+R+R-1 fine-grained regions. Among them, the size of R can be arbitrarily determined according to requirements.
  • the target storage area 30d includes 8 fine-grained regions, and the operable region includes 5 fine-grained regions (fine-grained region 31d, fine-grained region 35d, fine-grained region 36d, fine-grained region 37d, and fine-grained region).
  • the non-operable area M0 includes three fine-grained areas (the fine-grained area 32d, the fine-grained area 33d, and the fine-grained area 34d).
  • the second fine-grained area in the target storage area 30d currently targeted by the second operation is the fine-grained area 32d.
  • the second fine-grained area in the target storage area 30d currently targeted by the second operation is the fine-grained area 33d.
  • the target currently targeted by the second operation The second fine-grained area (fine-grained area 33d) in the storage area 30d is not moved out of the non-operable area, and the position of the non-operable area is not updated; when the second operation is performed on the fine-grained area 33d, the second operation The second fine-grained area in the target storage area 30d currently targeted is the fine-grained area 34d.
  • the second fine-grained area (fine-grained area 34d) in the target storage area 30d currently targeted by the second operation has not The non-operable area is moved out, and the position of the non-operable area is not updated; after the second operation is performed on the fine-grained area 34d, the second fine-grained area in the target storage area 30 currently targeted by the second operation is fine Granularity area 35d.
  • the second fine-grained area (fine-grained area 35d) in the target storage area 30d currently targeted by the second operation has moved out of the non-operable area, and the position of the non-operable area is updated to the fine-grained area 35d , 36d and 37d). It should be noted that the present disclosure does not limit the size of the non-operable area.
  • the operable area includes 5 fine-grained regions (fine-grained region 31d, fine-grained region 32d, fine-grained region 33d, fine-grained region 34d and the fine-grained region 38d)
  • the non-operable region M0 includes three fine-grained regions (the fine-grained region 35d, the fine-grained region 36d, and the fine-grained region 37d).
  • the non-operational area may be a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is located in the non-operational area The position of the non-operable area is updated with the operating position of the second operation.
  • the position of the second fine-grained area in the non-operable area is updated with the operating position of the second operation.
  • the non-operable area may be R fine-grained areas including the second fine-grained area, and the current non-operable area includes the second to 2+R-1 fine-grained areas, and the second fine-grained area
  • the set position of the area in the non-operable area is the Sth (where S ⁇ R).
  • the second operation After the execution of the second operation completes the operation on the current fine-grained area, the second operation starts to execute the operation for the next fine-grained area.
  • the position of the non-operable area is updated with the operation position of the second operation .
  • the updated non-operational area includes the 2+1th to 2+Rth fine-grained areas.
  • the size of R and the value of S can be determined according to requirements.
  • the present disclosure does not limit the number of fine-grained regions included in the non-operable region and the position of the second fine-grained region in the non-operable region.
  • Figures 7a and 7b show schematic diagrams of application scenarios of a processor operating method according to an embodiment of the present disclosure.
  • the target storage area 40 includes 8 fine-grained regions, where the operable region includes 5 fine-grained regions (fine-grained region 41, fine-grained region 45, fine-grained region 46, fine-grained region 47, and The fine-grained region 48), the non-operable region M1 includes three fine-grained regions (the fine-grained region 42, the fine-grained region 43, and the fine-grained region 44).
  • the second fine-grained area in the target storage area 40 currently targeted by the second operation is set as the second fine-grained area located in the non-operable area M1, that is, the fine-grained area 43.
  • the second fine-grained area in the target storage area 40 currently targeted by the second operation is the fine-grained area 44.
  • the position of the non-operable area follows the first The operation position of the second operation is updated, so that the second fine-grained area in the target storage area 40 currently targeted by the second operation is located in the second fine-grained area of the non-operable area M1.
  • the operable area includes 5 fine-grained areas (fine-grained area 41, fine-grained area 42, fine-grained area 46, fine-grained area) 47 and fine-grained region 48)
  • the non-operable region M1 includes 3 fine-grained regions (fine-grained region 43, fine-grained region 44, and fine-grained region 45).
  • the position of the non-operable area can be updated in real time, and the degree of synchronization of fine-grained processing can be improved, thereby further improving the efficiency of data synchronization processing.
  • the target storage area may include: a circular buffer storage area.
  • the circular buffer storage area can be used to circularly store data.
  • Fig. 8 shows a schematic diagram of a circular buffer storage area of a processor operating method according to an embodiment of the present disclosure.
  • the target storage area 50 includes a circular buffer storage area 51 whose addresses are start_addr to end_addr.
  • the second operation is a write operation, and the operand can be written into the circular buffer storage area 51.
  • the address pointer point starts from the start address start_addr and stores data sequentially until the end address end_addr, which occupies the circular buffer storage area. 51 storage space, at this time, the address pointer point jumps back to start_addr to determine whether the address is used up by the first operation that needs to be synchronized. If it is used up, the data will be stored to this address, overwriting the original data, and then the address The pointer point moves downward in turn until end_addr, at which point the data can be overwritten again, and the above process is repeated.
  • the circular buffer storage area is used to store data, which can save data storage space and improve storage space utilization.
  • the circular buffer storage area can be divided into multiple fine-grained areas. For each fine-grained area, whether the data in the fine-grained area can be covered can be managed through a list or flag bit or other methods. For example, the coverage flag can be set to indicate whether the data in the fine-grained area can be overwritten.
  • the first operation is a read operation
  • the second operation is a write operation, that is, write first and then read.
  • the write pointer wp and the read pointer rp may be used to indicate the fine-grained area currently targeted by the second operation and the first operation, respectively.
  • the coverage flag of the second fine-grained area currently targeted by the second operation is overwritable, the second operation can be performed to write data.
  • the first operation can be performed to read the data.
  • the circular buffer access area is divided into multiple fine-grained areas, so that multiple operations can simultaneously operate on the circular buffer storage area, thereby improving the processing efficiency of the processor.
  • the fine-grained area may include a status identifier
  • the state identifier may include whether an operation for the fine-grained area is in a completed state or an incomplete state
  • Step S14d may include: when there is no overlap between the first fine-grained region and the second fine-grained region, judging whether the status identifier of the first fine-grained region is a completed state; if so, executing the First operation.
  • the fine-grained area may include a state identifier
  • the state identifier may include a completed state or an uncompleted state of the operation in the fine-grained area.
  • the status identifier can be represented by 0 and 1, where 0 represents the unfinished status of the fine-grained area of the operation, 1 represents the completed status of the fine-grained area of the operation, or 0 represents the completed state of the fine-grained area of the operation, and 1 represents The incomplete state of the operation fine-grained area.
  • the present disclosure does not limit the manner in which the status flag is expressed.
  • the second operation may set the status identifier of the fine-grained area that has been completed in the target storage area to the completed state, and the status identifier of the fine-grained area that is not operated or being operated to be incomplete. status. It is also possible to set the state identifiers of some fine-grained regions in the fine-grained regions that have completed the operation to the completed state, and set other fine-grained regions to the incomplete state. For example, if the second operation has completed 5 fine-grained regions, the status flags of the first 3 fine-grained regions may be set to the completed state, and the other fine-grained regions may be set to the incomplete state.
  • the first fine-grained area currently targeted by the first operation and the second fine-grained area currently targeted by the second operation After determining that there is no overlap between the first fine-grained region and the second fine-grained region, determine whether the status identifier of the first fine-grained region is a completed state; if the status identifier of the first fine-grained region is a completed state, The first operation can be performed.
  • the fine-grained area includes a state identifier.
  • the first operation is executable according to the state identifier of the first fine-grained area. While improving the processing efficiency of the processor, it also improves the accuracy of data processing.
  • the fine-grained area may include a status identifier
  • the state identifier may include that an operation for the fine-grained area is in a completed state or an incomplete state
  • Step S14d may include: judging whether the status indicator of the first fine-grained region is a completed state; if so, executing the first fine-grained region and the second fine-grained region when there is no overlap. First operation.
  • the first fine-grained area currently targeted by the first operation and the second fine-grained area currently targeted by the second operation can be determined After the state of a fine-grained region is marked as a completed state, it is determined whether the first operation is executable according to the overlap relationship between the first fine-grained region and the second fine-grained region. When there is no overlap between the first fine-grained region and the second fine-grained region, the first operation may be performed.
  • the fine-grained area includes a status indicator. After determining that the status indicator of the first fine-grained area is a completed state, the first fine-grained area and the second fine-grained area can be determined according to the overlap relationship between the first and second fine-grained areas. Whether the operation is executable can improve the accuracy of data processing and the processing efficiency of the processor.
  • the second operation is an operation on the descriptor.
  • the operand of the second operation is the same as the operand of the first operation, that is, the second operation and the first operation are operations for the same descriptor, and the storage area of the operand of the second operation is completely the target storage area. overlapping.
  • the target storage area of the tensor data indicated by the descriptor can be divided into multiple fine-grained areas, according to the method in the embodiment of the present disclosure, two operations that operate on the same descriptor can be executed in parallel without affecting the performance of each operation. Results of the.
  • the first fine-grained area and the second fine-grained area may be determined respectively according to the execution process of the operation.
  • the current target storage area for the first operation is The first fine-grained area is a fine-grained area in the target storage area to be executed by the first operation.
  • the first fine-grained area in the target storage area currently targeted by the first operation is usually the first fine-grained area of the target storage area.
  • the second fine-grained area in the target storage area currently targeted by the second operation in progress may be related to the execution process of the second operation.
  • the second fine-grained area may also be the first fine-grained area of the target storage area. At this time, the first fine-grained area overlaps with the second fine-grained area. If the second operation has completed the operation of the first fine-grained area, and the second fine-grained area in the current target storage area is the P-th fine-grained area (P is an integer greater than 1), then the first fine-grained area The area does not overlap with the second fine-grained area.
  • the first operation when determining whether there is a second operation on the target storage area in progress during the operation of the first operation on the target storage area, the first operation may be determined according to the execution process of the first operation.
  • the second fine-grained region is determined according to the execution process of the second operation, and then it is determined whether the first fine-grained region and the second fine-grained region overlap.
  • the first operation may be performed.
  • the consistent beat means that when the size of the fine-grained region is the same, the operation duration of two operations for a fine-grained region is the same.
  • the method in the embodiment of the present disclosure can be used to realize the parallel execution of two or more operations for the same descriptor, or Determine the fine-grained area currently targeted by each operation according to the execution process of each operation.
  • the first fine-grained area and the second fine-grained area perform the first operation, so that two of the same descriptor Or multiple operations can be executed in parallel without affecting the execution effect of each operation, thereby improving the execution efficiency of the processor.
  • the storage area of the operand of the second operation overlaps with the target storage area.
  • the storage area of the operand of the second operation when the storage area of the operand of the second operation overlaps with the target storage area, and the second operation is performing an operation for the overlap area, the storage area of the operand of the second operation can be changed
  • the target storage area is divided into multiple fine-grained areas, or the overall storage area where the target storage area is located is divided into multiple fine-grained areas, and then according to the method in the embodiments of the present disclosure, the fine-grained areas in the overlapping area A judgment is made to determine whether the first operation can be performed, so that two operations with overlapping regions in the storage area of the operand can be executed in parallel without affecting the execution result of each operation.
  • the second operation is an operation on a descriptor
  • the descriptor targeted by the second operation is different from the descriptor targeted by the first operation
  • it can be based on whether the description is allowed when creating the descriptor
  • the storage area of the tensor data indicated by the symbol overlaps to determine whether the storage area of the operand of the second operation and the target storage area may overlap.
  • the descriptor for the second operation is the same as the descriptor for the first operation. At different times, the storage area of the tensor data indicated by the descriptor for the second operation does not overlap with the target storage area, and the fine-grained areas of the first operation and the second operation do not overlap.
  • the operation of the descriptor makes a fine-grained area judgment.
  • the descriptor targeted by the second operation is different from the descriptor targeted by the first operation.
  • the storage area of the descriptor targeted by the second operation may overlap with the target storage area indicated by the descriptor targeted by the first operation.
  • the method in the embodiment of the present disclosure may be used to make the target storage area have an overlapped area. The two operations of different descriptors can be executed in parallel.
  • the method in the embodiment of the present disclosure can be used to implement parallel execution of two or more operations, thereby improving the execution of the processor. effectiveness.
  • the method may further include: dividing the overall storage area where the target storage area is located into multiple fine-grained areas.
  • the target storage area may be a part or all of the storage area in the overall storage area of the storage device, and the overall storage area includes a plurality of preset fine-grained areas.
  • the overall storage area where the target storage area is located is RAM1, which may include m pre-set fine-grained areas (m is a positive integer).
  • the target storage area may also include a part of a fine-grained area.
  • each fine-grained area is a row in the overall storage area RAM1, and each row is 100 bits.
  • the target storage area may include the previous (n-1) complete fine-grained areas and part of the last fine-grained area, such as the first 80 in the nth row (nth fine-grained area) in RAM1 Bits.
  • any operation on any target storage area in the overall storage area regardless of the descriptor for the first operation
  • the target storage area of the indicated tensor data or the overlap area between the storage area of the operand of the second operation and the target storage area can be determined according to the result of fine-grained division of the overall storage area.
  • Fine-grained areas The arbitrary operand of any operation is stored in the middle storage area of the overall storage area, and has a fine-grained area of the same size.
  • the size and/or number of fine-grained areas of the overall storage area can be determined according to the hardware characteristics of the storage device, that is, according to at least one of the hardware computing capability and hardware bandwidth of the storage device, Determine the size and/or number of fine-grained areas of the overall storage area.
  • the overall storage area where the target storage area is located is divided into multiple fine-grained areas. Any operation on any target storage area in the overall storage area can be performed in the same fine-grained size, and different operations are performed according to this
  • the methods in the disclosed embodiments are parallel, synchronization can be more convenient, operation parallelism is improved, and processing efficiency of the processor is improved.
  • the method may further include:
  • the target storage area is divided into multiple fine-grained areas
  • the storage area of the operand of the second operation is divided into multiple fine-grained areas.
  • fine-grained division information may be carried in the operation, and the fine-grained division information may include fine-grained size and/or quantity.
  • Different operations can carry different fine-grained information.
  • the same type of operation can carry the same fine-grained division information.
  • the fine-grained division information can be carried in the setting position of the operand in the operation, and the identification information of whether to carry out the fine-grained division can also be carried in the operation code or the operand.
  • the present disclosure does not limit the content and expression of the fine-grained information.
  • the target storage area is divided into a plurality of first fine-grained areas according to the first fine-grained division information carried in the first operation.
  • the other areas in the overall storage area where the tensor data indicated by the descriptor targeted by the first operation are located may not be fine-grained division, or may be fine-grained according to the fine-grained division information carried by other operations. This disclosure does not limit this.
  • the storage area of the operand of the second operation completely overlaps the target storage area.
  • the first fine-grained division information and the second fine-grained division information may be consistent or inconsistent.
  • the target storage area may be fine-grained division according to the second fine-grained division information at the same time. That is, for the target storage area, different operations can divide it into multiple fine-grained areas of different sizes or numbers.
  • the physical address between the first fine-grained area in the target storage area currently targeted by the first operation and the physical address between the second fine-grained area in the target storage area currently targeted by the second operation can be used , Determine whether the first fine-grained area and the second fine-grained area overlap, and perform the first operation and the second operation in parallel according to the determination result.
  • the fine-grained division information carried in each operation may include at least one of the area where the operation data of the set length is located and the area where the operand of the set dimension is located. The size and/or number of fine-grained regions are described, so that the result of fine-grained division is more consistent with the type or attribute of the operand in the operation.
  • the target storage area is divided into multiple fine-grained areas
  • the second fine-grained division information carried in the second operation the second The storage area of the operand of the operation is divided into multiple fine-grained areas.
  • the descriptor can be used to indicate the shape of N-dimensional tensor data, where N is an integer greater than or equal to zero, and the content of the descriptor can include a shape representing the shape of the tensor data. At least one shape parameter.
  • the descriptor can be used to indicate the shape of N-dimensional tensor data.
  • the value of N can be determined according to the dimensionality (order) of the tensor data, or can be set according to the needs of the tensor data.
  • tensor data is three-dimensional data, and the value of N can be 3 (determined according to the number of dimensions), and the descriptor can be used to indicate the shape of the tensor data in three dimensions (such as offset, size, etc.) . It should be understood that those skilled in the art can set the value of N according to actual needs, which is not limited in the present disclosure.
  • the descriptor may include identification and content, etc.
  • the identifier of the descriptor may be used to distinguish the descriptor, for example, a number;
  • the content of the descriptor may include at least one shape representing the shape of the tensor data Parameters (such as the dimensions of the tensor in each dimension, etc.).
  • the present disclosure does not limit the specific shape parameters included in the content of the descriptor.
  • the descriptor can be used to indicate the shape of the tensor data, and the relationship between multiple tensor data can be determined by the shape of the tensor data indicated by the descriptor, thereby improving the access efficiency of the processor .
  • the identifier and content of the descriptor can be stored in the descriptor storage space, which can be the internal memory of the control unit (for example, registers, on-chip SRAM or other media cache, etc.) Storage space.
  • the target storage area of the tensor data indicated by the descriptor may be a storage space in the internal memory of the control unit (for example, an on-chip cache) or an external memory (off-chip memory) connected to the control unit.
  • the data address in the target storage area may be an actual physical address or a virtual address.
  • the present disclosure does not limit the location of the descriptor storage space and target storage area, and the type of data address.
  • the identifier and content of the descriptor and the tensor data indicated by the descriptor can be located in the same area.
  • a continuous area of the on-chip cache can be used to store the relevant content of the descriptor
  • the address is ADDR0-ADDR1023, where the address ADDR0-ADDR31 can be used to store the identifier of the descriptor, the address ADDR32-ADDR63 can be used to store the content of the descriptor, and the address ADDR64-ADDR1023 can be used to store the tensor data indicated by the descriptor.
  • the address ADDR is not limited to one bit or one byte. It is used here to indicate an address and is an address unit. Those skilled in the art can determine the storage area and its address according to the actual situation, which is not limited in the present disclosure.
  • 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.
  • a register can be used as a descriptor storage space, and the description can be stored in the register.
  • the identifier and content of the symbol use the on-chip cache as the overall storage area to store the tensor data indicated by the descriptor.
  • a special register (SR) dedicated to the descriptor can also be set, and the data in the descriptor can be an immediate value or can be obtained from a special register.
  • the number of the register can be used to represent the identifier of the descriptor. For example, when the number of the register is 0, the identifier of the stored descriptor is 0.
  • an area can be allocated in the cache space according to the size of the tensor data indicated by the descriptor (for example, a tensor cache unit is created for each tensor data in the cache) for storing the Tensor data. It should be understood that a preset cache space may also be used to store the tensor data, which is not limited in the present disclosure.
  • the identifier and content of the descriptor can be stored in the internal memory, and the tensor data indicated by the descriptor can be stored in the external memory.
  • a method of storing the identifier and content of the descriptor on the chip, and storing the tensor data indicated by the descriptor off the chip may be adopted.
  • the data address of the storage area corresponding to the identifier of the descriptor may be a fixed address.
  • a separate storage area can be divided for tensor data, and the starting address of each tensor data in the storage area corresponds to the identifier of the descriptor one-to-one.
  • the target storage area of the tensor data indicated by the descriptor can be directly determined.
  • the descriptor may also be used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor may further include at least one address parameter representing the address of the tensor data.
  • the descriptor can also be used to indicate the address of N-dimensional tensor data, where the address can be, for example, the start address, address offset, register address, or other address of the tensor data.
  • the address may be the starting address of tensor data.
  • the data address of the storage area corresponding to the identifier of the descriptor is a fixed address
  • the starting address of the N-dimensional tensor data indicated by the descriptor is the fixed address
  • the starting address of the N-dimensional tensor data indicated by the descriptor can be determined according to its specific storage area. This disclosure does not limit this.
  • the content of the descriptor may further include at least one address parameter representing the address of the tensor data.
  • a descriptor can be used to indicate the address of the tensor data, and the content of the descriptor can include an address parameter indicating the address of the tensor data (such as the start of the tensor data) Address), it may also include multiple address parameters of the address of the tensor data (for example, the starting address of the tensor data + the address offset, or the address parameters of the tensor data based on each dimension).
  • Those skilled in the art can set the address parameters according to actual needs, which is not limited in the present disclosure.
  • the descriptor can be used to indicate the address of the tensor data, and the relationship between multiple tensor data can be determined by the address of the tensor data indicated by the descriptor, thereby improving the access efficiency of the processor .
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the overall storage area where the tensor data is located;
  • the shape parameter of the tensor data includes at least one of the following:
  • the size of the overall storage area where the tensor data is located in at least one of the N dimensional directions, the size of the storage area of the tensor data in at least one direction of the N dimensional directions, and the size of the tensor data The offset of the storage area in at least one of the N dimensional directions, the position of the at least two vertices in the diagonal positions of the N dimensional directions relative to the data reference point, and the tensor indicated by the descriptor
  • the data of the data describes the mapping relationship between the location and the data address.
  • the address parameter of the tensor data includes the reference address of the data reference point of the descriptor in the overall storage area where the tensor data is located.
  • the reference address can be different according to the change of the data reference point.
  • the present disclosure does not limit the selection of data reference points.
  • the reference address may include the start address of the entire storage area.
  • the reference address of the descriptor is the starting address of the overall storage area.
  • the reference address of the descriptor is the physical address of the data block in the overall storage area.
  • the shape parameter of the tensor data includes at least one of the following: the size of the overall storage area where the tensor data is located in at least one of the N dimensional directions, and the storage area of the tensor data is in N The size in at least one of the two dimensional directions, the offset of the storage area of the tensor data in at least one of the N dimensional directions, and the at least two vertices in the diagonal positions of the N dimensional directions relative to the The mapping relationship between the position of the data reference point and 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 region in the tensor data indicated by the descriptor.
  • the descriptor can be represented by 3D space coordinates (x, y, z)
  • the shape of the tensor data and the data description position of the tensor data may be the position of a point or area in the three-dimensional space that the tensor data is mapped to, which is represented by three-dimensional space coordinates (x, y, z).
  • the overall storage area 21 stores a two-dimensional data in a row-first manner, which can be represented by (x, y) (where the X-axis goes horizontally to the right and the Y-axis goes vertically downwards), and the X-axis direction
  • the size (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)
  • ori_y not shown in the figure
  • the start address of the overall storage area 21 is PA_start (reference Address) is the physical address of the first data block 22.
  • the data block 23 is the tensor data in the overall storage area 21.
  • the offset 25 in the X-axis direction is denoted as offset_x
  • the offset 24 in the Y-axis direction is denoted as offset_y
  • the size in the X-axis direction Denoted as size_x
  • the size in the Y-axis direction as size_y.
  • the data reference point of the descriptor can use the first data block of the overall storage area 21, and the reference address of the descriptor is the start of the overall storage area 21.
  • the starting address PA_start can then be combined with the size ori_x of the overall storage area 21 on the X axis, the size ori_y on the Y axis, and the offset of the data block 23 in the Y axis direction offset_y, the offset amount 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 determine the content of the descriptor of the data block 23.
  • the descriptor describes a two-dimensional space
  • those skilled in the art can set the dimension represented by the content of the descriptor according to the actual situation, which is not limited in the present disclosure.
  • the data reference point of the descriptor can be determined based on the reference address of the data reference point in the overall storage area, and the positions of at least two vertices at diagonal positions in N dimensions relative to the data reference point. Describes the content of the tensor data descriptor.
  • the reference address PA_base of the data reference point of the descriptor in the overall storage area and the positions of the two diagonal vertices relative to the data reference point can be used to determine the value of the descriptor of the data block 23 in FIG. 2 content.
  • one piece of data (for example, data at position (2, 2)) can be selected as the data reference point in the overall storage area 21 ,
  • the physical address of the data in the overall storage area 21 is used as the reference address PA_base; then, determine the position of at least two vertices of the diagonal position of the data block 23 relative to the data reference point, for example, use the upper left to lower right direction
  • PA_base the upper left vertex
  • the relative position (x_min, y_min) of and the relative position (x_max, y_max) of the vertex of the lower right corner determine the content of the descriptor of the data block 73.
  • the reference address of the data reference point of the descriptor in the overall storage area and the mapping relationship between the data description position of the tensor data indicated by the descriptor and the data address can be determined. Describes the content of the tensor data descriptor. Among them, the mapping relationship between the data description location and the data address can be set according to actual needs. For example, when the tensor data indicated by the descriptor is three-dimensional spatial data, the function f(x, y, z) can be used to define The data describes the mapping relationship between the location and the data address.
  • mapping relationship between the data description location and the data address can be set according to the actual situation, which is not limited in the present disclosure.
  • the reference address of the tensor data and at least one shape reference can be used to determine the content of the descriptor, so that different descriptors can be used according to the processing needs of each operation.
  • the position of the descriptor in the descriptor storage space can be determined, and then the content of the descriptor can be obtained from the descriptor storage space; then, the content of the descriptor can be determined
  • the data address of the tensor data indicated by the descriptor in the overall storage area can be done automatically by hardware or realized by software.
  • the calculation method of the data address of the tensor data indicated by the descriptor in the overall storage area can also be different.
  • the offset of the tensor data indicated by the descriptor in the overall storage area is offset_x and offset_y, and the size is size_x*size_y, then,
  • the starting data address PA1 (x, y) of the tensor data indicated by the descriptor in the overall storage area can be determined by the following formula (4):
  • PA1 (x,y) PA_start+(offset_y-1)*ori_x+offset_x (4)
  • PA2 (x,y) PA_start+(offset_y+y q -1)*ori_x+(offset_x+x q ) (5)
  • the content of the descriptor can be obtained according to the identifier of the descriptor; and according to the content of the descriptor, the data address of the tensor data indicated by the descriptor in the overall storage area can be determined; according to the data address, Determine the target storage area of the tensor data indicated by the descriptor.
  • the descriptor can be used in the data access process, thereby reducing the complexity of data access and improving the processing efficiency of the processor.
  • Fig. 3d shows a block diagram of a processor operating device according to an embodiment of the present disclosure.
  • the processor operating device includes:
  • the area determining module 81 is configured to obtain the target storage area of the tensor data indicated by the descriptor when the first operation is an operation on the descriptor;
  • the operation judgment module 82 is configured to judge whether there is an ongoing second operation for the target storage area
  • the overlap judging module 83 is configured to judge the first fine-grained area in the target storage area currently targeted by the first operation and the second operation currently targeted when the second operation exists. Whether there is overlap between the second fine-grained areas in the target storage area;
  • the execution module 84 is configured to execute the first operation when there is no overlap between the first fine-grained area and the second fine-grained area.
  • the device further includes: an execution control module, configured to block the first operation when the first fine-grained region overlaps with the second fine-grained region.
  • At least one of the first operation and the second operation is a write operation.
  • the size and/or number of the fine-grained regions are determined according to at least one of the region where the data of the set length is located and the area where the data of the set dimension is located.
  • the size and/or number of the fine-grained regions are determined according to at least one of hardware computing capability and hardware bandwidth.
  • the first operation is an operation in a first processing instruction
  • the second operation is an operation in a second processing instruction
  • the second processing instruction is an operation in the instruction queue. The processing instruction before the first processing instruction.
  • the device further includes: a position recording module, configured to record first position information of the first fine-grained area of the current operation of the first operation and the second operation of the second operation. Second location information of the fine-grained area,
  • the execution module 84 includes: a first execution sub-module, configured to execute the first operation when the first location information is inconsistent with the second location information.
  • the first location information includes a first number of fine-grained regions where the first operation has been completed
  • the second location information includes the first number of fine-grained regions where the second operation has been completed.
  • the first execution submodule is further configured to execute the first operation when the first operation is an operation after the second operation, and the first number is less than the second number.
  • the target storage area includes an operable area and an inoperable area
  • the overlap judgment module 83 includes a judgment submodule, which is used when the second operation exists, and the When the first fine-grained area in the target storage area currently targeted by the first operation is located in the operable area, determine the first fine-grained area in the target storage area currently targeted by the first operation Whether it overlaps with the second fine-grained area in the target storage area currently targeted by the second operation.
  • the non-operable area is a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is within the inoperable area.
  • the position is updated with the operating position of the second operation, and the device further includes: an update module for when the second fine-grained area in the target storage area targeted by the second operation moves out of the inoperable After the area, the position of the non-operable area is updated.
  • the non-operable area is a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is located within the inoperable area.
  • the position is set, and the position of the non-operable area is updated with the operating position of the second operation.
  • the target storage area includes: a circular buffer storage area.
  • the fine-grained area includes a state identifier
  • the state identifier includes that an operation for the fine-grained area is in a completed state or an incomplete state
  • the execution module 84 includes:
  • the first state judgment sub-module is configured to judge whether the state identifier of the first fine-grained region is a completed state when there is no overlap between the first fine-grained region and the second fine-grained region;
  • the second execution submodule is configured to execute the first operation when the state of the first fine-grained area is identified as a completed state.
  • the fine-grained area includes a state identifier
  • the state identifier includes that an operation for the fine-grained area is in a completed state or an incomplete state
  • the execution module 84 includes:
  • the second state judgment sub-module is used to judge whether the state identifier of the first fine-grained area is a completed state
  • the third execution sub-module is configured to execute the first fine-grained area when the state of the first fine-grained area is marked as a completed state, and the first fine-grained area and the second fine-grained area do not overlap. One operation.
  • the second operation is an operation on the descriptor.
  • the storage area of the operand of the second operation overlaps with the target storage area.
  • the device further includes: a first setting module, configured to divide the overall storage area where the target storage area is located into multiple fine-grained areas.
  • the device further includes:
  • the second setting module is configured to divide the target storage area into multiple fine-grained areas according to the first fine-grained division information carried in the first operation, and
  • the third setting module is configured to divide the storage area of the operand of the second operation into multiple fine-grained areas according to the second fine-grained division information carried in the second operation.
  • the descriptor is used to indicate the shape of N-dimensional tensor data, and N is an integer greater than or equal to zero, wherein the content of the descriptor includes at least the shape of the tensor data A shape parameter.
  • the descriptor is also used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • the address parameter of the tensor data includes the reference address of the data reference point of the descriptor in the overall storage area where the tensor data is located;
  • the shape parameter includes at least one of the following: the size of the overall storage area where the tensor data is located in at least one of the N dimensional directions, and the storage area of the tensor data in at least one direction of the N dimensional directions.
  • an artificial intelligence chip is also disclosed, which includes the aforementioned processor operating device.
  • a board card which includes a storage device, an interface device, a control device, and the aforementioned artificial intelligence chip; wherein, the artificial intelligence chip and the storage device and the control device And the interface devices are respectively connected; the storage device is used to store data; the interface device is used to implement data transmission between the artificial intelligence chip and external equipment; the control device is used to The state of the artificial intelligence chip is monitored.
  • the storage device includes: multiple groups of storage units, each group of the storage unit is connected to the artificial intelligence chip by a bus, the storage unit is: DDR SDRAM; the chip includes : DDR controller, used to control the data transmission and data storage of each storage unit; the interface device is: a standard PCIE interface.
  • a processor operation method comprising:
  • the first operation is an operation on a descriptor, obtaining the target storage area of the tensor data indicated by the descriptor;
  • the second operation it is determined that the first fine-grained area in the target storage area currently targeted by the first operation and the second fine-grained area in the target storage area currently targeted by the second operation are determined. Whether there is overlap between fine-grained areas;
  • the first operation is performed.
  • A3 The method of claim A1, wherein at least one of the first operation and the second operation is a write operation.
  • A4 The method according to claim A1, wherein the size and/or number of the fine-grained regions are determined according to at least one of the region where the data of the set length is located and the area where the data of the set dimension is located.
  • A5. The method according to claim A1, wherein the size and/or number of the fine-grained regions are determined according to at least one of hardware computing capability and hardware bandwidth.
  • A6 The method according to claim A1, wherein the first operation is an operation in a first processing instruction, the second operation is an operation in a second processing instruction, and the second processing instruction is an operation in an instruction queue The processing instruction before the first processing instruction.
  • performing the first operation includes:
  • A8 The method according to claim A7, wherein the first location information includes a first number of fine-grained regions where a first operation has been completed, and the second location information includes a fine-grained regions where a second operation has been completed The second quantity,
  • performing the first operation includes:
  • the first operation is an operation after the second operation, and the first number is less than the second number, the first operation is performed.
  • the target storage area includes an operable area and a non-operable area
  • the target storage area currently targeted by the first operation is determined Whether there is an overlap between the first fine-grained area in and the second fine-grained area in the target storage area currently targeted by the second operation includes:
  • the second operation exists and the first fine-grained area in the target storage area currently targeted by the first operation is located within the operable area, it is determined that the first operation currently targeted Whether the first fine-grained area in the target storage area overlaps with the second fine-grained area in the target storage area currently targeted by the second operation.
  • the inoperable area is a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is in the inoperable area
  • the position within is updated with the operating position of the second operation, and the method further includes:
  • the position of the non-operational area is updated.
  • non-operable area is a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is located in the inoperable area Set position within,
  • the position of the non-operable area is updated with the operating position of the second operation.
  • the target storage area comprises: a circular buffer storage area.
  • A13 The method according to claim A1, wherein the fine-grained area includes a status indicator, and the state indicator includes that an operation for the fine-grained area is in a completed state or an uncompleted state,
  • performing the first operation includes:
  • A14 The method according to claim A1, wherein the fine-grained area includes a state identifier, and the state identifier includes that an operation for the fine-grained area is in a completed state or an uncompleted state,
  • performing the first operation includes:
  • the second operation is an operation on the descriptor.
  • the overall storage area where the target storage area is located is divided into multiple fine-grained areas.
  • the target storage area is divided into multiple fine-grained areas
  • the storage area of the operand of the second operation is divided into multiple fine-grained areas.
  • the content of the descriptor includes at least one shape parameter representing the shape of the tensor data.
  • descriptor is further used to indicate the address of N-dimensional tensor data, wherein the content of the descriptor further includes at least one address parameter representing the address of the tensor data.
  • the address parameter of the tensor data includes a reference address of the data reference point of the descriptor in the overall storage area where the tensor data is located;
  • the shape parameter of the tensor data includes at least one of the following:
  • the size of the overall storage area where the tensor data is located in at least one of the N dimensional directions, the size of the storage area of the tensor data in at least one direction of the N dimensional directions, and the size of the tensor data The offset of the storage area in at least one of the N dimensional directions, the position of the at least two vertices in the diagonal positions of the N dimensional directions relative to the data reference point, and the tensor indicated by the descriptor
  • the data of the data describes the mapping relationship between the location and the data address.
  • a processor operating device comprising:
  • An area determining module configured to obtain a target storage area of the tensor data indicated by the descriptor when the first operation is an operation on the descriptor
  • An operation judgment module configured to judge whether there is an ongoing second operation for the target storage area
  • An overlap judging module configured to judge the first fine-grained area in the target storage area currently targeted by the first operation and the target currently targeted by the second operation when the second operation exists Whether there is overlap between the second fine-grained areas in the storage area;
  • the execution module is configured to execute the first operation when there is no overlap between the first fine-grained region and the second fine-grained region.
  • the execution control module is configured to block the first operation when the first fine-grained area overlaps with the second fine-grained area.
  • A24 The device according to claim A22, wherein at least one of the first operation and the second operation is a write operation.
  • A25 The device according to claim A22, wherein the size and/or number of the fine-grained regions are determined according to at least one of a region where data of a set length is located, and an area where data of a set dimension is located.
  • A26 The device according to claim A22, wherein the size and/or number of the fine-grained regions are determined according to at least one of hardware computing capability and hardware bandwidth.
  • A27 The device according to claim A22, wherein the first operation is an operation in a first processing instruction, the second operation is an operation in a second processing instruction, and the second processing instruction is in an instruction queue A processing instruction before the first processing instruction.
  • a location recording module configured to record first location information of the first fine-grained area currently operated by the first operation and second location information of the second fine-grained area currently operated by the second operation,
  • the execution module includes:
  • the first execution submodule is configured to execute the first operation when the first location information is inconsistent with the second location information.
  • A29 The device according to claim A28, wherein the first position information includes a first number of fine-grained regions where a first operation has been completed, and the second position information includes a fine-grained region where the second operation has been completed The second quantity,
  • the first execution submodule is also used for:
  • the first operation is an operation after the second operation, and the first number is less than the second number, the first operation is performed.
  • A30 The device according to claim A22, wherein the target storage area includes an operable area and an inoperable area, and the overlap judgment module includes:
  • the judging submodule is used to judge the first fine-grained area in the target storage area currently targeted by the first operation when the second operation exists within the operable area Whether the first fine-grained area in the target storage area currently targeted by the operation overlaps with the second fine-grained area in the target storage area currently targeted by the second operation.
  • the inoperable area is a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is in the inoperable area
  • the position within is updated with the operating position of the second operation, and the device further includes:
  • the update module is configured to update the position of the non-operational area after the second fine-grained area in the target storage area targeted by the second operation moves out of the non-operational area.
  • the inoperable area is a plurality of fine-grained areas including the second fine-grained area, and the second fine-grained area is located in the inoperable area Set position within,
  • the position of the non-operable area is updated with the operating position of the second operation.
  • the target storage area comprises: a circular buffer storage area.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Executing Machine-Instructions (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Neurology (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Complex Calculations (AREA)
  • Advance Control (AREA)

Abstract

一种数据处理方法及装置以及相关产品,该方法包括:在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容(S11a),根据所述描述符的内容,执行所述第一处理指令(S12a)。通过以上方法可以提高相关产品在进行神经网络模型的运算时的运算效率。

Description

数据处理方法及装置以及相关产品 技术领域
本公开涉及计算机技术领域,尤其涉及一种数据处理方法及装置以及相关产品。
背景技术
随着人工智能技术的不断发展,其应用领域越来越广泛,在图像识别、语音识别、自然语言处理等领域中都得到了良好的应用。然而,随着人工智能算法的复杂度提高,需要处理的数据量和数据维度都在不断增大。在相关技术中,处理器通常通过获取指令的参数来确定数据地址,然后根据数据地址完成数据的读取和使用。这就要求技术人员在设计参数时设定数据存取的相关参数(例如数据之间或数据维度之间的相互关系等),从而生成指令传递给处理器来完成数据的存取,该方式降低了处理器的处理效率。
发明内容
有鉴于此,本公开提出了一种数据处理技术方案。
根据本公开的一方面,提供了一种数据处理方法,包括:在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;根据所述描述符的内容,执行所述第一处理指令。
根据本公开的另一方面,提供了一种数据处理装置,包括:内容获取模块,用于在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;指令执行模块,用于根据所述描述符的内容,执行所述第一处理指令。
根据本公开的另一方面,提供了一种神经网络芯片,所述芯片包括如上所述的数据处理装置。
根据本公开的另一方面,提供了一种电子设备,所述电子设备包括如上所述的神经网络芯片。
根据本公开的另一方面,提供了一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如上所述的神经网络芯片;其中,所述神经网络芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述神经网络芯片与外部设备之间的数据传输;所述控制器件,用于对所述神经网络芯片的状态进行监控。
根据本公开的实施例,通过引入指示张量形状的描述符,能够在解码的处理指令的操作数中包括描述符标识时确定对应的描述符内容,并根据描述符内容执行该处理指令,从而降低数据存取的复杂度,提高数据存取的效率。
根据下面参考附图对示例性实施例的详细说明,本公开的其它特征及方面将变得清楚。
附图说明
包含在说明书中并且构成说明书的一部分的附图与说明书一起示出了本公开的示例性实施例、特征和方面,并且用于解释本公开的原理。
图1a示出根据本公开实施例的数据处理方法的流程图。
图1b示出根据本公开实施例的数据处理装置的框图。
图1c示出根据本公开实施例的数据同步方法的流程图。
图1d1示出根据本公开实施例的应用场景的示意图。
图1d2示出根据本公开实施例的处理器操作方法的流程图。
图1e示出根据本公开实施例的数据同步方法的流程图。
图1f示出根据本公开实施例的数据处理方法的流程图。
图1g示出根据本公开实施例的处理器操作方法的流程图。
图2示出根据本公开实施例的数据存储空间的示意图。
图3a示出根据本公开实施例的数据处理装置的框图。
图3b示出根据本公开实施例的数据处理方法的流程图。
图3c1示出根据本公开实施例的数据同步方法的流程图。
图3c2示出根据本公开实施例的数据同步方法的流程图。
图3c3示出根据本公开实施例的数据同步装置的框图。
图3c4示出根据本公开实施例的数据同步装置的框图。
图3c5示出根据本公开实施例的数据同步装置的框图。
图3d示出根据本公开实施例的处理器操作装置的框图。
图3e示出根据本公开实施例的数据同步装置的框图。
图3f示出根据本公开实施例的数据处理装置的框图。
图3g示出根据本公开实施例的处理器操作装置的框图。
图4示出根据本公开实施例的板卡的结构框图。
图5a和图5b示出根据本公开实施例的处理器操作方法的应用场景的示意图。
图6a和图6b示出根据本公开实施例的处理器操作方法的应用场景的示意图。
图7a和图7b示出根据本公开实施例的处理器操作方法的应用场景的示意图。
图8示出根据本公开实施例的处理器操作方法的循环缓冲存储区域的示意图。
具体实施方式
以下将参考附图详细说明本公开的各种示例性实施例、特征和方面。附图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施例的各种方面,但是除非特别指出,不必按比例绘制附图。
在这里专用的词“示例性”意为“用作例子、实施例或说明性”。这里作为“示例性”所说明的任何实施例不必解释为优于或好于其它实施例。
另外,为了更好的说明本公开,在下文的具体实施方式中给出了众多的具体细节。本领域技术人员应当理解,没有某些具体细节,本公开同样可以实施。在一些实例中,对于本领域技术人员熟知的方法、手段、元件和电路未作详细描述,以便于凸显本公开的主旨。
根据本公开的实施例,提供了一种数据处理方法。图1a示出根据本公开实施例的数据处理方法的流程图。如图1a所示,该数据处理方法包括:
在步骤S11a中,在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;
在步骤S12a中,根据所述描述符的内容,执行所述第一处理指令。
根据本公开的实施例,通过引入指示张量形状的描述符,能够在解码的处理指令的操作数中包括描述符标识时确定对应的描述符内容,并根据描述符内容执行该处理指令,从而降低数据存取的复杂度,提高数据存取的效率。
举例来说,该数据处理方法可应用于处理器中,该处理器可包括通用处理器(例如中央处理器CPU、图形处理器GPU)和专用处理器(例如人工智能处理器、科学计算处理器或数字信号处理器等)。本公开对处理器的类型不作限制。
在一种可能的实现方式中,待处理的数据可包括N维的张量数据(N为大于或等于零的整数,例如N=1、2或3),其中,张量可以包含多种形式的数据组成方式,张量可以是不同维度的,比如标量可以看作是0维张量,向量可以看作1维张量,而矩阵可以是2维或2维以上的张量。张量的形状包括张量的维度、张量各个维度的尺寸等信息。举例而言,对于张量:
Figure PCTCN2020082775-appb-000001
该张量的形状可以被描述符描述为(2,4),也即通过两个参数表示该张量为二维张量,且该张量的第一维度(列)的尺寸为2、第二维度(行)的尺寸为4。需要说明的是,本申请对于描述符指示张量形状的方式并不做限定。在存储器中存储张量数据时,根据其数据地址(或存储区域)无法确定张量数据的形状,进而也无法确定多个张量数据之间相互关系等相关信息,导致处理器对张量数据的存取效率较低。
在该情况下,可引入描述符(张量描述符)来指示张量(N维的张量数据)的形状。其中,N的取值可根据张量数据的维数(阶数)来确定,也可以根据张量数据的使用需要进行设定。例如,在N的取值为3时,张量数据为三维的张量数据,描述符可用来指示该三维的张量数据在三个维度方向上的形状(例如偏移量、尺寸等)。应当理解,本领域技术人员可以根据实际需要对N的取值进行设置,本公开对此不作限制。
在一种可能的实现方式中,描述符可包括标识和内容等,描述符的标识可用于对描述符进行区分,例如为编号;描述符的内容可包括表示张量数据的形状的至少一个形状参数(例如张量的各个维度方向上的尺寸等),还可以包括表示张量数据的地址的至少一个地址参数(例如数据基准点的基准地址)。本公开对描述符的内容包括的具体参数不作限制。
通过采用描述符来指示张量数据的方式,能够表达张量数据的形状,进而也能够确定多个张量数据之间的相互关 系等相关信息,提高对张量数据的存取效率。
在一种可能的实现方式中,在接收到处理指令时,可先对处理指令进行解码(译码)。其中,所述方法还包括:对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,
其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。
在该情况下,第一处理指令经解码后,可得到解码后的第一处理指令(微指令)。其中,第一处理指令可包括数据存取指令、运算指令、描述符管理指令以及同步指令等。本公开对第一处理指令的具体类型及解码的具体方式不作限制。
该解码后的第一处理指令可包括操作码以及一个或多个操作数,操作码用于指示与第一处理指令对应的处理类型,操作数用于指示待处理的数据。例如,该指令可表示为:Add;A;B,其中Add为操作码,A和B为操作数,该指令用于对A和B相加。本公开对解码后的指令的操作数的数量以及指令的表示形式不作限制。
在一种可能的实现方式中,如果解码后的第一处理指令的操作数包括描述符的标识,则可通过该描述符的标识确定与描述符对应的描述符存储空间,并从描述符存储空间获取描述符的内容(包括表征张量数据的形状、地址等信息);然后,可根据描述符的内容执行第一处理指令。
在一种可能的实现方式中,步骤S12a可包括:
根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
根据所述数据地址,执行与所述第一处理指令对应的数据处理。
举例来说,根据描述符的内容,可计算第一处理指令中包括描述符标识的操作数对应的数据在数据存储空间中的数据地址,进而可以根据该数据地址执行对应的处理。例如,对于指令Add;A;B,如果操作数A和B中分别包括描述符的标识TR1和TR2,则处理器可根据描述符的标识TR1和TR2分别确定与TR1和TR2对应的描述符存储空间,并读取描述符存储空间中的内容(例如形状参数和地址参数);根据描述符的内容,可计算数据A和B的数据地址,例如A在内存中的数据地址1为ADDR64-ADDR127,B在内存中的数据地址2为ADDR1023-ADDR1087。然后,处理器可从地址1和地址2中分别读取数据,执行加法(Add)运算,得到运算结果(A+B)。
在一种可能的实现方式中,根据本公开实施例的方法可通过相关技术的硬件结构实现。在该情况下,应用该方法的处理器可包括控制单元及执行单元,控制单元用于进行控制,例如读取存储器或外部传入的指令,对指令进行解码(译码),向相应的部件发出微操作控制信号等。执行单元用于执行具体的指令,执行单元可以例如为算术逻辑单元(arithmetic and logic unit,ALU)、内存存取单元(memory access unit,MAU)、人工智能运算单元(neural functional unit,NFU)等。本公开对执行单元的具体硬件类型不作限制。
在一种可能的实现方式中,可通过控制单元对指令进行解码,得到解码后的第一处理指令;如果解码后的第一处理指令的操作数包括描述符的标识,则控制单元可确定与描述符对应的描述符存储空间,并从描述符存储空间获取描述符的内容(形状、地址等信息);然后,控制单元可将描述符的内容及第一处理指令发送到执行单元,以使执行单元根据描述符的内容执行第一处理指令。执行单元在接收到描述符的内容及第一处理指令时,可以根据描述符的内容,计算第一处理指令中包括描述符标识的操作数对应的数据在数据存储空间中的数据地址,进而可以根据该数据地址执行对应的处理。
例如,对于指令Add;A;B,如果操作数A和B中分别包括描述符的标识TR1和TR2,则控制单元可确定与TR1和TR2对应的描述符存储空间,读取描述符存储空间中的内容(例如形状参数和地址参数)并将其发送给执行单元。执行单元在接收到描述符的内容后,可以计算数据A和B的数据地址,例如A在内存中的地址1为ADDR64-ADDR127,B在内存中的地址2为ADDR1023-ADDR1087。然后,执行单元可从地址1和地址2中分别读取数据,执行加法(Add)运算,得到运算结果(A+B)。
在一种可能的实现方式中,可以通过对相关技术的硬件结构进行改进,以实现根据本公开实施例的方法。例如,可以在控制单元中设置有张量控制模块,以实现与描述符相关联的操作,例如描述符的注册、修改及注销;对描述符内容的读写等。张量控制模块可例如为张量接口单元(Tensor interface Unit,TIU),本公开对张量控制模块的具体硬件类型不作限制。通过这种方式,可以通过专用的硬件实现与描述符相关联的操作,进一步提高了张量数据的存取效率。
在该情况下,如果控制单元解码后的第一处理指令的操作数包括描述符的标识,则可以通过张量控制模块确定与 描述符对应的描述符存储空间;确定描述符存储空间后,可从描述符存储空间获取描述符的内容(形状、地址等信息)。然后,控制单元可将描述符的内容及第一处理指令发送到执行单元,以使执行单元根据描述符的内容执行第一处理指令。
在一种可能的实现方式中,张量控制模块还可以实现与描述符相关联的操作以及指令的执行,例如描述符的注册、修改及注销;对描述符内容的读写;数据地址的计算以及数据存取指令的执行等。在该情况下,如果控制单元解码后的第一处理指令的操作数包括描述符的标识,则可以通过张量控制模块确定与描述符对应的描述符存储空间;确定描述符存储空间后,可从描述符存储空间获取描述符的内容;根据描述符的内容,通过张量控制模块确定与第一处理指令的操作数对应的数据在数据存储空间中的数据地址;根据数据地址,通过张量控制模块执行与所述第一处理指令对应的数据处理。
本公开对实现本公开实施例的方法所采用的具体硬件结构不作限制。
通过这种方式,可以从描述符存储空间获取描述符内容,进而获取数据地址,无需在每次存取时通过指令传入地址,从而提高了处理器的数据存取效率。
在一种可能的实现方式中,描述符的标识和内容可存储在描述符存储空间中,该描述符存储空间可以为控制单元的内部存储器(例如寄存器、片上的SRAM或其他介质缓存等)中的存储空间。描述符所指示的张量数据的数据存储空间可为控制单元的内部存储器(例如片上缓存)或与控制单元连接的外部存储器(片下存储器)中的存储空间。数据存储空间中的数据地址可以为实际的物理地址或虚拟地址。本公开对描述符存储空间及数据存储空间的位置以及数据地址的类型不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以位于同一块区域,例如,可使用片上缓存的一块连续区域存储描述符的相关内容,其地址为ADDR0-ADDR1023,其中,地址ADDR0-ADDR31可用于存储描述符的标识,地址ADDR32-ADDR63可用于存储描述符的内容,地址ADDR64-ADDR1023可用于存储描述符指示的张量数据。其中,地址ADDR并不限于1位或一个字节,此处用来表示一个地址,是一个地址单位。本领域技术人员可以根据实际情况确定存储区域及其地址,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以分开存储在内部存储器的不同区域,例如,可以将寄存器作为描述符存储空间,在寄存器中存储描述符的标识及内容,将片上缓存作为数据存储空间,存储描述符所指示的张量数据。
在一种可能的实现方式中,还可以设置专门供描述符使用的专用寄存器(SR),描述符中的数据可以是立即数也可以从专用寄存器中获取。在使用寄存器存储描述符的标识和内容时,可以使用寄存器的编号来表示描述符的标识,例如,寄存器的编号为0时,其存储的描述符的标识为0。当寄存器中的描述符有效时,可根据描述符所指示的张量数据的大小在缓存空间中分配一块区域(例如在缓存中为每个张量数据创建一个张量缓存单元)用于存储该张量数据。应当理解,也可以采用预设的缓存空间存储该张量数据,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识及内容可存储在内部存储器,描述符所指示的张量数据可存储在外部存储器。例如,可以采用在片上存储描述符的标识及内容、在片下存储描述符所指示的张量数据的方式。
在一种可能的实现方式中,与描述符对应的数据存储空间的数据地址可以是固定地址。例如,可以为张量数据划分单独的数据存储空间,每个张量数据在数据存储空间的起始地址与描述符的标识一一对应。在这种情况下,执行单元根据描述符的内容即可确定与操作数对应数据的数据地址,然后执行第一处理指令。
在一种可能的实现方式中,在与描述符的标识对应的数据存储空间的数据地址为可变地址时,所述描述符还可用于指示N维的张量数据的地址,其中,所述描述符的内容还可包括表示张量数据的地址的至少一个地址参数。例如,张量数据为3维数据,在描述符指向该张量数据的地址时,描述符的内容可包括表示该张量数据的地址的一个地址参数,例如张量数据的起始地址,也可以包括该张量数据的地址的多个地址参数,例如张量数据的起始地址+地址偏移量,或张量数据基于各维度的地址参数。本领域技术人员可以根据实际需要对地址参数进行设置,本公开对此不作限制。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址。其中,基准地址可根据数据基准点的变化而不同。本公开对数据基准点的选取不作限制。
在一种可能的实现方式中,所述基准地址可包括所述数据存储空间的起始地址。在描述符的数据基准点是数据存储空间的第一个数据块时,描述符的基准地址即为数据存储空间的起始地址。在描述符的数据基准点是数据存储空间中第一个数据块以外的其他数据时,描述符的基准地址即为该数据块在数据存储空间中的物理地址。
在一种可能的实现方式中,所述张量数据的形状参数包括以下至少一种:所述张量数据的数据存储空间在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。其中,数据描述位置是描述符所指示的张量数据中的点或区域的映射位置,例如,张量数据为3维数据时,描述符可使用三维空间坐标(x,y,z)来表示该张量数据的形状,该张量数据的数据描述位置可以是使用三维空间坐标(x,y,z)表示的、该张量数据映射在三维空间中的点或区域的位置。
应当理解,本领域技术人员可以根据实际情况选择表示张量数据的形状参数,本公开对此不作限制。
图2示出根据本公开一实施例的数据存储空间的示意图。如图2所示,数据存储空间21采用行优先的方式存储了一个二维数据,可通过(x,y)来表示(其中,X轴水平向右,Y轴垂直向下),X轴方向上的尺寸(每行的尺寸)为ori_x(图中未示出),Y轴方向上的尺寸(总行数)为ori_y(图中未示出),数据存储空间21的起始地址PA_start(基准地址)为第一个数据块22的物理地址。数据块23是数据存储空间21中的部分数据,其在X轴方向上的偏移量25表示为offset_x,在Y轴方向上的偏移量24表示为offset_y,在X轴方向上的尺寸表示为size_x,在Y轴方向上的尺寸表示为size_y。
在一种可能的实现方式中,使用描述符来定义数据块23时,描述符的数据基准点可使用数据存储空间21的第一个数据块,描述符的基准地址为数据存储空间21的起始地址PA_start,然后可以结合数据存储空间21在X轴的尺寸ori_x、在Y轴上的尺寸ori_y,以及数据块23在Y轴方向的偏移量offset_y、X轴方向上的偏移量offset_x、X轴方向上的尺寸size_x以及Y轴方向上的尺寸size_y来确定数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(1)来表示描述符的内容:
Figure PCTCN2020082775-appb-000002
应当理解,虽然上述示例中,描述符描述的是二维空间,但本领域技术人员可以根据实际情况对描述符的内容表示的维度进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置,确定所述张量数据的描述符的内容。
举例来说,可以使用描述符的数据基准点在数据存储空间中的基准地址PA_base,以及对角位置的两个顶点相对于数据基准点的位置,确定出图2中数据块23的描述符的内容。首先,确定描述符的数据基准点以及其在数据存储空间中的基准地址PA_base,例如,可以在数据存储空间21中选取一个数据(例如,位置为(2,2)的数据)作为数据基准点,将该数据在数据存储空间中的物理地址作为基准地址PA_base;然后,确定数据块23的对角位置的至少两个顶点相对于数据基准点的位置,例如,使用左上至右下方向的对角位置顶点相对于数据基准点的位置,其中,左上角顶点的相对位置为(x_min,y_min),右下角顶点的相对位置为(x_max,y_max),然后可以根据基准地址PA_base、左上角顶点的相对位置(x_min,y_min)以及右下角顶点的相对位置(x_max,y_max)确定出数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(2)来表示描述符的内容:
Figure PCTCN2020082775-appb-000003
应当理解,虽然上述示例中使用左上角和右下角两个顶点来确定描述符的内容,但本领域技术人员可以根据实际需要对至少两个顶点的具体顶点进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址,以及所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系,确定所述张量数据的描述符的内容。其中,数据描述位置与数据地址之间的映射关系可以根据实际需要进行设定,例如,描述符所指示的张量数据为三维空间数据时,可是使用函数f(x,y,z)来定义数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,可以使用下述公式(3)来表示描述符的内容:
Figure PCTCN2020082775-appb-000004
应当理解,本领域技术人员可以根据实际情况对数据描述位置与数据地址之间的映射关系进行设定,本公开对此不作限制。
在采用公式(1)表示描述符的内容的情况下,对于张量数据中的任意一个数据点,设其数据描述位置为(x q,y q),那么,该数据点在数据存储空间中的数据地址PA2 (x,y)可以使用下述公式(4)来确定:
PA2 (x,y)=PA_start+(offset_y+y q-1)*ori_x+(offset_x+x q)  (4)
通过这种方式,执行单元可以根据描述符的内容计算出描述符所指示的张量数据在数据存储空间中的数据地址,进而根据该地址执行与处理指令对应的处理。
在一种可能的实现方式中,可以通过描述符的管理指令来实现描述符的注册、修改及注销等管理,并为这些管理指令设定相应的操作码。例如可通过描述符注册指令(TRCreat)来注册(创建)描述符;通过描述符修改指令来修改描述符的各个参数(形状、地址等);通过描述符注销指令(TRRelease)来注销(删除)描述符等。本公开对描述符的管理指令的种类及操作码的具体设定不作限制。
在一种可能的实现方式中,所述方法还包括:
在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一种;
根据所述描述符的注册参数,确定所述描述符的内容在描述符存储空间中的第一存储区域,以及所述描述符所指示的张量数据的内容在数据存储空间中的第二存储区域;
根据所述描述符的注册参数以及所述第二存储区域,确定所述描述符的内容,以建立所述描述符与所述第二存储区域之间的对应关系;
将所述描述符的内容存储到所述第一存储区域。
举例来说,描述符注册指令可用于注册描述符,该指令中可包括描述符的注册参数。该注册参数可包括描述符的标识(ID)、张量形状以及描述符所指示的张量数据的内容中的至少一种。例如,该注册参数可包括标识为TR0、张量形状(维度数量、各维度的尺寸、偏移量、起始数据地址等)。本公开对注册参数的具体内容不作限制。
在一种可能的实现方式中,当根据解码后的第一处理指令的操作码确定该指令为描述符注册指令时,根据第一处理指令中的注册参数,可创建相应的描述符。其中,可通过控制单元或通过张量控制模块创建相应的描述符,本公开对此不作限制。
在一种可能的实现方式中,可以先确定描述符的内容在描述符存储空间中的第一存储区域,以及所述描述符所指示的张量数据的内容在数据存储空间中的第二存储区域。
举例来说,如果已经预先设定了存储区域中的至少一个,则可以直接确定第一存储区域和/或第二存储区域。例如预设了描述符内容和张量数据内容存储于同一存储空间,并且描述符的标识TR0对应的描述符的内容的存储地址为ADDR32-ADDR63,张量数据的内容的存储地址为ADDR64-ADDR1023,则可以直接确定这两个地址为第一存储区域和第二存储区域。
在一种可能的实现方式中,如果没有预设的存储区域,则可以为描述符内容在描述符存储空间中分配第一存储区域,并为张量数据内容在数据存储空间中分配第二存储区域。其中,可通过控制单元或通过张量控制模块分配存储区域,本公开对此不作限制。
在一种可能的实现方式中,根据注册参数中的张量形状以及所述第二存储区域的数据地址,可以建立张量形状与地址之间的对应关系,进而确定描述符内容,从而能够在数据处理时根据描述符内容确定对应的数据地址。在确定描述符内容后,可将其存入第一存储区域中,完成描述符的注册过程。
例如,对于如图2所示的张量数据23,注册参数可以包括数据存储空间21的起始地址PA_start(基准地址)、在X轴方向上的偏移量25(表示为offset_x),在Y轴方向上的偏移量24(表示为offset_y),在X轴方向上的尺寸(表示为size_x),在Y轴方向上的尺寸(表示为size_y)。通过这些参数,可以将描述符的内容表示为公式(1),并将其存储到第一存储区域中,从而完成描述符的注册过程。
通过这种方式,可以根据描述符注册指令自动创建描述符,实现描述符所指示的张量与数据地址之间的对应,从而在数据处理时通过描述符内容获取数据地址,提高处理器的数据存取效率。
在一种可能的实现方式中,所述方法还包括:
在所述第一处理指令为描述符注销指令时,获取所述第一处理指令中描述符的标识;
根据所述描述符的标识,分别释放所述描述符在描述符存储空间中的存储区域以及所述描述符所指示的张量数据的内容在数据存储空间中的存储区域。
举例来说,描述符注销指令可用于注销(删除)描述符,以便释放描述符所占用的空间。该指令中可至少包括描述符的标识。
在一种可能的实现方式中,当根据解码后的第一处理指令的操作码确定该指令为描述符注销指令时,根据第一处理指令中的描述符标识,可注销相应的描述符。可通过控制单元或通过张量控制模块注销相应的描述符,本公开对此不作限制。
在一种可能的实现方式中,根据描述符的标识,可释放该描述符在描述符存储空间中的存储区域,和/或描述符所指示的张量数据的内容在数据存储空间中的存储区域,从而解除该描述符对各存储区域的占用。
通过这种方式,可以在描述符使用结束后释放描述符所占用的空间,重复利用有限的存储资源,提高了资源的利用效率。
在一种可能的实现方式中,所述方法还包括:
在所述第一处理指令为描述符修改指令时,获取所述第一处理指令中描述符的修改参数,所述修改参数包括所述描述符的标识、待修改的张量形状以及描述符所指示的张量数据的内容中的至少一种;
根据所述描述符的修改参数,确定所述描述符的待更新内容;
根据待更新内容,更新所述描述符存储空间中的所述描述符的内容和/或数据存储空间中张量数据的内容。
举例来说,描述符修改指令可用于修改描述符的各种参数,例如标识、张量形状等。该指令中可包括修改参数,该修改参数包括所述描述符的标识、待修改的张量形状以及描述符所指示的张量数据的内容中的至少一种。本公开对修改参数的具体内容不作限制。
在一种可能的实现方式中,当根据解码后的第一处理指令的操作码确定该指令为描述符修改指令时,根据第一处理指令中的修改参数,可确定描述符的待更新内容,例如将张量的维度由3维改为2维,更改张量在一个或多个维度方向上的尺寸等。
在一种可能的实现方式中,在确定待更新内容后,可更新描述符存储空间中的描述符内容和/或数据存储空间中张量数据的内容,以便修改张量数据并使得更新后的描述符内容能够指示修改后的张量数据的形状。本公开对待更新内容的范围及具体更新方式不作限制。
通过这种方式,可以在描述符所指示的张量数据发生改变时,直接修改描述符,以保持描述符与张量数据之间的对应,提高资源的利用效率。
在一种可能的实现方式中,所述方法还包括:
根据所述描述符的标识,确定是否存在未完成处理的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;
在存在未完成处理的第二处理指令时,阻塞或缓存所述第一处理指令。
举例来说,在设定描述符后,可以根据描述符进行指令之间的依赖关系的判断。如果解码后的第一处理指令的操作数包括描述符的标识,则可确定该第一处理指令的前序指令中是否存在与该第一处理指令具有依赖关系的指令。
在该情况下,对于指令队列中的在第一处理指令之前的指令(前序指令),如果前序指令的操作数中具有所述描述符的标识,则可认为该前序指令是与该第一处理指令具有依赖关系的第二处理指令。在第一处理指令的操作数中具有多个描述符的标识的情况下,可分别判断对应于每个描述符的依赖关系,也就是说,将操作数中具有多个描述符中的至少一个描述符的标识的前序指令作为具有依赖关系的第二处理指令。可在控制单元中设置依赖关系判断模块以便判断处理指令之间的依赖关系,本公开对此不作限制。
在一种可能的实现方式中,如果存在未完成处理的第二处理指令,则第一处理指令需在第二处理指令完成之后再执行。例如,如果第一处理指令为针对描述符TR0的运算指令,第二处理指令为对描述符TR0的写指令,则第二处理指令与第一处理指令之间具有依赖关系。在该第二处理指令执行期间,不能执行第一处理指令。再例如,如果第二处理指令包括针对第一处理指令的同步指令(sync),则第二处理指令与第一处理指令之间具有依赖关系,需要在该第二处理指令执行完成后,再执行第一处理指令。
在一种可能的实现方式中,如果存在未完成处理的第二处理指令,则可以阻塞第一处理指令,也即暂停第一处理指令及之后的其他指令的执行,直到第二处理指令执行完成后,再执行第一处理指令及之后的其他指令。
在一种可能的实现方式中,如果存在未完成处理的第二处理指令,则可以缓存第一处理指令,也即将第一处理指令存储到预设的缓存空间,而不影响其他指令的执行。在第二处理指令执行完成后,再执行缓存空间中的第一处理指令。本公开对存在未完成处理的第二处理指令时对第一处理指令的处理方式不作限制。
通过这种方式,可以确定由于指令类型产生的指令之间的依赖关系以及由同步指令产生的依赖关系,并在具有依赖关系的前序指令未完成处理时阻塞或缓存第一处理指令,从而保证指令的执行顺序,确保数据处理的正确性。
在一种可能的实现方式中,所述方法还包括:
根据所述描述符的标识,确定所述描述符当前的状态,所述描述符的状态包括可操作状态或不可操作状态;
在所述描述符当前处于不可操作状态时,阻塞或缓存所述第一处理指令。
举例来说,可以设置描述符的状态的对应表(例如,在张量控制模块中存放描述符的状态的对应表),从而显示描述符当前的状态,描述符的状态包括可操作状态或不可操作状态。
在一种可能的实现方式中,在第一处理指令的前序指令当前正在对描述符进行操作(例如写入或读取)的情况下,可将描述符的当前状态设置为不可操作状态。在该状态下,无法执行第一处理指令,可阻塞或缓存第一处理指令。反之,在当前没有对描述符进行操作的前序指令的情况下,可将描述符的当前状态设置为可操作状态。在该状态下,能够执行第一处理指令。
在一种可能的实现方式中,在描述符内容存储在寄存器TR(张量寄存器,Tensor Register)中时,描述符的状态对应表中还可以存放TR的使用情况,从而确定TR被占用还是被释放,实现有限的寄存器资源的管理。
通过这种方式,可根据描述符的状态判断指令之间的依赖关系,从而保证指令的执行顺序,确保数据处理的正确性。
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,步骤S11a包括:在所述源数据和所述目的数据中的至少一个包括描述符的标识时,从所述描述符存储空间获取所述描述符的内容;
其中,步骤S12a包括:根据所述描述符的内容,分别确定所述源数据的第一数据地址和/或所述目的数据的第二数据地址;从所述第一数据地址读取数据并写入到所述第二数据地址。
举例来说,数据存取指令的操作数包括源数据和目的数据,用于从源数据的数据地址读取数据并写入到目的数据的数据地址。在第一处理指令为数据存取指令时,可通过描述符来实现张量数据的存取。在数据存取指令的源数据和目的数据中的至少一个包括描述符的标识时,可确定描述符的描述符存储空间。
在一种可能的实现方式中,如果源数据包括第一描述符的标识,且目的数据包括第二描述符的标识,则可分别确定第一描述符的第一描述符存储空间和第二描述符的第二描述符存储空间;然后从第一描述符存储空间和第二描述符存储空间分别读取第一描述符的内容和第二描述符的内容;根据第一描述符和第二描述符的内容,可分别计算源数据的第一数据地址和目的数据的第二数据地址;从第一数据地址读取数据并写入到第二数据地址,从而完成整个存取过程。
例如,源数据可以是片下的待读取数据,其第一描述符的标识为1,目的数据是片上的一块存储空间,其第二描述符的标识为2。可根据源数据中第一描述符的标识1以及目的数据中第二描述符的标识2,从描述符存储空间分别获取第一描述符的内容D1和第二描述符的内容D2。其中,第一描述符的内容D1和第二描述符的内容可分别表示如下:
Figure PCTCN2020082775-appb-000005
Figure PCTCN2020082775-appb-000006
根据第一描述符的内容D1和第一描述符的内容D2,可分别获取源数据的起始物理地址PA3和目的数据的起始物理地址PA4,分别表示如下:
PA3=PA_start1+(offset_y1-1)*ori_x1+offset_x1
PA4=PA_start2+(offset_y2-1)*ori_x2+offset_x2
根据源数据的起始物理地址PA3和目的数据的起始物理地址PA4,以及第一描述符的内容D1和第二描述符的内容 D2,可分别确定第一数据地址和第二数据地址,并从第一数据地址读取数据并写入第二数据地址(可通过IO通路),从而完成将D1所指示的张量数据载入到D2所指示的存储空间。
在一种可能的实现方式中,如果仅有源数据包括第一描述符的标识,则可确定第一描述符的第一描述符存储空间;然后从第一描述符存储空间读取第一描述符的内容;根据第一描述符的内容,可计算源数据的第一数据地址;根据指令的操作数中目的数据的第二数据地址,可从第一数据地址读取数据并写入到第二数据地址,从而完成整个存取过程。
在一种可能的实现方式中,如果仅有目的数据包括第二描述符的标识,则可确定第二描述符的第二描述符存储空间;然后从第二描述符存储空间读取第二描述符的内容;根据第二描述符的内容后,可计算目的数据的第二数据地址;根据指令的操作数中源数据的第一数据地址,可从第一数据地址读取数据并写入到第二数据地址,从而完成整个存取过程。
通过这种方式,可使用描述符完成数据的存取,无需在每次存取时通过指令传入数据地址,从而提高数据存取效率。
在一种可能的实现方式中,所述第一处理指令包括运算指令,步骤S12a包括:
根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
根据所述数据地址,执行与所述第一处理指令对应的运算。
举例来说,在第一处理指令为运算指令时,可通过描述符来实现张量数据的运算。在运算指令的操作数中包括描述符的标识时,可确定描述符的描述符存储空间,然后从描述符存储空间读取描述符的内容;根据描述符的内容后,可计算操作数对应的数据的地址,进而从数据地址读取数据进行运算,从而完成整个运算过程。通过这种方式,可在运算时使用描述符完成数据的读取,无需通过指令传入数据地址,从而提高数据运算效率。
根据本公开实施例的数据处理方法,引入了能够指示张量形状的描述符,使得数据处理指令运行过程中能够通过描述符来确定数据的地址,从硬件方面简化了指令生成方式,从而降低数据存取的复杂度,并且提高处理器存取数据的效率。
图3a示出根据本公开实施例的数据处理装置的框图。如图3a所示,本公开还提供了一种数据处理装置,包括:
内容获取模块31a,用于在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;指令执行模块32a,用于根据所述描述符的内容,执行所述第一处理指令。
在一种可能的实现方式中,所述指令执行模块包括:地址确定子模块,用于根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;数据处理子模块,用于根据所述数据地址,执行与所述第一处理指令对应的数据处理。
在一种可能的实现方式中,所述装置还包括:第一参数获取模块,用于在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一种;区域确定模块,用于根据所述描述符的注册参数,确定所述描述符的内容在描述符存储空间中的第一存储区域,以及所述描述符所指示的张量数据的内容在数据存储空间中的第二存储区域;内容确定模块,用于根据所述描述符的注册参数以及所述第二存储区域,确定所述描述符的内容,以建立所述描述符与所述第二存储区域之间的对应关系;内容存储模块,用于将所述描述符的内容存储到所述第一存储区域。
在一种可能的实现方式中,所述装置还包括:标识获取模块,用于在所述第一处理指令为描述符注销指令时,获取所述第一处理指令中描述符的标识;空间释放模块,用于根据所述描述符的标识,分别释放所述描述符在描述符存储空间中的存储区域以及所述描述符所指示的张量数据的内容在数据存储空间中的存储区域。
在一种可能的实现方式中,所述装置还包括:第二参数获取模块,用于在所述第一处理指令为描述符修改指令时,获取所述第一处理指令中描述符的修改参数,所述修改参数包括所述描述符的标识、待修改的张量形状以及描述符所指示的张量数据的内容中的至少一种;更新内容确定模块,用于根据所述描述符的修改参数,确定所述描述符的待更新内容;内容更新模块,用于根据待更新内容,更新描述符存储空间中的所述描述符的内容和/或数据存储空间中张量数据的内容。
在一种可能的实现方式中,所述装置还包括:指令确定模块,用于根据所述描述符的标识,确定是否存在未完成处理的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;第一指令缓存模块,用于在存在未完成处理的第二处理指令时,阻塞或缓存所述第一处理指令。
在一种可能的实现方式中,所述装置还包括:状态确定模块,用于根据所述描述符的标识,确定所述描述符当前的状态,所述描述符的状态包括可操作状态或不可操作状态;第二指令缓存模块,用于在所述描述符当前处于不可操作状态时,阻塞或缓存所述第一处理指令。
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,其中,所述内容获取模块包括:内容获取子模块,用于在所述源数据和所述目的数据中的至少一个包括描述符的标识时,从描述符存储空间获取所述描述符的内容;其中,所述指令执行模块包括:第一地址确定子模块,用于根据所述描述符的内容,分别确定所述源数据的第一数据地址和/或所述目的数据的第二数据地址;存取子模块,用于从所述第一数据地址读取数据并写入到所述第二数据地址。
在一种可能的实现方式中,所述第一处理指令包括运算指令,其中,所述指令执行模块包括:第二地址确定子模块,用于根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;运算子模块,用于根据所述数据地址,执行与所述第一处理指令对应的运算。
在一种可能的实现方式中,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
在一种可能的实现方式中,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;其中,所述张量数据的形状参数包括以下至少一种:所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,所述装置还包括:解码模块,用于对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。
在一种可能的实现方式中,还公开了一种神经网络芯片,其包括了上述数据处理装置。
在一种可能的实现方式中,还公开了一种板卡,其包括存储器件、接口装置和控制器件以及上述神经网络芯片;其中,所述神经网络芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述神经网络芯片与外部设备之间的数据传输;所述控制器件,用于对所述神经网络芯片的状态进行监控。
图4示出根据本公开实施例的板卡的结构框图,参阅图4,上述板卡除了包括上述芯片389以外,还可以包括其他的配套部件,该配套部件包括但不限于:存储器件390、接口装置391和控制器件392;
所述存储器件390与所述神经网络芯片通过总线连接,用于存储数据。所述存储器件可以包括多组存储单元393。每一组所述存储单元与所述神经网络芯片通过总线连接。可以理解,每一组所述存储单元可以是DDR SDRAM(英文:Double Data Rate SDRAM,双倍速率同步动态随机存储器)。
DDR不需要提高时钟频率就能加倍提高SDRAM的速度。DDR允许在时钟脉冲的上升沿和下降沿读出数据。DDR的速度是标准SDRAM的两倍。在一个实施例中,所述存储装置可以包括4组所述存储单元。每一组所述存储单元可以包括多个DDR4颗粒(芯片)。在一个实施例中,所述神经网络芯片内部可以包括4个72位DDR4控制器,上述72位DDR4控制器中64bit用于传输数据,8bit用于ECC校验。可以理解,当每一组所述存储单元中采用DDR4-3200颗粒时,数据传输的理论带宽可达到25600MB/s。
在一个实施例中,每一组所述存储单元包括多个并联设置的双倍速率同步动态随机存储器。DDR在一个时钟周期内可以传输两次数据。在所述芯片中设置控制DDR的控制器,用于对每个所述存储单元的数据传输与数据存储的控制。
所述接口装置与所述神经网络芯片电连接。所述接口装置用于实现所述神经网络芯片与外部设备(例如服务器或计算机)之间的数据传输。例如在一个实施例中,所述接口装置可以为标准PCIE接口。比如,待处理的数据由服务器通过标准PCIE接口传递至所述芯片,实现数据转移。优选的,当采用PCIE 3.0 X 16接口传输时,理论带宽可达到16000MB/s。在另一个实施例中,所述接口装置还可以是其他的接口,本申请并不限制上述其他的接口的具体表现形式,所述接口单元能够实现转接功能即可。另外,所述神经网络芯片的计算结果仍由所述接口装置传送回外部设备(例 如服务器)。
所述控制器件与所述神经网络芯片电连接。所述控制器件用于对所述神经网络芯片的状态进行监控。具体的,所述神经网络芯片与所述控制器件可以通过SPI接口电连接。所述控制器件可以包括单片机(Micro Controller Unit,MCU)。如所述神经网络芯片可以包括多个处理芯片、多个处理核或多个处理电路,可以带动多个负载。因此,所述神经网络芯片可以处于多负载和轻负载等不同的工作状态。通过所述控制装置可以实现对所述神经网络芯片中多个处理芯片、多个处理和或多个处理电路的工作状态的调控。
在一种可能的实现方式中,公开了一种电子设备,其包括了上述神经网络芯片。电子设备包括数据处理装置、机器人、电脑、打印机、扫描仪、平板电脑、智能终端、手机、行车记录仪、导航仪、传感器、摄像头、服务器、云端服务器、相机、摄像机、投影仪、手表、耳机、移动存储、可穿戴设备、交通工具、家用电器、和/或医疗设备。
所述交通工具包括飞机、轮船和/或车辆;所述家用电器包括电视、空调、微波炉、冰箱、电饭煲、加湿器、洗衣机、电灯、燃气灶、油烟机;所述医疗设备包括核磁共振仪、B超仪和/或心电图仪。
A1、一种数据处理方法,所述方法包括:
在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;
根据所述描述符的内容,执行所述第一处理指令。
A2、根据权利要求A1所述的方法,根据所述描述符的内容,执行所述第一处理指令,包括:
根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
根据所述数据地址,执行与所述第一处理指令对应的数据处理。
A3、根据权利要求A1或A2所述的方法,所述方法还包括:
在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一种;
根据所述描述符的注册参数,确定所述描述符的内容在描述符存储空间中的第一存储区域,以及所述描述符所指示的张量数据的内容在数据存储空间中的第二存储区域;
根据所述描述符的注册参数以及所述第二存储区域,确定所述描述符的内容,以建立所述描述符与所述第二存储区域之间的对应关系;
将所述描述符的内容存储到所述第一存储区域。
A4、根据权利要求A1-A3中任意一项所述的方法,所述方法还包括:
在所述第一处理指令为描述符注销指令时,获取所述第一处理指令中描述符的标识;
根据所述描述符的标识,分别释放所述描述符在描述符存储空间中的存储区域以及所述描述符所指示的张量数据的内容在数据存储空间中的存储区域。
A5、根据权利要求A1-A4中任意一项所述的方法,所述方法还包括:
在所述第一处理指令为描述符修改指令时,获取所述第一处理指令中描述符的修改参数,所述修改参数包括所述描述符的标识、待修改的张量形状以及描述符所指示的张量数据的内容中的至少一种;
根据所述描述符的修改参数,确定所述描述符的待更新内容;
根据待更新内容,更新描述符存储空间中的所述描述符的内容和/或数据存储空间中张量数据的内容。
A6、根据权利要求A1-A5中任意一项所述的方法,所述方法还包括:
根据所述描述符的标识,确定是否存在未完成处理的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;
在存在未完成处理的第二处理指令时,阻塞或缓存所述第一处理指令。
A7、根据权利要求A1-A6中任意一项所述的方法,所述方法还包括:
根据所述描述符的标识,确定所述描述符当前的状态,所述描述符的状态包括可操作状态或不可操作状态;
在所述描述符当前处于不可操作状态时,阻塞或缓存所述第一处理指令。
A8、根据权利要求A1-A7中任意一项所述的方法,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,根据所述描述符的标识,获取所述描述符的内容,包括:
在所述源数据和所述目的数据中的至少一个包括描述符的标识时,从描述符存储空间获取所述描述符的内容;
其中,根据所述描述符的内容,执行所述第一处理指令,包括:
根据所述描述符的内容,分别确定所述源数据的第一数据地址和/或所述目的数据的第二数据地址;
从所述第一数据地址读取数据并写入到所述第二数据地址。
A9、根据权利要求A1-A7中任意一项所述的方法,所述第一处理指令包括运算指令,其中,根据所述描述符的内容,执行所述第一处理指令,包括:
根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
根据所述数据地址,执行与所述第一处理指令对应的运算。
A10、根据权利要求A1-A9中任意一项所述的方法,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A11、根据权利要求A10所述的方法,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A12、根据权利要求A11所述的方法,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A13、根据权利要求A1-A12中任意一项所述的方法,所述方法还包括:
对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,
其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。
A14、一种数据处理装置,所述装置包括:
内容获取模块,用于在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;
指令执行模块,用于根据所述描述符的内容,执行所述第一处理指令。
A15、根据权利要求A14所述的装置,所述指令执行模块包括:
地址确定子模块,用于根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
数据处理子模块,用于根据所述数据地址,执行与所述第一处理指令对应的数据处理。
A16、根据权利要求A14或A15所述的装置,所述装置还包括:
第一参数获取模块,用于在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一种;
区域确定模块,用于根据所述描述符的注册参数,确定所述描述符的内容在描述符存储空间中的第一存储区域,以及所述描述符所指示的张量数据的内容在数据存储空间中的第二存储区域;
内容确定模块,用于根据所述描述符的注册参数以及所述第二存储区域,确定所述描述符的内容,以建立所述描述符与所述第二存储区域之间的对应关系;
内容存储模块,用于将所述描述符的内容存储到所述第一存储区域。
A17、根据权利要求A14-A16中任意一项所述的装置,所述装置还包括:
标识获取模块,用于在所述第一处理指令为描述符注销指令时,获取所述第一处理指令中描述符的标识;
空间释放模块,用于根据所述描述符的标识,分别释放所述描述符在描述符存储空间中的存储区域以及所述描述符所指示的张量数据的内容在数据存储空间中的存储区域。
A18、根据权利要求A14-A17中任意一项所述的装置,所述装置还包括:
第二参数获取模块,用于在所述第一处理指令为描述符修改指令时,获取所述第一处理指令中描述符的修改参数, 所述修改参数包括所述描述符的标识、待修改的张量形状以及描述符所指示的张量数据的内容中的至少一种;
更新内容确定模块,用于根据所述描述符的修改参数,确定所述描述符的待更新内容;
内容更新模块,用于根据待更新内容,更新描述符存储空间中的所述描述符的内容和/或数据存储空间中张量数据的内容。
A19、根据权利要求A14-A18中任意一项所述的装置,所述装置还包括:
指令确定模块,用于根据所述描述符的标识,确定是否存在未完成处理的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;
第一指令缓存模块,用于在存在未完成处理的第二处理指令时,阻塞或缓存所述第一处理指令。
A20、根据权利要求A14-A19中任意一项所述的装置,所述装置还包括:
状态确定模块,用于根据所述描述符的标识,确定所述描述符当前的状态,所述描述符的状态包括可操作状态或不可操作状态;
第二指令缓存模块,用于在所述描述符当前处于不可操作状态时,阻塞或缓存所述第一处理指令。
A21、根据权利要求A14-A20中任意一项所述的装置,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,所述内容获取模块包括:
内容获取子模块,用于在所述源数据和所述目的数据中的至少一个包括描述符的标识时,从描述符存储空间获取所述描述符的内容;
其中,所述指令执行模块包括:
第一地址确定子模块,用于根据所述描述符的内容,分别确定所述源数据的第一数据地址和/或所述目的数据的第二数据地址;
存取子模块,用于从所述第一数据地址读取数据并写入到所述第二数据地址。
A22、根据权利要求A14-A20中任意一项所述的装置,所述第一处理指令包括运算指令,其中,所述指令执行模块包括:
第二地址确定子模块,用于根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
运算子模块,用于根据所述数据地址,执行与所述第一处理指令对应的运算。
A23、根据权利要求A14-A22中任意一项所述的装置,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A24、根据权利要求A23所述的装置,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A25、根据权利要求A24所述的装置,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A26、根据权利要求A14-A25中任意一项所述的装置,所述装置还包括:
解码模块,用于对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,
其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。
A27、一种神经网络芯片,所述芯片包括如权利要求A14-A26中任意一项所述的数据处理装置。
A28、一种电子设备,所述电子设备包括如权利要求A27所述的神经网络芯片。
A29、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求A27所述的神经网络芯片;
其中,所述神经网络芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;
所述存储器件,用于存储数据;
所述接口装置,用于实现所述神经网络芯片与外部设备之间的数据传输;
所述控制器件,用于对所述神经网络芯片的状态进行监控。
A30、根据权利要求A29所述的板卡,
所述存储器件包括:多组存储单元,每一组所述存储单元与所述神经网络芯片通过总线连接,所述存储单元为:DDR SDRAM;
所述芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;
所述接口装置为:标准PCIE接口。
根据本公开的实施例,提供了一种数据处理装置。图1b示出根据本公开实施例的数据处理装置的框图。如图1b所示,该数据处理装置包括控制单元11b以及执行单元12b,所述控制单元11b用于:
在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,从描述符存储空间获取所述描述符的内容,所述描述符用于指示张量的形状;
向所述执行单元发送所述描述符的内容及所述第一处理指令,以使所述执行单元根据所述描述符的内容执行所述第一处理指令。
根据本公开的实施例,控制单元通过第一处理指令操作数中的描述符的标识获取描述符的内容,并向执行单元发送描述符内容以执行第一处理指令,使得执行处理指令时可以通过描述符来获取操作数,从而降低数据存取的复杂度,提高处理器的数据存取效率。
在一种可能的实现方式中,所述数据处理装置可应用于处理器,其中,处理器可包括通用处理器(例如中央处理器CPU、图形处理器GPU)和专用处理器(例如人工智能处理器、科学计算处理器或数字信号处理器)。本公开对处理器的类型不作限制。
在一种可能的实现方式中,所述控制单元11b可用于对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。其中,第一处理指令可包括数据存取指令、运算指令、描述符管理指令以及同步指令等。本公开对第一处理指令的具体类型不作限制。
在一种可能的实现方式中,控制单元11b对接收到的第一处理指令进行解码处理后,在该指令的操作数包括描述符的标识时,根据描述符的标识从描述符存储空间获取描述符的内容,并将描述符的内容及第一处理指令发送给执行单元12b;执行单元12b在接收到描述符的内容及第一处理指令后,首先根据描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址,然后根据数据地址,执行与第一处理指令对应的数据处理。其中,数据存储空间中的数据地址可以为实际的物理地址或虚拟地址,本公开对数据地址的类型不作限制。
在一种可能的实现方式中,描述符存储空间可以为控制单元11b的内部存储器中的存储空间,数据存储空间可以为控制单元11b的内部存储器或与控制单元11b连接的外部存储器中的存储空间。本公开对此不作限制。
在一种可能的实现方式中,所述描述符用于指示N维的张量数据的形状,N为正整数,例如N=1、2或3。其中,张量可以包含多种形式的数据组成方式,张量可以是不同维度的,比如标量可以看作是0维张量,向量可以看作1维张量,而矩阵可以是2维或2维以上的张量。张量的形状包括张量的维度、张量各个维度的尺寸等信息。举例而言,对于张量:
Figure PCTCN2020082775-appb-000007
该张量的形状可以被描述符描述为(2,4),也即通过两个参数表示该张量为二维张量,且该张量的第一维度(列)的尺寸为2、第二维度(行)的尺寸为4。需要说明的是,本申请对于描述符指示张量形状的方式并不做限定。
在一种可能的实现方式中,N的取值可根据张量数据的维数(阶数)来确定,也可以根据张量数据的使用需要进行设定。例如,在N的取值为3时,张量数据为三维的张量数据,描述符可用来指示该三维的张量数据在三个维度方向上的形状(例如偏移量、尺寸等)。应当理解,本领域技术人员可以根据实际需要对N的取值进行设置,本公开对此不作限制。
在一种可能的实现方式中,所述描述符可包括描述符的标识和描述符的内容。其中,描述符的标识用于对描述符进行区分,例如描述符的标识为其编号;描述符的内容包括表示张量数据的形状的至少一个形状参数。例如,张量数 据为3维数据,在该张量数据的三个维度中,其中两个维度的形状参数固定不变,其描述符的内容可包括表示该张量数据的另一个维度的形状参数。
在一种可能的实现方式中,描述符的标识和内容可存储在描述符存储空间(内部存储器),例如寄存器、片上的SRAM或其他介质缓存等。描述符所指示的张量数据可存储在数据存储空间(内部存储器或外部存储器),例如片上缓存或片下存储器等。本公开对描述符存储空间及数据存储空间的具体位置不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以存储在内部存储器的同一块区域,例如,可使用片上缓存的一块连续区域来存储描述符的相关内容,其地址为ADDR0-ADDR1023,其中,可将地址ADDR0-ADDR63作为描述符存储空间,存储描述符的标识和内容,地址ADDR64-ADDR1023作为数据存储空间,存储描述符所指示的张量数据。在描述符存储空间中,可用地址ADDR0-ADDR31存储描述符的标识,地址ADDR32-ADDR63存储描述符的内容。应当理解,地址ADDR并不限于1位或一个字节,此处用来表示一个地址,是一个地址单位。本领域技术人员可以根据实际情况确定描述符存储空间、数据存储空间以及其具体地址,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以存储在内部存储器的不同区域。例如,可以将寄存器作为描述符存储空间,在寄存器中存储描述符的标识及内容,将片上缓存作为数据存储空间,存储描述符所指示的张量数据。
在一种可能的实现方式中,在使用寄存器存储描述符的标识和内容时,可以使用寄存器的编号来表示描述符的标识。例如,寄存器的编号为0时,其存储的描述符的标识设置为0。当寄存器中的描述符有效时,可根据描述符所指示的张量数据的大小在缓存空间中分配一块区域用于存储该张量数据。
在一种可能的实现方式中,描述符的标识及内容可存储在内部存储器,描述符所指示的张量数据可存储在外部存储器。例如,可以采用在片上存储描述符的标识及内容、在片下存储描述符所指示的张量数据的方式。
在一种可能的实现方式中,与描述符的标识对应的数据存储空间的数据地址可以是固定地址。例如,可以为张量数据划分单独的数据存储空间,每个张量数据在数据存储空间的起始地址与描述符的标识一一对应。在这种情况下,执行单元根据描述符的内容即可确定与操作数对应的数据在数据存储空间中的数据地址,然后执行第一处理指令。
在一种可能的实现方式中,在与描述符的标识对应的数据存储空间的数据地址为可变地址时,所述描述符还可用于指示N维的张量数据的地址,其中,所述描述符的内容还可包括表示张量数据的地址的至少一个地址参数。例如,张量数据为3维数据,在描述符指向该张量数据的地址时,描述符的内容可包括表示该张量数据的地址的一个地址参数,例如张量数据的起始物理地址,也可以包括该张量数据的地址的多个地址参数,例如张量数据的起始地址+地址偏移量,或张量数据基于各维度的地址参数。本领域技术人员可以根据实际需要对地址参数进行设置,本公开对此不作限制。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址。其中,基准地址可根据数据基准点的变化而不同。本公开对数据基准点的选取不作限制。
在一种可能的实现方式中,所述基准地址可包括所述数据存储空间的起始地址。在描述符的数据基准点是数据存储空间的第一个数据块时,描述符的基准地址即为数据存储空间的起始地址。在描述符的数据基准点是数据存储空间中第一个数据块以外的其他数据时,描述符的基准地址即为该数据块在数据存储空间中的地址。
在一种可能的实现方式中,所述张量数据的形状参数包括以下至少一种:所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。其中,数据描述位置是描述符所指示的张量数据中的点或区域的映射位置,例如,张量数据为3维数据时,描述符可使用三维空间坐标(x,y,z)来表示该张量数据的形状,该张量数据的数据描述位置可以是使用三维空间坐标(x,y,z)表示的、该张量数据映射在三维空间中的点或区域的位置。应当理解,本领域技术人员可以根据实际情况选择表示张量数据的形状参数,本公开对此不作限制。
通过在数据存取过程中使用描述符,可建立数据之间的关联,从而降低数据存取的复杂度,提高指令处理效率。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址、所述数据存储空间的N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的尺寸和/或所述存储区域在N个维度方向的至少一个方向上的偏移量,确定所述张量数据的描述符的内容。
图2示出根据本公开实施例的数据存储空间的示意图。如图2所示,数据存储空间21采用行优先的方式存储了一个 二维数据,可通过(x,y)来表示(其中,X轴水平向右,Y轴垂直向下),X轴方向上的尺寸(每行的尺寸)为ori_x(图中未示出),Y轴方向上的尺寸(总行数)为ori_y(图中未示出),数据存储空间21的起始地址PA_start(基准地址)为第一个数据块22的物理地址。数据块23是数据存储空间21中的部分数据,其在X轴方向上的偏移量25表示为offset_x,在Y轴方向上的偏移量24表示为offset_y,在X轴方向上的尺寸表示为size_x,在Y轴方向上的尺寸表示为size_y。
在一种可能的实现方式中,使用描述符来定义数据块23时,描述符的数据基准点可使用数据存储空间21的第一个数据块,描述符的基准地址为数据存储空间21的起始地址PA_start,然后可以结合数据存储空间21在X轴的尺寸ori_x、在Y轴上的尺寸ori_y,以及数据块23在Y轴方向的偏移量offset_y、X轴方向上的偏移量offset_x、X轴方向上的尺寸size_x以及Y轴方向上的尺寸size_y来确定数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(1)来表示描述符的内容:
Figure PCTCN2020082775-appb-000008
应当理解,虽然上述示例中,描述符的内容表示的是二维空间,但本领域技术人员可以根据实际情况对描述符的内容表示的具体维度进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置,确定所述张量数据的描述符的内容。
举例来说,可以使用描述符的数据基准点在数据存储空间中的基准地址PA_base,以及对角位置的两个顶点相对于数据基准点的位置,确定出图2中数据块23的描述符的内容。首先,确定描述符的数据基准点以及其在数据存储空间中的基准地址PA_base,例如,可以在数据存储空间21中选取一个数据(例如,位置为(2,2)的数据)作为数据基准点,将该数据在数据存储空间中的物理地址作为基准地址PA_base;然后,确定数据块23的对角位置的至少两个顶点相对于数据基准点的位置,例如,使用左上至右下方向的对角位置顶点相对于数据基准点的位置,其中,左上角顶点的相对位置为(x_min,y_min),右下角顶点的相对位置为(x_max,y_max),然后可以根据基准地址PA_base、左上角顶点的相对位置(x_min,y_min)以及右下角顶点的相对位置(x_max,y_max)确定出数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(2)来表示描述符的内容:
Figure PCTCN2020082775-appb-000009
应当理解,虽然上述示例中使用左上角和右下角两个对角位置的顶点来确定描述符的内容,但本领域技术人员可以根据实际需要对对角位置的至少两个顶点的具体顶点进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址,以及所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系,确定所述张量数据的描述符的内容。其中,数据描述位置与数据地址之间的映射关系可以根据实际需要进行设定,例如,描述符所指示的张量数据为三维空间数据时,可是使用函数f(x,y,z)来定义数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,可以使用下述公式(3)来表示描述符的内容:
Figure PCTCN2020082775-appb-000010
应当理解,本领域技术人员可以根据实际情况对数据描述位置与数据地址之间的映射关系进行设定,本公开对此不作限制。
在一种可能的实现方式中,执行单元12接收到控制单元11发送的描述符的内容及第一处理指令时,可根据描述符的内容,确定与第一处理指令的操作数对应的数据在数据存储空间中的数据地址。其中,数据地址的计算由硬件自动完成,且描述符的内容的表示方式不同时,数据地址的计算方法也会不同。本公开对数据地址的具体计算方法不作限制。
例如,操作数中描述符的内容是使用公式(1)表示的,描述符所指示的张量数据在数据存储空间中的偏移量分别为offset_x和offset_y,尺寸为size_x*size_y,那么,该描述符所指示的张量数据在数据存储空间中的起始数据地址PA1 (x,y)可以使用下述公式(4)来确定:
PA1 (x,y)=PA_start+(offset_y-1)*ori_x+offset_x  (4)
根据上述公式(4)确定的数据起始地址PA1 (x,y),结合偏移量offset_x和offset_y,以及存储区域的尺寸size_x和size_y,可确定出描述符所指示的张量数据在数据存储空间中的存储区域。
在一种可能的实现方式中,执行单元12接收到控制单元11发送的描述符的内容及第一处理指令,当操作数还包括针对描述符的数据描述位置时,可根据描述符的内容以及数据描述位置,确定操作数对应的数据在数据存储空间中的数据地址。通过这种方式,可以对描述符所指示的张量数据中的部分数据(例如一个或多个数据)进行处理。
例如,操作数中描述符的内容是使用公式(1)表示的,描述符所指示的张量数据在数据存储空间中偏移量分别为offset_x和offset_y,尺寸为size_x*size_y,操作数中包括的针对描述符的数据描述位置为(x q,y q),那么,该描述符所指示的张量数据在数据存储空间中的数据地址PA2 (x,y)可以使用下述公式(5)来确定:
PA2 (x,y)=PA_start+(offset_y+y q-1)*ori_x+(offset_x+x q)  (5)
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,所述控制单元11b用于在所述源数据包括第一描述符的标识,且所述目的数据包括第二描述符的标识时,从所述描述符存储空间分别获取所述第一描述符的内容和所述第二描述符的内容;向所述执行单元12b发送所述第一描述符的内容、所述第二描述符的内容及所述第一处理指令;
其中,所述执行单元12b用于根据接收到的所述第一描述符的内容和所述第二描述符的内容,分别获取所述源数据的第一数据地址和所述目的数据的第二数据地址;从所述第一数据地址读取数据并写入到所述第二数据地址。
举例来说,在源数据和目的数据均包括描述符的标识的情况下,源数据可以是片下的一组待读取数据,其第一描述符的标识为1,目的数据是片上的一块存储空间,其第二描述符的标识为2。控制单元11b可根据源数据中第一描述符的标识1以及目的数据中第二描述符的标识2,从描述符存储空间分别获取第一描述符的内容D1和第二描述符的内容D2,并将第一描述符的内容D1、第二描述符的内容D2以及第一处理指令发给执行单元12b。其中,第一描述符的内容D1和第二描述符的内容可分别表示如下:
Figure PCTCN2020082775-appb-000011
Figure PCTCN2020082775-appb-000012
执行单元12b根据接收到的第一描述符的内容D1和第一描述符的内容D2,可分别获取源数据的起始物理地址PA3和目的数据的起始物理地址PA4,分别表示如下:
PA3=PA_start1+(offset_y1-1)*ori_x1+offset_x1
PA4=PA_start2+(offset_y2-1)*ori_x2+offset_x2
执行单元12b根据源数据的起始物理地址PA3和目的数据的起始物理地址PA4,以及第一描述符的内容D1和第二描述符的内容D2,可分别确定第一数据地址和第二数据地址,然后从第一数据地址读取数据并写入第二数据地址(可通过IO通路),从而完成将D1所指向的张量数据载入到D2所指向的存储空间,即,完成了数据从片下到片上的载入。应当理解,数据从片上到片下的传输,与上述过程类似,此处不再赘述。
在一种可能的实现方式中,数据载入时可以设定载入数据的规模,其中,载入数据的规模,可根据使用需要或存储空间的大小进行设定。例如,根据使用需要,在数据载入时,可以设定载入D1中的前10个数据。本公开对载入数据的具体规模不作限制。
通过这种方式可使用描述符完成数据的存取,描述符的内容存储在描述符存储空间,无需在每次存取时通过指令传入数据地址,从而可以提高处理器的数据存取效率。
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,所述控制单元11b用于在所述源数据包括第三描述符的标识时,从所述描述符存储空间获取所述第三描述符的内容;向所述执行单元12b发送所述第三描述符的内容及所述第一处理指令;
其中,所述执行单元12b用于根据接收到的所述第三描述符的内容,获取所述源数据的第三数据地址;从所述第三 数据地址读取数据并写入到所述目的数据的数据地址。
举例来说,在源数据和目的数据均包括描述符的标识的情况下,源数据可以是片下的一组待读取数据,其第一描述符的标识为3,目的数据是片上的一块存储空间。控制单元11可根据源数据中第三描述符的标识3,从描述符存储空间获取第三描述符的内容D3,并将第三描述符的内容D3以及第一处理指令发给执行单元12b。其中,第三描述符的内容D3可表示如下:
Figure PCTCN2020082775-appb-000013
执行单元12b根据接收到的第三描述符的内容D3,可获取源数据的起始物理地址PA5,表示如下:
PA5=PA_start3+(offset_y3-1)*ori_x3+offset_x3
执行单元12b可根据第一处理指令中目的数据的地址信息,计算目的数据的起始物理地址以及目标数据的数据地址。例如,目的数据的地址信息中包括起始地址、偏移量的通用寄存器编号,可以先访问通用寄存器获取偏移量,再将起始地址与偏移量相加,得到目的数据的起始物理地址;然后根据目标数据的尺寸,即可确定目的数据的数据地址。
执行单元12b根据源数据的起始物理地址PA5以及第三描述符的内容D3,可确定第三数据地址,然后从第三数据地址读取数据并写入到目的数据的数据地址(可通过IO通路),从而完成将D3所指向的张量数据载入到目的数据的存储空间,即,完成了数据从片下到片上的载入。应当理解,数据从片上到片下的传输,与上述过程类似,此处不再赘述。
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,所述控制单元11b用于在所述目的数据包括第四描述符的标识时,从所述描述符存储空间获取所述第四描述符的内容;向所述执行单元12b发送所述第四描述符的内容及所述第一处理指令;
其中,所述执行单元12b用于根据接收到的所述第四描述符的内容,获取所述目的数据的第四数据地址;从所述源数据的数据地址读取数据并写入到所述第四数据地址。
举例来说,在目的数据包括描述符的标识的情况下,源数据可以是片下的一组待读取数据,目的数据是片上的一块存储空间,其第四描述符的标识为4。控制单元11b可根据目标数据中第四描述符的标识4,从描述符存储空间获取第四描述符的内容D4,并将第四描述符的内容D4以及第一处理指令发给执行单元12b。其中,第四描述符的内容D4可表示如下:
Figure PCTCN2020082775-appb-000014
执行单元12b根据接收到的第四描述符的内容D4,可获取目标数据的起始物理地址PA6,表示如下:
PA6=PA_start4+(offset_y4-1)*ori_x4+offset_x4
执行单元12b可根据第一处理指令中源数据的地址信息,计算源数据的起始物理地址以及源数据的数据地址,例如,源数据的地址信息中包括起始地址、偏移量的通用寄存器编号,可以先访问通用寄存器获取偏移量,再将起始地址与偏移量相加,得到源数据的起始物理地址;然后根据源数据的尺寸,即可确定源数据的数据地址。
执行单元12b根据目标数据的起始物理地址PA6以及第四描述符的内容D4,可确定第四数据地址,然后从源数据的数据地址读取数据并写入到第四数据地址(可通过IO通路),从而完成将源数据载入到D4所指向的存储空间,即,完成了数据从片下到片上的载入。应当理解,数据从片上到片下的传输,与上述过程类似,此处不再赘述。
在一种可能的实现方式中,所述第一处理指令包括运算指令,其中,所述执行单元根据所述数据地址,执行与所述第一处理指令对应的数据处理可包括:从所述数据地址读取数据并执行与所述运算指令对应的运算。
举例来说,在第一处理指令为运算指令,且运算指令的操作数包括描述符标识的情况下,控制单元11可根据描述符的标识,从描述符存储空间获取描述符的内容,并将描述符的内容及运算指令发送给执行单元12;执行单元12根据接收到的描述符的内容,确定待运算数据的数据地址,从该数据地址读取待运算的数据并执行与运算指令对应的运算。例如,运算指令为ADD指令,在其操作数包括描述符的标识时,控制单元11可根据描述符的标识获取描述符的内容,并将描述符的内容及ADD指令发送给执行单元12b,执行单元12b可根据描述符的内容确定出待运算数据的数据地址,并执行ADD运算。在操作数是片下数据时,执行单元12b可根据数据地址,通过IO通路将数据载入到片上,然后从操作数在片上的数据地址中读取数据并执行ADD操作。
通过这种方式,可以使用描述符完成数据的传输,提高处理器的数据存取效率。
根据本公开实施例的数据处理装置,引入了能够描述数据的形状的描述符,使得第一处理指令运行过程中能够通过描述符来确定数据的地址,从硬件方面简化了指令生成方式,从而降低数据存取的复杂度,并且提高处理器存取数据的效率。
需要说明的是,尽管以上述实施例作为示例介绍了数据处理装置如上,但本领域技术人员能够理解,本公开应不限于此。事实上,用户完全可根据个人喜好和/或实际应用场景灵活设定各模块,只要符合本公开的技术方案即可。
图3b示出根据本公开实施例的数据处理方法的流程图。如图3b所示,所述数据处理方法应用于处理器,所述方法包括:
步骤S41b,在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,从描述符存储空间获取所述描述符的内容,所述描述符用于指示张量的形状;
步骤S42b,根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
步骤S43b,根据所述数据地址,执行与所述第一处理指令对应的数据处理。
在一种可能的实现方式中,步骤S42b可包括:
在所述操作数还包括针对所述描述符的数据描述位置时,根据所述描述符的内容以及所述数据描述位置,确定所述操作数对应的数据在所述数据存储空间中的数据地址。
在一种可能的实现方式中,所述描述符用于指示N维的张量数据的形状,N为正整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
在一种可能的实现方式中,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,所述基准地址包括所述数据存储空间的起始地址。
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,在解码后的第一处理指令的操作数包括描述符的标识时,步骤S41b可包括:在所述源数据包括第一描述符的标识,且所述目的数据包括第二描述符的标识时,从所述描述符存储空间分别获取所述第一描述符的内容和所述第二描述符的内容;
其中,步骤S42b可包括:根据所述第一描述符的内容和所述第二描述符的内容,分别获取所述源数据的第一数据地址和所述目的数据的第二数据地址;
其中,步骤S43b可包括:从所述第一数据地址读取数据并写入到所述第二数据地址。
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,在解码后的第一处理指令的操作数包括描述符的标识时,步骤S41b可包括:在所述源数据包括第三描述符的标识时,从所述描述符存储空间获取所述第三描述符的内容;
其中,步骤S42b可包括:根据所述第三描述符的内容,获取所述源数据的第三数据地址;
其中,步骤S43b可包括:从所述第三数据地址读取数据并写入到所述目的数据的数据地址。
在一种可能的实现方式中,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,在解码后的第一处理指令的操作数包括描述符的标识时,步骤S41b可包括:在所述目的数据包括第四描述符的标识时,从所述描述符存储空间获取所述第四描述符的内容;
其中,步骤S42b可包括:根据所述第四描述符的内容,获取所述目的数据的第四数据地址;
其中,步骤S43b可包括:从所述源数据的数据地址读取数据并写入到所述第四数据地址。
在一种可能的实现方式中,所述第一处理指令包括运算指令,
其中,步骤S43b可包括:从所述数据地址读取数据并执行与所述运算指令对应的运算。
在一种可能的实现方式中,所述方法还包括:
对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,
其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。
在一种可能的实现方式中,所述描述符存储空间为所述处理器的内部存储器中的存储空间,所述数据存储空间为所述处理器的内部存储器或外部存储器中的存储空间。
在一种可能的实现方式中,还公开了一种人工智能芯片,其包括了上述数据处理装置。
在一种可能的实现方式中,还公开了一种板卡,其包括存储器件、接口装置和控制器件以及上述人工智能芯片;其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;所述控制器件,用于对所述人工智能芯片的状态进行监控。
图4示出根据本公开实施例的板卡的结构框图,参阅图4,上述板卡除了包括上述芯片389以外,还可以包括其他的配套部件,该配套部件包括但不限于:存储器件390、接口装置391和控制器件392;
所述存储器件390与所述人工智能芯片通过总线连接,用于存储数据。所述存储器件可以包括多组存储单元393。每一组所述存储单元与所述人工智能芯片通过总线连接。可以理解,每一组所述存储单元可以是DDR SDRAM(英文:Double Data Rate SDRAM,双倍速率同步动态随机存储器)。
DDR不需要提高时钟频率就能加倍提高SDRAM的速度。DDR允许在时钟脉冲的上升沿和下降沿读出数据。DDR的速度是标准SDRAM的两倍。在一个实施例中,所述存储装置可以包括4组所述存储单元。每一组所述存储单元可以包括多个DDR4颗粒(芯片)。在一个实施例中,所述人工智能芯片内部可以包括4个72位DDR4控制器,上述72位DDR4控制器中64bit用于传输数据,8bit用于ECC校验。可以理解,当每一组所述存储单元中采用DDR4-3200颗粒时,数据传输的理论带宽可达到25600MB/s。
在一个实施例中,每一组所述存储单元包括多个并联设置的双倍速率同步动态随机存储器。DDR在一个时钟周期内可以传输两次数据。在所述芯片中设置控制DDR的控制器,用于对每个所述存储单元的数据传输与数据存储的控制。
所述接口装置与所述人工智能芯片电连接。所述接口装置用于实现所述人工智能芯片与外部设备(例如服务器或计算机)之间的数据传输。例如在一个实施例中,所述接口装置可以为标准PCIE接口。比如,待处理的数据由服务器通过标准PCIE接口传递至所述芯片,实现数据转移。优选的,当采用PCIE 3.0 X 16接口传输时,理论带宽可达到16000MB/s。在另一个实施例中,所述接口装置还可以是其他的接口,本申请并不限制上述其他的接口的具体表现形式,所述接口单元能够实现转接功能即可。另外,所述人工智能芯片的计算结果仍由所述接口装置传送回外部设备(例如服务器)。
所述控制器件与所述人工智能芯片电连接。所述控制器件用于对所述人工智能芯片的状态进行监控。具体的,所述人工智能芯片与所述控制器件可以通过SPI接口电连接。所述控制器件可以包括单片机(Micro Controller Unit,MCU)。如所述人工智能芯片可以包括多个处理芯片、多个处理核或多个处理电路,可以带动多个负载。因此,所述人工智能芯片可以处于多负载和轻负载等不同的工作状态。通过所述控制装置可以实现对所述人工智能芯片中多个处理芯片、多个处理和或多个处理电路的工作状态的调控。
在一种可能的实现方式中,公开了一种电子设备,其包括了上述人工智能芯片。电子设备包括数据处理装置、机器人、电脑、打印机、扫描仪、平板电脑、智能终端、手机、行车记录仪、导航仪、传感器、摄像头、服务器、云端服务器、相机、摄像机、投影仪、手表、耳机、移动存储、可穿戴设备、交通工具、家用电器、和/或医疗设备。
所述交通工具包括飞机、轮船和/或车辆;所述家用电器包括电视、空调、微波炉、冰箱、电饭煲、加湿器、洗衣机、电灯、燃气灶、油烟机;所述医疗设备包括核磁共振仪、B超仪和/或心电图仪。
A1、一种数据处理装置,所述装置包括控制单元以及执行单元,所述控制单元用于:
在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,从描述符存储空间获取所述描述符的内容,所述描述符用于指示张量的形状;
向所述执行单元发送所述描述符的内容及所述第一处理指令,以使所述执行单元根据所述描述符的内容执行所述第一处理指令。
A2、根据权利要求A1所述的装置,所述执行单元用于:
根据接收到的描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
根据所述数据地址,执行与所述第一处理指令对应的数据处理。
A3、根据权利要求A2所述的装置,根据接收到的描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址,包括:
在所述操作数还包括针对所述描述符的数据描述位置时,根据所述描述符的内容以及所述数据描述位置,确定所述操作数对应的数据在所述数据存储空间中的数据地址。
A4、根据权利要求A1-A3中任意一项所述的装置,所述描述符用于指示N维的张量数据的形状,N为正整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A5、根据权利要求A4所述的装置,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A6、根据权利要求A5所述的装置,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A7、根据权利要求A6所述的装置,所述基准地址包括所述数据存储空间的起始地址。
A8、根据权利要求A2-A7中任意一项所述的装置,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,所述控制单元用于:
在所述源数据包括第一描述符的标识,且所述目的数据包括第二描述符的标识时,从所述描述符存储空间分别获取所述第一描述符的内容和所述第二描述符的内容;
向所述执行单元发送所述第一描述符的内容、所述第二描述符的内容及所述第一处理指令;
其中,所述执行单元用于:
根据接收到的所述第一描述符的内容和所述第二描述符的内容,分别获取所述源数据的第一数据地址和所述目的数据的第二数据地址;
从所述第一数据地址读取数据并写入到所述第二数据地址。
A9、根据权利要求A2-A7中任意一项所述的装置,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,所述控制单元用于:
在所述源数据包括第三描述符的标识时,从所述描述符存储空间获取所述第三描述符的内容;
向所述执行单元发送所述第三描述符的内容及所述第一处理指令;
其中,所述执行单元用于:
根据接收到的所述第三描述符的内容,获取所述源数据的第三数据地址;
从所述第三数据地址读取数据并写入到所述目的数据的数据地址。
A10、根据权利要求A2-A7中任意一项所述的装置,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,所述控制单元用于:
在所述目的数据包括第四描述符的标识时,从所述描述符存储空间获取所述第四描述符的内容;
向所述执行单元发送所述第四描述符的内容及所述第一处理指令,
其中,所述执行单元用于:
根据接收到的所述第四描述符的内容,获取所述目的数据的第四数据地址;
从所述源数据的数据地址读取数据并写入到所述第四数据地址。
A11、根据权利要求A2所述的装置,所述第一处理指令包括运算指令,
其中,所述执行单元根据所述数据地址,执行与所述第一处理指令对应的数据处理,包括:
从所述数据地址读取数据并执行与所述运算指令对应的运算。
A12、根据权利要求A1-A11中任意一项所述的装置,所述控制单元还用于:
对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,
其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。
A13、根据权利要求A1-A12中任意一项所述的装置,所述描述符存储空间为所述控制单元的内部存储器中的存储空间,所述数据存储空间为所述控制单元的内部存储器或与所述控制单元连接的外部存储器中的存储空间。
A14、一种数据处理方法,所述方法应用于处理器,所述方法包括:
在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,从描述符存储空间获取所述描述符的内容,所述描述符用于指示张量的形状;
根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
根据所述数据地址,执行与所述第一处理指令对应的数据处理。
A15、根据权利要求A14所述的方法,根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址,包括:
在所述操作数还包括针对所述描述符的数据描述位置时,根据所述描述符的内容以及所述数据描述位置,确定所述操作数对应的数据在所述数据存储空间中的数据地址。
A16、根据权利要求A14或A15所述的方法,所述描述符用于指示N维的张量数据的形状,N为正整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A17、根据权利要求A16所述的方法,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A18、根据权利要求A17所述的方法,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A19、根据权利要求A18所述的方法,所述基准地址包括所述数据存储空间的起始地址。
A20、根据权利要求A14-A19中任意一项所述的方法,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,从描述符存储空间获取所述描述符的内容,包括:在所述源数据包括第一描述符的标识,且所述目的数据包括第二描述符的标识时,从所述描述符存储空间分别获取所述第一描述符的内容和所述第二描述符的内容;
其中,根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址,包括:根据所述第一描述符的内容和所述第二描述符的内容,分别获取所述源数据的第一数据地址和所述目的数据的第二数据地址;
其中,根据所述数据地址,执行与所述第一处理指令对应的数据处理,包括:从所述第一数据地址读取数据并写入到所述第二数据地址。
A21、根据权利要求A14-A19中任意一项所述的方法,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,从描述符存储空间获取所述描述符的内容,包括:在所述源数据包括第三描述符的标识时,从所述描述符存储空间获取所述第三描述符的内容;
其中,根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址,包括:根据所述第三描述符的内容,获取所述源数据的第三数据地址;
其中,根据所述数据地址,执行与所述第一处理指令对应的数据处理,包括:从所述第三数据地址读取数据并写 入到所述目的数据的数据地址。
A22、根据权利要求A14-A19中任意一项所述的方法,所述第一处理指令包括数据存取指令,所述操作数包括源数据和目的数据,
其中,在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,从描述符存储空间获取所述描述符的内容,包括:在所述目的数据包括第四描述符的标识时,从所述描述符存储空间获取所述第四描述符的内容;
其中,根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址,包括:
根据所述第四描述符的内容,获取所述目的数据的第四数据地址;
其中,根据所述数据地址,执行与所述第一处理指令对应的数据处理,包括:从所述源数据的数据地址读取数据并写入到所述第四数据地址。
A23、根据权利要求A14所述的方法,所述第一处理指令包括运算指令,
其中,根据所述数据地址,执行与所述第一处理指令对应的数据处理,包括:
从所述数据地址读取数据并执行与所述运算指令对应的运算。
A24、根据权利要求A14-A23中任意一项所述的方法,所述方法还包括:
对接收到的第一处理指令进行解码处理,得到解码后的第一处理指令,
其中,解码后的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。
A25、根据权利要求A14-A24中任意一项所述的方法,所述描述符存储空间为所述处理器的内部存储器中的存储空间,所述数据存储空间为所述处理器的内部存储器或外部存储器中的存储空间。
A26、一种人工智能芯片,所述芯片包括如权利要求A1-A13中任意一项所述的数据处理装置。
A27、一种电子设备,所述电子设备包括如权利要求A26所述的人工智能芯片。
A28、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求A26所述的人工智能芯片;
其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;
所述存储器件,用于存储数据;
所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;
所述控制器件,用于对所述人工智能芯片的状态进行监控。
A29、根据权利要求A28所述的板卡,所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;
所述芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;
所述接口装置为:标准PCIE接口。
随着人工智能算法的复杂度提高,需要处理的数据量和数据维度都在不断增大,通常需要多核和/或多芯片进行数据处理。在进行核间或芯片间的数据同步时,采用相关技术的同步方式的同步开销较大,处理效率较低。
根据本公开的实施例,提供了一种数据同步方法。图1c示出根据本公开实施例的数据同步方法的流程图。该数据同步方法可应用于第一处理器中,该第一处理器可包括通用处理器(例如中央处理器CPU、图形处理器GPU)和专用处理器(例如人工智能处理器、科学计算处理器或数字信号处理器等)。本公开对第一处理器的类型不作限制。
如图1c所示,该数据同步方法包括:
在步骤S11c中,根据待同步的张量数据的描述符,生成描述符同步指令,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;
在步骤S12c中,向第二处理器发送所述描述符同步指令,所述描述符同步指令用于指示第二处理器根据所述描述符同步指令获取所述待同步的张量数据。
举例来说,待同步的数据可包括N维的张量数据(N为大于或等于零的整数,例如N=1、2或3),其中,张量可以包含多种形式的数据组成方式,张量可以是不同维度的,比如标量可以看作是0维张量,向量可以看作1维张量,而矩阵可以是2维或2维以上的张量。张量的形状包括张量的维度、张量各个维度的尺寸等信息。例如对于张量:
Figure PCTCN2020082775-appb-000015
该张量的形状可以被描述符描述为(2,4),也即通过两个参数表示该张量为二维张量,且该张量的第一维度(列)的尺寸为2、第二维度(行)的尺寸为4。需要说明的是,本公开对于描述符指示张量形状的方式并不做限定。在存储器中存储张量数据时,根据其数据地址(或存储区域)无法确定张量数据的形状,进而也无法确定多个张量数据之间相互关系等相关信息,导致处理器对张量数据的存取效率较低,在进行数据同步时的复杂度也较大。
在该情况下,可设定描述符(张量描述符)来指示张量数据(N维的张量数据)的形状。其中,N的取值可根据张量数据的维数(阶数)来确定,也可以根据张量数据的使用需要进行设定。例如,在N的取值为3时,张量数据为三维的张量数据,描述符可用来指示该三维的张量数据在三个维度方向上的形状(例如偏移量、尺寸等)。应当理解,本领域技术人员可以根据实际需要对N的取值进行设置,本公开对此不作限制。
在一种可能的实现方式中,描述符可包括标识和内容等,描述符的标识可用于对描述符进行区分,例如为编号;描述符的内容可包括表示张量数据的形状的至少一个形状参数(例如张量的各个维度方向上的尺寸等),还可以包括表示张量数据的地址的至少一个地址参数(例如数据基准点的基准地址)。本公开对描述符的内容包括的具体参数不作限制。通过采用描述符来指示张量数据的方式,能够表达张量数据的形状,进而也能够确定多个张量数据之间的相互关系等相关信息,提高对张量数据的存取效率,从而降低数据同步时的复杂度。
在一种可能的实现方式中,在数据处理过程中,可能需要进行多个处理器(例如人工智能芯片的多个核)之间的数据同步,例如将处理器A1的运算结果同步到处理器A2中做为另一项运算的输入数据。在该情况下,可以采用基于描述符的数据同步机制实现数据同步。
在一种可能的实现方式中,第一处理器是数据同步的发送方,第二处理器是数据同步的接收方。当存在待同步的张量数据时,第一处理器可在步骤S11c中根据该张量数据的描述符,生成描述符同步指令,并在步骤S12c中向待同步的第二处理器发送该描述符同步指令。其中,第二处理器可包括通用处理器(例如中央处理器CPU、图形处理器GPU)和专用处理器(例如人工智能处理器、科学计算处理器或数字信号处理器等)。第二处理器可与第一处理器的类型相同或不同,本公开对第二处理器的类型不作限制。
在一种可能的实现方式中,第一处理器可以主动发起对第二处理器的数据同步,例如在第一处理器完成一项运算得到运算结果(张量数据)时,主动发起对需要使用该运算结果的第二处理器的数据同步。在另一个示例中,第一处理器也可以响应于第二处理器的同步请求,发起对第二处理器的数据同步,例如在接收到第二处理器的同步请求指令时,发起对第二处理器的数据同步。本公开对数据同步的发起时机不作限制。
在一种可能的实现方式中,当第一处理器确定存在待同步的张量数据时,可以获取该张量数据的描述符。该描述符可以是已注册(创建)的用于指示该张量数据的形状的描述符,也可以根据该张量数据的形状参数注册(创建)新的描述符,本公开对此不作限制。
在一种可能的实现方式中,根据该张量数据的描述符,可生成描述符同步指令,该描述符同步指令包括所述描述符的标识和/或所述描述符的内容。如果第二处理器中已注册有指示该待同步的张量数据的描述符,则描述符同步指令可仅包括描述符的标识(例如在描述符的标识为TR1时,将描述符同步指令表示为Send TR1),以指示第二处理器根据该描述符的标识(TR1)实现张量数据的同步;如果第二处理器中未注册指示该待同步的张量数据的描述符,则描述符同步指令可包括描述符的内容,或同时包括描述符的标识和内容两者,以指示第二处理器根据该描述符的内容实现张量数据的同步。本公开对描述符同步指令包括的具体内容不作限制。
在一种可能的实现方式中,在生成描述符同步指令后,可向第二处理器发送该描述符同步指令,以指示第二处理器根据所述描述符同步指令获取所述待同步的张量数据。如果描述符同步指令包括描述符的标识,则第二处理器可根据描述符的标识获取描述符的内容,再根据描述符的内容获取描述符所指示的张量数据,从而实现张量数据的同步。如果描述符同步指令包括描述符的内容,则第二处理器可根据描述符的内容直接获取描述符所指示的张量数据,从而实现张量数据的同步。
根据本公开实施例的数据同步方法,通过设定指示张量数据的形状的描述符,能够在需要数据同步时,根据待同步的张量数据的描述符生成描述符同步指令并向第二处理器发送该指令,以指示第二处理器根据描述符同步指令获取待同步的张量数据,从而减少同步开销,降低数据同步的复杂度,提高数据同步的效率。
在一种可能的实现方式中,所述方法还包括:根据来自第二处理器的描述符同步请求指令,确定所述待同步的张 量数据的描述符。
举例来说,第一处理器可响应于第二处理器的同步请求,发起对第二处理器的数据同步。其中,来自第二处理器的描述符同步请求指令可包括待同步的张量数据的信息,例如指示该待同步的张量数据的描述符的标识、该待同步的张量数据的数据特征等。其中,张量数据的数据特征可包括张量数据的形状、来源、地址等信息,本公开对描述符同步请求指令的具体内容不作限制。根据描述符同步请求指令中的信息,第一处理器可确定待同步的张量数据的描述符,进而生成描述符同步指令。
通过这种方式,可以根据第二处理器的同步请求确定待同步的张量数据的描述符,以便生成描述符同步指令,从而避免不必要的数据同步,提高了数据同步的效率。
在一种可能的实现方式中,所述描述符同步请求指令包括描述符的标识,
其中,所述根据来自第二处理器的描述符同步请求指令,确定所述待同步的张量数据的描述符的步骤可包括:解析所述描述符同步请求指令,获得所述描述符的标识;根据所述描述符的标识,确定所述待同步的张量数据的描述符。
举例来说,如果第一处理器和第二处理器均已注册有指示该张量数据的描述符,且描述符的标识相同或具有对应关系,则描述符同步请求指令中可包括描述符的标识,例如在描述符的标识为TR1时,将描述符同步请求指令表示为Receive TR1。第一处理器可解析来自第二处理器的描述符同步请求指令,得到描述符的标识;进而根据描述符的标识,确定所述待同步的张量数据的描述符,以便生成描述符同步指令。
通过这种方式,可以根据请求指令中的描述符标识确定待同步的张量数据的描述符,以便实现张量数据的同步,从而减小同步时传输的数据量,提高处理效率。
在一种可能的实现方式中,所述描述符同步请求指令包括所述待同步的张量数据的数据特征,
其中,所述根据来自第二处理器的描述符同步请求指令,确定所述待同步的张量数据的描述符的步骤可包括:解析所述描述符同步请求指令,获得待同步的张量数据的数据特征;根据待同步的张量数据的数据特征,确定所述待同步的张量数据的描述符。
举例来说,如果第二处理器中未注册指示该张量数据的描述符,或已注册有指示该张量数据的描述符但描述符标识不具有对应关系,则描述符同步请求指令中可包括待同步的张量数据的数据特征。第一处理器可解析来自第二处理器的描述符同步请求指令,得到待同步的张量数据的数据特征;进而根据待同步的张量数据的数据特征,确定所述待同步的张量数据及其描述符,以便生成描述符同步指令。
在一种可能的实现方式中,待同步的张量数据的数据特征可包括张量数据的形状、来源、地址等信息。例如,该张量数据的数据来源为第K个发送方(第K个处理器)、该张量数据的数据来源为编号200的卷积操作的运算结果、该张量数据的地址为特定的地址区域(例如地址ADDR0-ADDR127)、该张量数据的形状为指定的形状(例如20*10的二维张量)等。本领域技术人员可根据实际情况设定待同步的张量数据的数据特征,本公开对此不作限制。
在一种可能的实现方式中,根据该数据特征,第一处理器可查找到待同步的张量数据,并确定该待同步的张量数据的描述符,例如直接获取或新注册对应的描述符。根据该待同步的张量数据的描述符,可生成并发送描述符同步指令,以指示第二处理器实现该张量数据的同步。
通过这种方式,可以根据请求指令中的数据特征确定待同步的张量数据的描述符,以便实现张量数据的同步,从而在同步时无需传输张量数据本身,减小了传输的数据量和同步开销,提高了处理效率。
在一种可能的实现方式中,所述描述符同步指令包括待同步的张量数据的描述符的内容,其中,步骤S11c可包括:
在待同步的张量数据的存储地址处于共用存储空间中时,根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
举例来说,多个处理器(多个核)可以具有共用存储空间,例如第一处理器和第二处理器均可以访问的片下存储器。该共用存储空间可以是多个核(多个处理器)均能够存取数据的存储空间,也可以是部分核(部分处理器)能够存取数据的存储空间,可以预先设定有核间的共用存储空间,本公开对共用存储空间的设定方式不作限制。
在一种可能的实现方式中,如果待同步的张量数据的存储地址处于共用存储空间中,则由于第二处理器也可从共用存储空间存取数据,第二处理器根据描述符的内容就可以直接读取张量数据以实现同步。在该情况下,描述符同步指令可包括待同步的张量数据的描述符的内容,也即,可根据所述待同步的张量数据的描述符的内容,生成描述符同步指令。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容;根据描述符的内容,第二处理器可 确定待同步的张量数据的数据地址,并从共用存储空间获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可以避免不必要的数据传输,减少张量数据存取次数,提高了同步的处理效率。
在一种可能的实现方式中,步骤S11c可包括:
将所述待同步的张量数据的描述符的内容存储到同步数据存储空间;
根据所述描述符的内容在所述同步数据存储空间中的地址,生成描述符同步指令,以指示所述第二处理器从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容。
举例来说,多个处理器(多个核)可以具有同步数据存储空间,专门用于存储同步数据。该同步数据存储空间可以是上述的共用存储空间,也可以是共用存储空间的一部分,还可以是与共用存储空间不同的存储空间,本公开对此不作限制。
在一种可能的实现方式中,同步数据存储空间可以是多个核(多个处理器)均能够存取同步数据的存储空间,也可以是部分核(部分处理器)能够存取同步数据的存储空间,本公开对此不作限制。
在一种可能的实现方式中,第一处理器在确定待同步的张量数据的描述符后,可以将描述符的内容存储到同步数据存储空间;并根据描述符的内容在同步数据存储空间中的地址,生成并发送描述符同步指令。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容的存储地址;根据该存储地址,第二处理器可从同步数据存储空间获取待同步的张量数据的描述符的内容,进而根据描述符的内容确定待同步的张量数据的数据地址,获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可以进一步减少同步时处理器间的数据传输,提高同步的处理效率。
在一种可能的实现方式中,步骤S11c可包括:
在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;
根据所述待同步的张量数据在共用存储空间中的地址,生成所述待同步的张量数据的描述符;
根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
举例来说,第一处理器可以具有非共用存储空间,第一处理器可存取该非共用存储空间中的数据,而第二处理器无法访问到第一处理器的非共用存储空间,不能存取该非共用存储空间中的数据。如果待同步的张量数据的存储地址处于非共用存储空间,则第二处理器无法直接获取该张量数据。在该情况下,第一处理器可将待同步的张量数据转存到共用存储空间,以使第二处理器能够存取该张量数据。在完成转存后,如果第一处理器中未注册指示该待同步的张量数据的描述符,或已注册有指示非共用存储空间中的该张量数据的描述符且该描述符不可修改(例如正在被操作),则第一处理器可生成所述待同步的张量数据的描述符,也即,注册新的描述符,以指示在共用存储空间中的该张量数据。
在一种可能的实现方式中,在生成描述符后,第一处理器可根据描述符的内容生成描述符同步指令。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容;根据描述符的内容,第二处理器可确定待同步的张量数据的数据地址,并从共用存储空间获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可将非共用存储空间中待同步的张量数据主动转存到共用存储空间,以使第二处理器能够获取待同步的张量数据,从而减少同步时处理器间的数据传输,提高同步的处理效率。
在一种可能的实现方式中,步骤S11c可包括:
在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;
根据所述待同步的张量数据在共用存储空间中的地址,修改所述待同步的张量数据的描述符;
根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
举例来说,与上面的描述类似,如果待同步的张量数据处于第一处理器非共用存储空间,则第一处理器可将待同步的张量数据转存到共用存储空间。在完成转存后,如果第一处理器中已注册有指示非共用存储空间中的该张量数据的描述符且该描述符可修改(例如描述符未被操作),则第一处理器可直接修改待同步的张量数据的描述符,使得该描述符指示在共用存储空间中的该张量数据。
在一种可能的实现方式中,在修改描述符后,第一处理器可根据描述符的内容生成描述符同步指令。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容;根据描述符的内容,第二处理器可确定待同步的张量数 据的数据地址,并从共用存储空间获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可将非共用存储空间中待同步的张量数据主动转存到共用存储空间,减少同步时处理器间的数据传输,提高同步的处理效率;并且,第一处理器不需要创建新的描述符,节省了有限的描述符资源。
图3c1示出根据本公开实施例的数据同步方法的流程图。该数据同步方法可应用于第二处理器中。如图3c1所示,该数据同步方法包括:
在步骤S21c中,解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;
在步骤S22c中,根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
举例来说,第一处理器(发送方)可以主动发起对第二处理器(接收方)的数据同步,例如在第一处理器完成一项运算得到运算结果(张量数据)时,主动发起对需要使用该运算结果的第二处理器的数据同步。
在一种可能的实现方式中,第二处理器在接收到来自第一处理器的描述符同步指令时,可解析该描述符同步指令,得到待同步的张量数据的描述符(例如描述符的标识和/或所述描述符的内容)。
在一种可能的实现方式中,如果该描述符同步指令仅包括描述符的标识,则第二处理器可内部查找该描述符的标识对应的描述符内容,进而根据描述符内容获取待同步的张量数据,从而实现张量数据的同步。
在一种可能的实现方式中,如果该描述符同步指令包括描述符的标识和内容,则第二处理器可查找该描述符的标识对应的描述符,并根据描述符同步指令中的描述符内容,更新原来的描述符内容;根据更新后的描述符内容获取待同步的张量数据,从而实现张量数据的同步。
在一种可能的实现方式中,如果该描述符同步指令包括描述符的内容,则第二处理器可根据描述符的内容,注册指示该待同步的张量数据的描述符,并根据描述符的内容获取待同步的张量数据,从而实现张量数据的同步。
根据本公开实施例的数据同步方法,通过设定指示张量数据的形状的描述符,能够根据描述符同步指令中的指示待同步的张量数据的描述符,获取待同步的张量数据,实现张量数据的同步,从而减少同步开销,降低数据同步的复杂度,提高数据同步的效率。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,步骤S22c包括:
根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
举例来说,如果待同步的张量数据的存储地址处于共用存储空间中,则第二处理器可从共用存储空间存取数据。在该情况下,描述符同步指令可包括待同步的张量数据的描述符的内容。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容;根据描述符的内容,第二处理器可确定待同步的张量数据的数据地址,并从共用存储空间获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可以避免不必要的数据传输,减少张量数据存取次数,提高了同步的处理效率。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,步骤S22c包括:
根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;
根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
举例来说,第一处理器在确定待同步的张量数据的描述符后,可以将描述符的内容存储到同步数据存储空间;并根据描述符的内容在同步数据存储空间中的地址,生成并发送描述符同步指令。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容的存储地址;根据该存储地址,第二处理器可从同步数据存储空间获取待同步的张量数据的描述符的内容,进而根据描述符的内容确定待同步的张量数据的数据地址,获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可以进一步减少同步时处理器间的数据传输,提高同步的处理效率。
图3c2示出根据本公开实施例的数据同步方法的流程图。该数据同步方法可应用于第二处理器中。如图3c2所示,该数据同步方法包括:
在步骤S31c中,当存在待同步的张量数据时,生成描述符同步请求指令,所述描述符同步请求指令用于指示第一处理器根据所述描述符同步请求指令发送待同步的张量数据的描述符,所述描述符用于指示待同步的张量数据的形状;
在步骤S32c中,向所述第一处理器发送所述描述符同步请求指令。
举例来说,当第二处理器中存在待同步的张量数据时,可以主动向第一处理器发送描述符同步请求指令,以便获取该待同步的张量数据。第二处理器可根据待同步的张量数据的信息,例如指示该待同步的张量数据的描述符的标识、该待同步的张量数据的数据特征等,生成描述符同步请求指令。本公开对描述符同步请求指令的具体内容不作限制。根据描述符同步请求指令中的信息,第一处理器可确定待同步的张量数据的描述符,进而生成描述符同步指令。
通过这种方式,可以在需要同步时主动发起同步请求,提高数据同步的效率。
在一种可能的实现方式中,所述描述符同步请求指令包括描述符的标识和/或所述待同步的张量数据的数据特征,以使第一处理器能够确定待同步的张量数据。其中,张量数据的数据特征可包括张量数据的形状、来源、地址等信息。本领域技术人员可根据实际情况设定待同步的张量数据的数据特征,本公开对此不作限制。
在一种可能的实现方式中,所述方法还包括:
解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容;
根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
举例来说,如果第一处理器和第二处理器均已注册有指示该张量数据的描述符,且描述符的标识相同或具有对应关系,则描述符同步请求指令中可包括描述符的标识,例如在描述符的标识为TR1时,将描述符同步请求指令表示为Receive TR1。第一处理器可解析来自第二处理器的描述符同步请求指令,得到描述符的标识;进而根据描述符的标识,确定所述待同步的张量数据的描述符,以便生成描述符同步指令。
在一种可能的实现方式中,第二处理器接收到描述符同步指令时,可解析该描述符同步指令,得到待同步的张量数据的描述符(描述符的标识和/或描述符的内容)。如果该描述符同步指令仅包括描述符的标识,则第二处理器可内部查找该描述符的标识对应的描述符内容,进而根据描述符内容获取待同步的张量数据,从而实现张量数据的同步。
在一种可能的实现方式中,如果该描述符同步指令包括描述符的标识和内容,则第二处理器可查找该描述符的标识对应的描述符,并根据描述符同步指令中的描述符内容,更新原来的描述符内容;根据更新后的描述符内容获取待同步的张量数据,从而实现张量数据的同步。
在一种可能的实现方式中,如果该描述符同步指令包括描述符的内容,则第二处理器可根据描述符的内容,注册指示该待同步的张量数据的描述符,并根据描述符的内容获取待同步的张量数据,从而实现张量数据的同步。
通过这种方式,可以降低数据同步的复杂度,提高数据同步的效率。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,所述根据所述待同步的张量数据的描述符,获取所述待同步的张量数据的步骤可包括:
根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
举例来说,如果待同步的张量数据的存储地址处于共用存储空间中,则第二处理器可从共用存储空间存取数据。在该情况下,描述符同步指令可包括待同步的张量数据的描述符的内容。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容;根据描述符的内容,第二处理器可确定待同步的张量数据的数据地址,并从共用存储空间获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可以避免不必要的数据传输,减少张量数据存取次数,提高了同步的处理效率。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,所述根据所述待同步的张量数据的描述符,获取所述待同步的张量数据的步骤可包括:
根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;
根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
第一处理器在确定待同步的张量数据的描述符后,可以将描述符的内容存储到同步数据存储空间;并根据描述符的内容在同步数据存储空间中的地址,生成并发送描述符同步指令。第二处理器接收到描述符同步指令后,可解析指令以得到描述符的内容的存储地址;根据该存储地址,第二处理器可从同步数据存储空间获取待同步的张量数据的描述符的内容,进而根据描述符的内容确定待同步的张量数据的数据地址,获取所述待同步的张量数据,从而实现整个同步过程。
通过这种方式,可以进一步减少同步时处理器间的数据传输,提高同步的处理效率。
在一种可能的实现方式中,描述符的标识和内容可存储在描述符存储空间中,该描述符存储空间可以为处理器的内部存储器(例如寄存器、片上的SRAM或其他介质缓存等)中的存储空间。描述符所指示的张量数据的数据存储空间可为处理器的内部存储器(例如片上缓存)或与处理器连接的外部存储器(片下存储器)中的存储空间。数据存储空间中的数据地址可以为实际的物理地址或虚拟地址。本公开对描述符存储空间及数据存储空间的位置以及数据地址的类型不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以位于同一块区域,例如,可使用片上缓存的一块连续区域存储描述符的相关内容,其地址为ADDR0-ADDR1023,其中,地址ADDR0-ADDR31可用于存储描述符的标识,地址ADDR32-ADDR63可用于存储描述符的内容,地址ADDR64-ADDR1023可用于存储描述符指示的张量数据。其中,地址ADDR并不限于1位或一个字节,此处用来表示一个地址,是一个地址单位。本领域技术人员可以根据实际情况确定存储区域及其地址,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以分开存储在内部存储器的不同区域,例如,可以将寄存器作为描述符存储空间,在寄存器中存储描述符的标识及内容,将片上缓存作为数据存储空间,存储描述符所指示的张量数据。
在一种可能的实现方式中,还可以设置专门供描述符使用的专用寄存器(SR),描述符中的数据可以是立即数也可以从专用寄存器中获取。在使用寄存器存储描述符的标识和内容时,可以使用寄存器的编号来表示描述符的标识,例如,寄存器的编号为0时,其存储的描述符的标识为0。当寄存器中的描述符有效时,可根据描述符所指示的张量数据的大小在缓存空间中分配一块区域(例如在缓存中为每个张量数据创建一个张量缓存单元)用于存储该张量数据。应当理解,也可以采用预设的缓存空间存储该张量数据,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识及内容可存储在内部存储器,描述符所指示的张量数据可存储在外部存储器。例如,可以采用在片上存储描述符的标识及内容、在片下存储描述符所指示的张量数据的方式。
在一种可能的实现方式中,与描述符对应的数据存储空间的数据地址可以是固定地址。例如,可以为张量数据划分单独的数据存储空间,每个张量数据在数据存储空间的起始地址与描述符的标识一一对应。在这种情况下,处理器根据描述符的内容即可确定张量数据的数据地址。
在一种可能的实现方式中,在与描述符对应的数据存储空间的数据地址为可变地址时,所述描述符还可用于指示N维的张量数据的地址,其中,所述描述符的内容还可包括表示张量数据的地址的至少一个地址参数。例如,张量数据为3维数据,在描述符指向该张量数据的地址时,描述符的内容可包括表示该张量数据的地址的一个地址参数,例如张量数据的起始地址,也可以包括该张量数据的地址的多个地址参数,例如张量数据的起始地址+地址偏移量,或张量数据基于各维度的地址参数。本领域技术人员可以根据实际需要对地址参数进行设置,本公开对此不作限制。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址。其中,基准地址可根据数据基准点的变化而不同。本公开对数据基准点的选取不作限制。
在一种可能的实现方式中,所述基准地址可包括所述数据存储空间的起始地址。在描述符的数据基准点是数据存储空间的第一个数据块时,描述符的基准地址即为数据存储空间的起始地址。在描述符的数据基准点是数据存储空间中第一个数据块以外的其他数据时,描述符的基准地址即为该数据块在数据存储空间中的物理地址。
在一种可能的实现方式中,所述张量数据的形状参数包括以下至少一种:所述张量数据的数据存储空间在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。其中,数据描述位置是描述符所指示的张量数据中的点或区域的映射位置,例如,张量数据为3维数据时,描述符可使用三维空间坐标(x,y,z)来表示该张量数据的形状,该张量数据的数据描述位置可以是使用三维空间坐标(x,y,z)表示的、该张量数据映射在三维空间中的点或区域的位置。
应当理解,本领域技术人员可以根据实际情况选择表示张量数据的形状参数,本公开对此不作限制。
图2示出根据本公开一实施例的数据存储空间的示意图。如图2所示,数据存储空间21采用行优先的方式存储了一个二维数据,可通过(x,y)来表示(其中,X轴水平向右,Y轴垂直向下),X轴方向上的尺寸(每行的尺寸)为ori_x(图中未示出),Y轴方向上的尺寸(总行数)为ori_y(图中未示出),数据存储空间21的起始地址PA_start(基准地址)为第一个数据块22的物理地址。数据块23是数据存储空间21中的部分数据,其在X轴方向上的偏移量25表示为offset_x, 在Y轴方向上的偏移量24表示为offset_y,在X轴方向上的尺寸表示为size_x,在Y轴方向上的尺寸表示为size_y。
在一种可能的实现方式中,使用描述符来定义数据块23时,描述符的数据基准点可使用数据存储空间21的第一个数据块,描述符的基准地址为数据存储空间21的起始地址PA_start,然后可以结合数据存储空间21在X轴的尺寸ori_x、在Y轴上的尺寸ori_y,以及数据块23在Y轴方向的偏移量offset_y、X轴方向上的偏移量offset_x、X轴方向上的尺寸size_x以及Y轴方向上的尺寸size_y来确定数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(1)来表示描述符的内容:
Figure PCTCN2020082775-appb-000016
应当理解,虽然上述示例中,描述符描述的是二维空间,但本领域技术人员可以根据实际情况对描述符的内容表示的维度进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置,确定所述张量数据的描述符的内容。
举例来说,可以使用描述符的数据基准点在数据存储空间中的基准地址PA_base,以及对角位置的两个顶点相对于数据基准点的位置,确定出图2中数据块23的描述符的内容。首先,确定描述符的数据基准点以及其在数据存储空间中的基准地址PA_base,例如,可以在数据存储空间21中选取一个数据(例如,位置为(2,2)的数据)作为数据基准点,将该数据在数据存储空间中的物理地址作为基准地址PA_base;然后,确定数据块23的对角位置的至少两个顶点相对于数据基准点的位置,例如,使用左上至右下方向的对角位置顶点相对于数据基准点的位置,其中,左上角顶点的相对位置为(x_min,y_min),右下角顶点的相对位置为(x_max,y_max),然后可以根据基准地址PA_base、左上角顶点的相对位置(x_min,y_min)以及右下角顶点的相对位置(x_max,y_max)确定出数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(2)来表示描述符的内容:
Figure PCTCN2020082775-appb-000017
应当理解,虽然上述示例中使用左上角和右下角两个顶点来确定描述符的内容,但本领域技术人员可以根据实际需要对至少两个顶点的具体顶点进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址,以及所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系,确定所述张量数据的描述符的内容。其中,数据描述位置与数据地址之间的映射关系可以根据实际需要进行设定,例如,描述符所指示的张量数据为三维空间数据时,可是使用函数f(x,y,z)来定义数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,可以使用下述公式(3)来表示描述符的内容:
Figure PCTCN2020082775-appb-000018
应当理解,本领域技术人员可以根据实际情况对数据描述位置与数据地址之间的映射关系进行设定,本公开对此不作限制。
在采用公式(1)表示描述符的内容的情况下,对于张量数据中的任意一个数据点,设其数据描述位置为(x q,y q),那么,该数据点在数据存储空间中的数据地址PA2 (x,y)可以使用下述公式(4)来确定:
PA2 (x,y)=PA_start+(offset_y+y q-1)*ori_x+(offset_x+x q)  (4)
通过这种方式,处理器可以根据描述符的内容计算出描述符所指示的张量数据在数据存储空间中的数据地址,进而根据该地址执行对应的处理(例如数据运算、数据同步等),从而可降低数据存取的复杂度,提高处理器的处理效率。
图3c3示出根据本公开实施例的数据同步装置的框图。该数据同步装置应用于第一处理器,如图3c3所示,该数据同步装置包括:
同步指令生成模块51c,用于根据待同步的张量数据的描述符,生成描述符同步指令,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;
同步指令发送模块52c,用于向第二处理器发送所述描述符同步指令,所述描述符同步指令用于指示第二处理器根据所述描述符同步指令获取所述待同步的张量数据。
在一种可能的实现方式中,所述装置还包括:第一描述符确定模块,用于根据来自第二处理器的描述符同步请求指令,确定所述待同步的张量数据的描述符。
在一种可能的实现方式中,所述描述符同步请求指令包括描述符的标识,其中,所述第一描述符确定模块包括:
第一解析子模块,用于解析所述描述符同步请求指令,获得所述描述符的标识;
第一确定子模块,用于根据所述描述符的标识,确定所述待同步的张量数据的描述符。
在一种可能的实现方式中,所述描述符同步请求指令包括所述待同步的张量数据的数据特征,其中,所述第一描述符确定模块包括:
第二解析子模块,用于解析所述描述符同步请求指令,获得待同步的张量数据的数据特征;
第二确定子模块,用于根据待同步的张量数据的数据特征,确定所述待同步的张量数据的描述符。
在一种可能的实现方式中,所述描述符同步指令包括待同步的张量数据的描述符的内容,其中,所述同步指令生成模块包括:
第一生成子模块,用于在待同步的张量数据的存储地址处于共用存储空间中时,根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
在一种可能的实现方式中,所述同步指令生成模块包括:
第一存储子模块,用于将所述待同步的张量数据的描述符的内容存储到同步数据存储空间;
第二生成子模块,用于根据所述描述符的内容在所述同步数据存储空间中的地址,生成描述符同步指令,以指示所述第二处理器从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容。
在一种可能的实现方式中,所述同步指令生成模块包括:
第二存储子模块,用于在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;
描述符生成子模块,用于根据所述待同步的张量数据在共用存储空间中的地址,生成所述待同步的张量数据的描述符;
第三生成子模块,用于根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
在一种可能的实现方式中,所述同步指令生成模块包括:
第三存储子模块,用于在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;
描述符修改子模块,用于根据所述待同步的张量数据在共用存储空间中的地址,修改所述待同步的张量数据的描述符;
第四生成子模块,用于根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
图3c4示出根据本公开实施例的数据同步装置的框图。该数据同步装置应用于第二处理器,如图3c4所示,该数据同步装置包括:
第一解析模块61c,用于解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;
第一数据获取模块62c,用于根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,所述第一数据获取模块包括:
第一数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,所述第一数据获取模块包括:
第一内容获取子模块,用于根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;
第二数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
图3c5示出根据本公开实施例的数据同步装置的框图。该数据同步装置应用于第二处理器,如图3c5所示,该数据同步装置包括:
请求指令生成模块71c,用于当存在待同步的张量数据时,生成描述符同步请求指令,所述描述符同步请求指令用于指示第一处理器根据所述描述符同步请求指令发送待同步的张量数据的描述符,所述描述符用于指示待同步的张量数据的形状;
请求指令发送模块72c,用于向所述第一处理器发送所述描述符同步请求指令。
在一种可能的实现方式中,所述描述符同步请求指令包括描述符的标识和/或所述待同步的张量数据的数据特征。
在一种可能的实现方式中,所述装置还包括:
第二解析模块,用于解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容;
第二数据获取模块,用于根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,所述第二数据获取模块包括:
第三数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
在一种可能的实现方式中,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,所述第二数据获取模块包括:
第二内容获取子模块,用于根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;
第四数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
在一种可能的实现方式中,还公开了一种人工智能芯片,其包括了上述数据同步装置。
在一种可能的实现方式中,还公开了一种板卡,其包括存储器件、接口装置和控制器件以及上述人工智能芯片;其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;所述控制器件,用于对所述人工智能芯片的状态进行监控。
A1、一种数据同步方法,所述方法应用于第一处理器,包括:根据待同步的张量数据的描述符,生成描述符同步指令,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;向第二处理器发送所述描述符同步指令,所述描述符同步指令用于指示第二处理器根据所述描述符同步指令获取所述待同步的张量数据。
A2、根据权利要求A1所述的方法,所述方法还包括:根据来自第二处理器的描述符同步请求指令,确定所述待同步的张量数据的描述符。
A3、根据权利要求A2所述的方法,所述描述符同步请求指令包括描述符的标识,其中,所述根据来自第二处理器的描述符同步请求指令,确定所述待同步的张量数据的描述符,包括:解析所述描述符同步请求指令,获得所述描述符的标识;根据所述描述符的标识,确定所述待同步的张量数据的描述符。
A4、根据权利要求A2所述的方法,所述描述符同步请求指令包括所述待同步的张量数据的数据特征,其中,所述根据来自第二处理器的描述符同步请求指令,确定所述待同步的张量数据的描述符,包括:解析所述描述符同步请求指令,获得待同步的张量数据的数据特征;根据待同步的张量数据的数据特征,确定所述待同步的张量数据的描述符。
A5、根据权利要求A1-A4中任意一项所述的方法,所述描述符同步指令包括待同步的张量数据的描述符的内容,其中,所述根据待同步的张量数据的描述符,生成描述符同步指令,包括:在待同步的张量数据的存储地址处于共用存储空间中时,根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述 待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
A6、根据权利要求A1-A4中任意一项所述的方法,所述根据待同步的张量数据的描述符,生成描述符同步指令,包括:将所述待同步的张量数据的描述符的内容存储到同步数据存储空间;根据所述描述符的内容在所述同步数据存储空间中的地址,生成描述符同步指令,以指示所述第二处理器从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容。
A7、根据权利要求A1-A4中任意一项所述的方法,所述根据待同步的张量数据的描述符,生成描述符同步指令,包括:在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;根据所述待同步的张量数据在共用存储空间中的地址,生成所述待同步的张量数据的描述符;根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
A8、根据权利要求A1-A4中任意一项所述的方法,所述根据待同步的张量数据的描述符,生成描述符同步指令,包括:在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;根据所述待同步的张量数据在共用存储空间中的地址,修改所述待同步的张量数据的描述符;根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
A9、一种数据同步方法,所述方法应用于第二处理器,包括:解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
A10、根据权利要求A9所述的方法,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,所述根据所述待同步的张量数据的描述符,获取所述待同步的张量数据,包括:根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A11、根据权利要求A9所述的方法,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,所述根据所述待同步的张量数据的描述符,获取所述待同步的张量数据,包括:根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A12、一种数据同步方法,所述方法应用于第二处理器,包括:当存在待同步的张量数据时,生成描述符同步请求指令,所述描述符同步请求指令用于指示第一处理器根据所述描述符同步请求指令发送待同步的张量数据的描述符,所述描述符用于指示待同步的张量数据的形状;向所述第一处理器发送所述描述符同步请求指令。
A13、根据权利要求A12所述的方法,所述描述符同步请求指令包括描述符的标识和/或所述待同步的张量数据的数据特征。
A14、根据权利要求A12或A13所述的方法,所述方法还包括:解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容;根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
A15、根据权利要求A14所述的方法,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,所述根据所述待同步的张量数据的描述符,获取所述待同步的张量数据,包括:根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A16、根据权利要求A14所述的方法,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,所述根据所述待同步的张量数据的描述符,获取所述待同步的张量数据,包括:根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A17、一种数据同步装置,所述装置应用于第一处理器,包括:同步指令生成模块,用于根据待同步的张量数据的描述符,生成描述符同步指令,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;同步指令发送模块,用于向第二处理器发送所述描述符同步指令,所述描述符同步指令用于指示第二处理器根据所述描述符同步指令获取所述待同步的张量数据。
A18、根据权利要求A17所述的装置,所述装置还包括:第一描述符确定模块,用于根据来自第二处理器的描述符 同步请求指令,确定所述待同步的张量数据的描述符。
A19、根据权利要求A18所述的装置,所述描述符同步请求指令包括描述符的标识,其中,所述第一描述符确定模块包括:第一解析子模块,用于解析所述描述符同步请求指令,获得所述描述符的标识;第一确定子模块,用于根据所述描述符的标识,确定所述待同步的张量数据的描述符。
A20、根据权利要求A18所述的装置,所述描述符同步请求指令包括所述待同步的张量数据的数据特征,其中,所述第一描述符确定模块包括:第二解析子模块,用于解析所述描述符同步请求指令,获得待同步的张量数据的数据特征;第二确定子模块,用于根据待同步的张量数据的数据特征,确定所述待同步的张量数据的描述符。
A21、根据权利要求A17-A20中任意一项所述的装置,所述描述符同步指令包括待同步的张量数据的描述符的内容,其中,所述同步指令生成模块包括:第一生成子模块,用于在待同步的张量数据的存储地址处于共用存储空间中时,根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
A22、根据权利要求A17-A20中任意一项所述的装置,所述同步指令生成模块包括:第一存储子模块,用于将所述待同步的张量数据的描述符的内容存储到同步数据存储空间;第二生成子模块,用于根据所述描述符的内容在所述同步数据存储空间中的地址,生成描述符同步指令,以指示所述第二处理器从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容。
A23、根据权利要求A17-A20中任意一项所述的装置,所述同步指令生成模块包括:第二存储子模块,用于在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;描述符生成子模块,用于根据所述待同步的张量数据在共用存储空间中的地址,生成所述待同步的张量数据的描述符;第三生成子模块,用于根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
A24、根据权利要求A17-A20中任意一项所述的装置,所述同步指令生成模块包括:第三存储子模块,用于在待同步的张量数据的存储地址处于非共用存储空间中时,将所述待同步的张量数据存储到共用存储空间;描述符修改子模块,用于根据所述待同步的张量数据在共用存储空间中的地址,修改所述待同步的张量数据的描述符;第四生成子模块,用于根据所述待同步的张量数据的描述符的内容,生成描述符同步指令,以指示所述第二处理器根据所述待同步的张量数据的描述符的内容,从所述共用存储空间获取所述待同步的张量数据。
A25、一种数据同步装置,所述装置应用于第二处理器,包括:第一解析模块,用于解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容,所述描述符用于指示待同步的张量数据的形状;第一数据获取模块,用于根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
A26、根据权利要求A25所述的装置,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,所述第一数据获取模块包括:第一数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A27、根据权利要求A25所述的装置,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,所述第一数据获取模块包括:
第一内容获取子模块,用于根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;第二数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A28、一种数据同步装置,所述装置应用于第二处理器,包括:请求指令生成模块,用于当存在待同步的张量数据时,生成描述符同步请求指令,所述描述符同步请求指令用于指示第一处理器根据所述描述符同步请求指令发送待同步的张量数据的描述符,所述描述符用于指示待同步的张量数据的形状;请求指令发送模块,用于向所述第一处理器发送所述描述符同步请求指令。
A29、根据权利要求A28所述的装置,所述描述符同步请求指令包括描述符的标识和/或所述待同步的张量数据的数据特征。
A30、根据权利要求A28或A29所述的装置,所述装置还包括:第二解析模块,用于解析来自第一处理器的描述符同步指令,得到待同步的张量数据的描述符,所述描述符同步指令包括所述描述符的标识和/或所述描述符的内容;第 二数据获取模块,用于根据所述待同步的张量数据的描述符,获取所述待同步的张量数据。
A31、根据权利要求A30所述的装置,所述描述符同步指令包括所述待同步的张量数据的描述符的内容,其中,所述第二数据获取模块包括:第三数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A32、根据权利要求A30所述的装置,所述描述符同步指令包括所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,其中,所述第二数据获取模块包括:
第二内容获取子模块,用于根据所述待同步的张量数据的描述符的内容在同步数据存储空间中的地址,从所述同步数据存储空间获取所述待同步的张量数据的描述符的内容;第四数据获取子模块,用于根据所述待同步的张量数据的描述符的内容,从共用存储空间获取所述待同步的张量数据。
A33、一种人工智能芯片,所述芯片包括如权利要求A17-A32中任意一项所述的数据同步装置。
A34、一种电子设备,所述电子设备包括如权利要求A33所述的人工智能芯片。
A35、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求A33所述的人工智能芯片;其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;所述控制器件,用于对所述人工智能芯片的状态进行监控。
A36、根据权利要求A35所述的板卡,所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;所述芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;所述接口装置为:标准PCIE接口。
随着人工智能技术的不断发展,需要处理的数据量和数据维度都在不断增大。在相关技术中,当多个操作针对相同的存储区域进行操作时,需要等待前一条操作完毕,后一条操作才能执行,降低了处理器的处理效率。
根据本公开的实施例,提供了一种处理器操作方法。图1d1示出根据本公开实施例的应用场景的示意图。其中,处理器100可以是通用处理器(例如中央处理器CPU、图形处理器GPU),也可以是专用处理器(例如人工智能处理器、科学计算处理器或数字信号处理器等),本公开对处理器的类型不作限制。存储设备200包括至少一个目标存储区域210,其中,目标存储区域210可以是描述符所指示的张量数据的存储区域。可以理解,处理器可以通过执行读操作或者执行写操作来实现对某个目标存储区域210的访问,处理器执行针对某个目标存储区域210的读操作,可以是指处理器通过描述符获取该目标存储区域210中的张量数据。而处理器执行针对某个目标存储区域210的写操作,可以是指处理器将描述符所指示的张量数据写入该目标存储区域210中。在相关技术中,由于处理器可以并行执行多个操作,为了避免冲突,当处理器并行执行的多个操作都是针对某个目标存储区域210的操作时,处理器将只执行该多个操作中的一个,同时阻塞其他操作,从而会导致处理器的效率降低。本公开提供的处理器操作方法将目标存储区域210进一步划分为多个细粒度区域211,当处理器并行执行的多个操作都是针对某个目标存储区域210的操作时,处理器可以判断该多个操作针对的细粒度区域211是否重叠,如果各个操作针对的细粒度区域211不重叠,就可并行执行该多个操作,因此,大大提高了处理器的效率。需要说明的是,存储设备200可以设置在处理器内部(例如片上缓存或寄存器等),也可以设置在处理器的外部且可以与处理器进行数据通信(例如片下存储器等)。本公开对存储设备的类型不做限定。本公开所涉及的操作,可以是处理器硬件支持的基本操作,也可以是将该基本操作进行解析后的微指令(例如请求信号等)。本公开对操作的具体类型不做限定。本公开处理器可以并行执行两个操作,也可以并行执行两个以上的操作,本公开对并行执行的操作的数量不做限定。
图1d2示出根据本公开实施例的处理器操作方法的流程图。所述处理器操作方法可应用于处理器。如图1d2所示,该处理器操作方法包括:
步骤S11d,在第一操作为针对描述符的操作时,获取所述描述符所指示的张量数据的目标存储区域。
第一操作可以是针对描述符的读操作或者写操作。本公开对第一操作的具体类型不作限制。描述符可用于指示张量的形状。其中,张量可以包含多种形式的数据组成方式,张量可以是不同维度的,比如标量可以看作是0维张量,向量可以看作1维张量,而矩阵可以是2维或2维以上的张量。张量的形状包括张量的维度、张量各个维度的尺寸等信息。举例而言,对于张量:
Figure PCTCN2020082775-appb-000019
该张量的形状可以被描述符描述为(2,4),也即通过两个参数表示该张量为二维张量,且该张量的第一维度(列)的尺寸为2、第二维度(行)的尺寸为4。需要说明的是,本公开对于描述符指示张量形状的方式并不做限定。
在一种可能的实现方式中,第一操作的操作数可以是一个或多个描述符。目标存储区域可以是第一操作的操作数中一个或多个描述符所指示的张量数据的存储区域,也可以是第一操作的操作数中任意一个描述符所指示的张量数据的存储空间。目标存储区域所在的整体存储区域可以是处理器的内部存储器(例如片上缓存或寄存器等),也可以是连接到处理器的外部存储器(例如片下存储器等)。
在一种可能的实现方式中,目标存储区域可包括至少一个细粒度区域。其中,细粒度区域的尺寸和/或数量的确定方式,可以包括根据硬件设计确定的方式、根据描述符所指示的张量数据的相关操作确定的方式、根据操作中相关参数进行定义的方式中的其中一种或任意组合。其中,根据硬件设计确定的方式,即在硬件设计时确定细粒度区域的尺寸,譬如确定目标存储区域的一行或多行为一个细粒度区域。根据描述符所指示的张量数据的相关操作确定的方式,包括根据描述符所指示的张量数据的处理需求、存储方式、或传输方式等进行确定的方式,例如描述符所指示的张量数据为一个二维矩阵数据,其规模为M*Q(M,Q均为正整数),表示存储所占字节数,即一行M字节,共有Q行,可以确定M字节为一个细粒度区域,该描述符所指示的张量数据所对应的目标存储区域包括Q个细粒度区域。根据操作中相关参数进行定义的方式,包括根据操作中携带的细粒度的尺寸和/或数量,将目标存储区域划分为多个细粒度区域。需要说明的是,多个细粒度区域的尺寸可以相同,也可以不同。例如,各细粒度区域的数据位数可以分别为64位、256位、512位等。可以根据需求确定各细粒度区域的尺寸和/或数量。本公开对此不做限定。
在一种可能的实现方式中,在第一操作为针对描述符的操作时,可通过第一操作所针对的描述符,来获取该描述符所指示的张量数据的目标存储区域,从而确定第一操作所针对的目标存储区域。
步骤S12d,判断是否存在正在进行的针对所述目标存储区域的第二操作。
其中,第二操作可以是读操作或写操作,本公开对第二操作的具体类型不作限制。第二操作可包括一个或多个操作数,第二操作的操作数可以是描述符、立即数、张量数据等各种数据,本公开对第二操作的操作数的具体数量和类型不作限制。
在一种可能的实现方式中,可通过根据该目标存储区域的占用状态来判断是否存在正在进行的针对目标存储区域的第二操作。例如,处理器可以通过查询占用状态列表来判断目标存储区域是否被占用,如被占用,则判断结果为存在正在进行的针对目标存储区域的第二操作。其中,该占用状态列表可以是预先设置并存储在存储器上,也可以是在处理器开始执行某个任务之前生成,并在该任务完成之后注销。当各存储区域的占用状态发生变化时,处理器更新该占用状态列表的内容以记录各存储区域的占用状态。
在一种可能的实现方式中,可以通过查询各操作的执行状态来判断是否存在正在进行的针对目标存储区域的第二操作。例如,可以记录各操作的操作数所对应的存储区域,并记录各操作的执行状态。若针对目标存储区域的操作的执行状态为未完成,则判断结果为存在正在进行的针对目标操作区域的第二操作。还可以通过判断操作数的占用状态,来确定操作数对应的目标存储区域是否被占用,从而确定是否存在正在进行的针对目标存储区域的第二操作。本公开对判断是否存在正在进行的针对目标存储区域的第二操作的判断依据不做限定。
在一种可能的实现方式中,第二操作可以是针对描述符的操作,第二操作所针对的描述符可以与第一操作所针对的描述符一致,则第二操作所针对的描述符的存储区域与目标存储区域一致,当第二操作未完成时,存在针对目标存储区域的第二操作;或第二操作所针对的描述符的存储区域与目标存储区域有重叠区域,当第二操作针对重叠区域进行操作时,则存在针对目标存储区域的第二操作。
在一种可能的实现方式中,在针对目标存储区域的第一操作执行前,可判断是否存在正在进行的针对目标存储区域的第二操作。
在一种可能的实现方式中,在第一操作针对目标存储区域的执行过程中,也可以判断是否存在正在进行的针对目标存储区域的第二操作。
步骤S13d,在存在所述第二操作时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否有重叠。
第一细粒度区域和第二细粒度区域可以为目标存储区域中多个细粒度区域中的任意细粒度区域。可以是将目标存 储区域所在的整体存储区域进行细粒度的划分,则针对整体存储区域的各操作所针对的细粒度区域的尺寸一致。
也可以是各操作将操作数所针对的存储区域按照各操作中携带的细粒度划分信息进行细粒度划分,则针对相同存储区域,不同的操作可以进行不同粒度的细粒度划分。第一细粒度区域可以是第一操作将目标存储区域划分为多个细粒度区域中的任意细粒度区域,第二细粒度区域可以是第二操作将其操作数所在的存储区域进行细粒度划分后得到的任意细粒度区域。第一细粒度区域与第二细粒度区域的尺寸可以不同。
例如,第一操作可以携带第一细粒度的尺寸(各细粒度区域的数据位数),并可以将该第一细粒度的尺寸设置为64位,而第二操作可以携带第二细粒度尺寸(例如各细粒度区域的数据位数),并可以将该第二细粒度的尺寸设置为256位。即在执行第一操作时,将每64位作为一个细粒度区域,而在执行第二操作时,每256位作为一个细粒度区域。又如,第一操作和第二操作所携带的细粒度尺寸(例如各细粒度区域的数据位数)均为512位。同样的,第一操作也可以携带第一细粒度的数量(例如设置为4个),而第二操作携带第二细粒度的数量(例如设置为8个)。即在执行第一操作时,将目标存储区域划分为4个细粒度区域,而在执行第二操作时,将目标存储区域划分为8个细粒度区域。可以理解,操作中还可以同时携带细粒度的尺寸、数量这两个参数。可以根据需求确定各细粒度区域的尺寸和/或数量,本公开对此不做限定。
可以理解的是,针对目标存储区域的操作,即为针对目标存储区域中各细粒度区域的操作。例如,目标存储区域A为第1行至第10行,每1行为一个细粒度区域,目标存储区域A包括10个细粒度区域。针对目标存储区域A的写操作可以看做针对此10个细粒度区域的写操作。其执行过程可以为,写第1个细粒度区域(第1行),第1个细粒度区域写完后写第2个细粒度区域(第2行),第2个细粒度区域写完后写第3个细粒度区域(第3行),以此类推,直至写完第10个细粒度区域(第10行),完成目标存储区域A的写操作。
当有针对目标存储区域的操作时,随着操作的执行,目标存储区域中的细粒度区域的状态,可以包括已被操作完成状态、正在进行操作状态和未被操作状态。操作当前所针对的细粒度区域的状态为正在进行操作状态。由此,当存在针对目标存储区域的操作时,可以认为是存在针对目标存储区域中的一个细粒度区域的操作,正在被操作的细粒度区域,即为操作当前所针对的细粒度区域。
在一种可能的实现方式中,第一操作当前所针对的目标存储区域中的第一细粒度区域,可以包括将要执行的第一操作所针对的目标存储区域中的细粒度区域,通常为第一个细粒度区域。也可以包括正在执行的第一操作当前所针对的目标存储区域中的细粒度区域,可以为任意一个细粒度区域。第二操作当前所针对的目标存储区域中的第二细粒度区域,可以为正在执行的第二操作当前所针对的目标存储区域中的细粒度区域,可以为任意一个细粒度区域。
在一种可能的实现方式中,可根据物理地址、指针位置、细粒度区域标识等,来判断第一操作当前所针对的目标存储区域中的第一细粒度区域与第二操作当前所针对的目标存储区域中的第二细粒度区域之间是否重叠。例如,可记录各操作当前的物理地址,根据第一操作当前的物理地址以及第二操作当前的物理地址,以及物理地址与细粒度区域之间的对应关系,分别确定第一操作当前所针对的目标存储区域中的第一细粒度区域以及第二操作当前所针对的目标存储区域中的第二细粒度区域,进而判断第一细粒度区域与第二细粒度区域是否重叠。物理地址可以包括细粒度区域的起始地址、终止地址、设定位置的地址或实时操作地址中的一种或任意组合。再例如,可为各操作设置指针,指针指向操作当前所针对的细粒度区域。根据第一操作的指针位置和第二操作的指针位置,分别确定第一操作当前所针对的目标存储区域中的第一细粒度区域以及第二操作当前所针对的目标存储区域中的第二细粒度区域,进而判断第一细粒度区域与第二细粒度区域是否重叠。再例如,还可以为各细粒度区域设置标识,通过记录操作当前所针对的细粒度区域的标识来判断第一细粒度区域与第二细粒度区域是否重叠。标识可以包括字母、数字或符号的任意组合。还可以通过其他方式判断第一细粒度区域与第二细粒度区域是否重叠,本公开对第一细粒度区域与第二细粒度区域之间是否重叠的判断依据不作限制。
步骤S14d,在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
在一种可能的实现方式中,如果第一操作当前所针对的目标存储区域中的第一细粒度区域与第二操作当前所针对的目标存储区域中的第二细粒度区域不重叠,则第一细粒度区域可以是第二操作已经操作完成的细粒度区域,也可以是第二操作不需要进行操作的细粒度区域,此时执行第一操作不会对第二操作的操作过程及操作结果产生影响,可以执行第一操作。
根据本实施例,能够在第一操作为针对描述符的操作时,获取描述符所指示的张量数据的目标存储区域,并在存在正在进行的针对目标存储区域的第二操作时,判断第一操作当前所针对的目标存储区域中的第一细粒度区域与第二 操作当前针对的目标存储区域中的第二细粒度区域之间是否有重叠,在两者无重叠时,执行第一操作。这样,第一操作和第二操作当前操作的细粒度区域无重叠即可执行,使得第一操作和第二操作可以同时对目标存储区域进行操作,提高了处理器的处理效率。
在一种可能的实现方式中,所述方法还可包括:在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
在一种可能的实现方式中,第一细粒度区域与第二细粒度区域有重叠,包括第一细粒度区域与第二细粒度区域完全重叠或部分重叠。第一细粒度区域与第二细粒度区域有重叠时,若执行第一操作,则第一操作针对重叠部分区域的操作,可以影响第二操作的执行导致第二操作的操作结果不准确,也可以影响第一操作的执行导致第一操作的操作结果不准确。此时,可阻塞第一操作,即暂停第一操作的执行,可以在第二操作对当前所针对的目标存储区域中的第二细粒度区域操作完成后,执行第一操作。即第一细粒度区域与第二细粒度区域不重叠时,执行第一操作。
在本实施例中,在第一细粒度区域与第二细粒度区域有重叠时,阻塞第一操作,能够避免由于各操作的细粒度区域的重叠而导致的操作错误、操作结果不准确,保证各操作的正确性。
图5a和图5b示出根据本公开实施例的处理器操作方法的应用场景的示意图。如图5a和图5b所示,整体存储区域20d中包括目标存储区域21d,其中,目标存储区域21d被划分为4个细粒度区域,依次为细粒度区域22d、细粒度区域23d、细粒度区域24d和细粒度区域25d。
如图5a所示,当前仅包括写操作,用写指针wp表示写操作当前所针对的目标存储区域21d中的细粒度区域。在写操作刚开始时,写指针wp指向细粒度区域22d,可首先判断是否存在正在进行的针对目标存储区域21d的第二操作,如果判断结果为不存在第二操作,则开始对细粒度区域22d进行写操作;当完成对细粒度区域22d的写操作后,写指针wp增加,即wp++,并指向下一个细粒度区域23d,进行同样的判断后,开始对细粒度区域23d进行写操作;当完成对细粒度区域23d的写操作后,写指针wp增加,指向下一个细粒度区域24d,进行同样的判断后,开始对细粒度区域24d进行写操作。
又如图5b所示,当前包括两个操作,读操作和写操作,其中读操作为第一操作,写操作为第二操作。并且使用写操作的写指针wp和读操作的读指针rp分别表示写操作和读操作当前所针对的细粒度区域。
在执行读操作(第一操作)时,判断是否存在正在进行的针对目标存储区域21d的第二操作。经判断,当前存在正在进行的针对目标存储区域21d的第二操作写操作,进一步判断读操作(第一操作)当前所针对的目标存储区域21d中的第一细粒度区域(图5b中的细粒度区域22d)与写操作(第二操作)当前所针对的目标存储区域21d中的第二细粒度区域(图5b中的细粒度区域24d)之间是否重叠,例如可根据细粒度区域的编号(22d和24d),或根据rp与wp之间的关系(rp=0,wp=2,rp<wp),确定出第一细粒度区域与第二细粒度区域之间不重叠,然后,可执行读操作(第一操作)。
当完成对细粒度区域22d的读操作后,rp增加,即rp++,并指向下一个细粒度区域23d,进行同样的判断后,第一操作开始对细粒度区域23d进行操作;当完成对细粒度区域23d的读操作后,rp增加并指向下一个细粒度区域24d。在该情况下,继续判断第一细粒度区域与第二细粒度区域之间是否重叠,如果细粒度区域编号相同或指针rp=wp,即可判断第一操作当前所针对的目标存储区域21d中的第一细粒度区域与第二操作当前所针对的目标存储区域21d中的第二细粒度区域重叠,则第一操作不可执行,阻塞第一操作。当第二操作完成对细粒度区域24d的操作后,wp增加,并指向下一个细粒度区域25d时,细粒度区域的编号不同(24d和25d)或者指针rp<wp,可执行第一操作。
在一种可能的实现方式中,所述第一操作和所述第二操作中可至少一个操作为写操作。即,当对操作数的操作为写后读(第二操作为写操作,第一操作为读操作)、读后写(第二操作为读操作,第一操作为写操作)或者写后写(第二操作和第一操作均为写操作)时,可采用本公开实施例中的方法。
例如,如果第一操作为针对描述符的读操作,第二操作为写操作,第一操作需要读取的描述符所指示的张量数据需要是第二操作写操作后的数据,第二操作所针对的目标存储区域中的第二细粒度区域的编号为8,则第一操作仅能够读取编号在8之前的细粒度区域的数据。也就是说,如果第一操作当前所针对的目标存储区域中的第一细粒度区域为编号1~7的细粒度区域中的任意一个,则可以执行第一操作。
在一种可能的实现方式中,如果第一操作和第二操作均为读操作,则第一操作和第二操作的细粒度区域之间的关系不会影响操作结果,可以采用本公开实施例中的方法,也可直接执行第一操作而不进行细粒度区域的判断。
在本实施例中,当第一操作和第二操作中的至少一个操作为写操作时,通过使用本公开实施例中的方法,通过将描述符所指示的张量数据的目标存储区域划分为一个或多个细粒度区域,并以细粒度区域为单位执行操作,可以使得 读后写、写后读、写后写等操作既能够正确的执行,得到准确的执行结果,又可以减少操作之间的等待时间,提高处理器的执行效率。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量可以是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
可以理解,确定所述细粒度区域的尺寸和/或数量可以是在操作生成前预先设定好的,也可以是每条操作生成时实时确定的。其中,在操作前预先设定好细粒度区域的尺寸和/或数量,可以包括根据预设长度的数据所在区域、预设维度的数据所在区域中的至少一种,确定细粒度区域的尺寸和/或数量。而设定长度的数据和预设维度的数据可以与各操作的操作数无关,也可以预先根据各操作的操作数综合确定,可以根据需求确定。而在每条操作生成时实时确定细粒度区域的尺寸和/或数量,可以包括根据各操作的操作数,确定设定长度的数据或设定维度的数据,即,可以根据各操作的操作数的不同,实时确定设定长度的数据所在区域、设定维数的数据所在区域中的至少一种,确定细粒度区域的尺寸和/或数量。
举例来说,可根据设定长度的数据所在区域的大小,确定细粒度区域的尺寸和/或数量。例如,可根据描述符所指示的张量数据中设定长度的数据所在目标存储区域的尺寸,来设定细粒度区域的尺寸,该区域可以为固定的位宽。例如,描述符所指示的张量数据B是20*10*5的三维数据,其在目标存储区域的存储方式为40*25(即每行40位数据,共25行),则可将设定长度设定为40位,将目标存储区域的每1行设为一个细粒度区域,描述符所指示的张量数据B的目标存储区域可划分为25个细粒度区域;也可将目标存储区域的每5行设为一个细粒度区域,描述符所指示的张量数据B的目标存储区域可划分为5个细粒度区域。本公开对此不作限制。
可以理解的是,根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种,可以在目标存储区域中确定细粒度区域的尺寸和/或数量,也可以在目标存储区域所在的整体存储区域中确定细粒度区域的尺寸和/或数量,以及在整体存储区域中的其他区域确定细粒度区域的尺寸和/或数量。上述示例仅给出其中一种情况,本公开不限定根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种,确定细粒度区域的尺寸和/或数量的适用划分范围。
在一种可能的实现方式中,还可根据设定维数的数据所在区域的大小,确定细粒度区域的尺寸和/或数量。例如,描述符所指示的张量数据C是20*10的二维数据,可根据设定维数为1维、长度为20的数据,将描述符所指示的张量数据C的目标存储区域划分为10个细粒度区域。
此外,还可同时根据描述符所指示的张量数据的目标存储区域中设定长度的数据所在区域的大小和设定维度的数据所在区域的大小,确定细粒度区域的尺寸和/或数量。例如,针对描述符所指示的张量数据C,可根据设定维数为2维、尺寸为4*2的数据来划分细粒度区域,从而将描述符所指示的张量数据C的目标存储区域划分为25个细粒度区域。
应当理解,本领域技术人员可根据实际情况设定划分细粒度区域的尺寸和/或数量,本公开对此不作限制。
在本实施例中,通过根据设定长度的数据所在区域的大小和/或设定维度的数据所在区域的大小,来确定所述细粒度区域的尺寸和/或数量,可针对数据特性来完成对细粒度区域的划分,能够提高细粒度区域划分的灵活性,从而提高多操作的执行的效率,也可以使得细粒度区域的划分结果能够更加符合不同操作数的特性,从而适应不同类型操作数的处理需求,进一步提高多操作的整体执行效率。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量可以是根据硬件计算能力、硬件带宽中的至少一种确定的。
其中,硬件计算能力可以是硬件在一个计算周期内并行处理的数据量,硬件带宽可以是数据传输能力,例如单位时间内传输的数据量。
举例来说,应用该处理器操作方法的处理器,其硬件计算能力为一个计算周期内并行处理100位数据,硬件带宽为单位时间内传输200位数据,对于大小为1000位的目标存储区域,可根据硬件计算能力将该目标存储区域划分为10个细粒度区域,其中,每个细粒度区域包括100位数据;也可根据硬件带宽将该目标存储区域划分为5个细粒度区域,其中,每个细粒度区域包括200位数据。
应该理解,硬件计算能力、硬件带宽可根据处理器硬件的不同而不同,本公开对硬件计算能力、硬件带宽不作限制。
可以理解的是,根据硬件计算能力、硬件带宽中的至少一种,可以在目标存储区域中确定细粒度区域的尺寸和/或数量,也可以在目标存储区域所在的整体存储区域中确定细粒度区域的尺寸和/或数量,以及在整体存储区域中的其 他区域确定细粒度区域的尺寸和/或数量。上述示例仅给出其中一种情况,本公开不限定根据硬件计算能力、硬件带宽中的至少一种,确定细粒度区域的尺寸和/或数量的适用划分范围。
通过这种方式,可根据处理器的处理能力(硬件计算能力和/或硬件带宽)来确定所述细粒度区域的尺寸和/或数量,使得细粒度区域的划分结果更加符合不同硬件使用环境的需求,使得根据细粒度区域执行的操作与处理器的处理能力趋于同步,能够尽可能地发挥硬件的执行效率,从而提高处理器的处理效率。
在一种可能的实现方式中,所述第一操作可以为第一处理指令中的操作,所述第二操作可以为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
其中,第一处理指令和第二处理指令可包括数据存取指令、运算指令、同步指令和通信指令等一种或多种,譬如该指令为读且运算指令。本公开对第一处理指令和第二处理指令的具体类型不作限制。
在一种可能的实现方式中,第一指令可以与第二指令有依赖关系,例如,第一指令需要使用第二指令的计算结果等依赖关系。第一指令也可以与第二指令没有依赖关系。当第一指令与第二指令有依赖关系时,通过本公开实施例中的方法,第一指令与第二指令可以并行执行。
在本实施例中,第一操作和第二操作可以是不同指令中的操作,利用本公开实施例中的方法,可以提高指令执行效率。
在一种可能的实现方式中,第一操作和第二操作也可以为同一处理指令中的两个操作,第二操作可以与第一操作无关,或者第二操作可以基于第一操作的结果。其中,该处理指令可以包括数据存取指令、运算指令、同步指令和通信指令等一种或多种,譬如该指令为“读和加”运算指令,则第一操作为读操作,第二操作为加法运算操作。本公开对该处理指令的具体类型不作限制。
在一种可能的实现方式中,所述方法还可包括:记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,
步骤S14d可包括:当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
在一种可能的实现方式中,位置信息可包括细粒度区域的标识信息。标识信息可以包括数字、字母符号的任意组合。本公开对此不做限定。
例如,位置信息可使用细粒度区域的编号信息来表示,可将目标存储区域划分为6个细粒度区域,其编号依次为0-5。在执行针对目标存储区域的第一操作和第二操作时,可分别记录第一操作当前操作的第一细粒度区域的第一位置信息(例如编号为2)和第二操作当前操作的第二细粒度区域的第二位置信息(例如编号为5);然后根据编号信息之间的关系(2<5),可知,第一位置信息与第二位置信息不一致;此时,可执行第一操作。
在一种可能的实现方式中,位置信息可包括细粒度区域的地址信息。地址信息可以包括细粒度区域的起始地址信息、终止地址信息、细粒度区域中预设位置的地址信息、地址偏移量信息中的至少一个。例如,细粒度区域的位置信息为ADDR1515-ADDR1531。
通过这种方式,可使用位置信息直接高效地判断第一细粒度区域与第二细粒度区域是否重叠,确定是否执行第一操作,可提高处理器的执行效率。
在一种可能的实现方式中,所述第一位置信息可包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息可包括第二操作已操作完成的细粒度区域的第二数量,
当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作,可包括:当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
举例来说,第一操作为第二操作之后的操作,其目标存储区域被划分为6个细粒度区域,其位置信息可使用已操作完成的细粒度区域的数量来表示。在执行针对目标存储区域的第一操作和第二操作时,可分别记录第一操作已操作完成的细粒度区域的第一数量(例如第一数量为3)和第二操作已操作完成的细粒度区域的第二数量(例如第二数量为5);然后根据第一操作与第二操作的执行顺序,以及第一数量与第二数量的关系,可知,第一操作为第二操作之后的操作,且第一数量3小于第二数量5,此时,可执行第一操作。
通过这种方式,可根据已操作完成的细粒度区域的数量来直观地判断第一细粒度区域与第二细粒度区域是否重叠,进而确定是否执行第一操作,可简化判断过程,提高处理器的执行效率。
在一种可能的实现方式中,所述目标存储区域可包括可操作区域和非可操作区域,步骤S13d可包括:在存在所述第二操作,且所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域位于所述可操作区域内时,判断所述 第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否有重叠。
在一种可能的实现方式中,目标存储区域中可包括一个或多个非可操作区域、也可包括连续或不连续的非可操作区域。
在一种可能的实现方式中,目标存储区域中可包括一个或多个可操作区域、也可包括连续或不连续的可操作区域。本公开对此不做限定。
在一种可能的实现方式中,在第一操作为针对描述符的操作时,可首先获取描述符所指示的张量数据的目标存储区域,然后判断是否存在正在进行的针对目标存储区域的第二操作;当存在第二操作时,判断第一操作所针对的目标存储区域中的第一细粒度区域是否位于可操作区域内;当存在第二操作,且第一操作所针对的目标存储区域中的第一细粒度区域位于可操作区域内时,然后再判断第一操作所针对的目标存储区域中的第一细粒度区域与第二操作所针对的目标存储区域中的第二细粒度区域之间是否有重叠;当第一细粒度区域与第二细粒度区域之间没有重叠时,执行第一操作。
在一种可能的实现方式中,所述非可操作区域可以包括禁止操作区域和非禁止操作区域。如果第一操作为针对描述符的写操作,当描述符所指示的张量数据中的部分数据不可修改时,可将该部分数据所在的存储区域设定为禁止操作区域,以避免误修改该部分数据;如果正在进行的第二操作为读取第一操作之前的数据的读操作(读后写),则可将第二操作所在的一个或多个细粒度区域设定为非禁止操作区域,当第二操作完成对非禁止操作区域的读取后,可将该非禁止操作区域变更为可操作区域。本公开对非可操作区域的分类及划分方式不作限制。
在本实施例中,可先判断第一操作的细粒度区域是否可操作,再判断不同操作的细粒度区域之间的关系,一方面提高了判断的效率,另一方面可以对指定数据进行保护以防止有误操作发生,也可以对指定的空间禁止读写,从而预留出该空间,用于执行其他操作,进一步提高了处理器在执行细粒度同步时的灵活性。
在一种可能的实现方式中,所述非可操作区域可以为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述方法还可包括:当所述第二操作所针对的所述目标存储区域中的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
也就是说,包括第二细粒度区域在内的多个细粒度区域的非可操作区域,可以不随第二操作所针对的目标存储区域中的第二细粒度区域的更新而更新,当第二操作所针对的目标存储区域中的第二细粒度区域移出非可操作区域后,更新非可操作区域的位置。例如,非可操作区域可以为包括所述第二细粒度区域在内的R个细粒度区域(R为大于1的整数),当前的非可操作区域包括第2至第2+R-1个细粒度区域。当第二操作在非可操作区域内执行完R个细粒度区域后,移出非可操作区域,则非可操作区域的位置随着第二操作所针对的细粒度区域的位置进行更新,更新后的非可操作区域包括第2+R个至2+R+R-1个细粒度区域。其中,R的大小可以根据需求任意确定。
图6a和图6b示出根据本公开实施例的处理器操作方法的应用场景的示意图。如图6a所示,目标存储区域30d包括8个细粒度区域,其中,可操作区域包括5个细粒度区域(细粒度区域31d、细粒度区域35d、细粒度区域36d、细粒度区域37d和细粒度区域38d),非可操作区域M0包括3个细粒度区域(细粒度区域32d、细粒度区域33d和细粒度区域34d)。其中,第二操作当前所针对的目标存储区域30d中的第二细粒度区域为细粒度区域32d。
当第二操作执行完对细粒度区域32d的操作后,第二操作当前所针对的目标存储区域30d中的第二细粒度区域为细粒度区域33d,此时,第二操作当前所针对的目标存储区域30d中的第二细粒度区域(细粒度区域33d)未移出非可操作区域,不更新非可操作区域的位置;当第二操作执行完对细粒度区域33d的操作后,第二操作当前所针对的目标存储区域30d中的第二细粒度区域为细粒度区域34d,此时,第二操作当前所针对的目标存储区域30d中的第二细粒度区域(细粒度区域34d)还未移出非可操作区域,不更新非可操作区域的位置;当第二操作执行完对细粒度区域34d的操作后,第二操作当前所针对的目标存储区域30中的第二细粒度区域为细粒度区域35d,此时,第二操作当前所针对的目标存储区域30d中的第二细粒度区域(细粒度区域35d)已移出非可操作区域,更新非可操作区域的位置到细粒度区域35d、36d和37d)。需要说明的是,本公开对非可操作区域的大小不做限定。
如图6b所示,更新非可操作区域的位置后,在目标存储区域30d中,可操作区域包括5个细粒度区域(细粒度区域31d、细粒度区域32d、细粒度区域33d、细粒度区域34d和细粒度区域38d),非可操作区域M0包括3个细粒度区域(细粒度区域35d、细粒度区域36d和细粒度区域37d)。
通过这种方式,不需要实时更新非可操作区域的位置,能够降低更新非可操作区域所产生的开销。
在一种可能的实现方式中,所述非可操作区域可以为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域位于所述非可操作区域内的设定位置,所述非可操作区域的位置随所述第二操作的操作位置更新。
也就是说,当非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域时,可以设定第二细粒度区域在非可操作区域中的位置(例如中间位置、最后位置等),非可操作区域的位置随第二操作的操作位置而更新。例如,非可操作区域可以为包括所述第二细粒度区域在内的R个细粒度区域,当前的非可操作区域包括第2至第2+R-1个细粒度区域,第二细粒度区域在非可操作区域内的设定位置为第S个(其中S≤R)。当第二操作执行完成对当前所针对的细粒度区域的操作后,第二操作开始执行针对下一个细粒度区域的操作,此时,非可操作区域的位置随第二操作的操作位置而更新,更新后的非可操作区域包括第2+1至第2+R个细粒度区域。其中,R的大小及S的取值可根据需求确定。本公开对非可操作区域包括的细粒度区域的数量、第二细粒度区域位于非可操作区域内的位置均不作限制。
图7a和图7b示出根据本公开实施例的处理器操作方法的应用场景的示意图。如图7a所示,目标存储区域40中包括8个细粒度区域,其中,可操作区域包括5个细粒度区域(细粒度区域41、细粒度区域45、细粒度区域46、细粒度区域47和细粒度区域48),非可操作区域M1包括3个细粒度区域(细粒度区域42、细粒度区域43和细粒度区域44)。其中,第二操作当前所针对的目标存储区域40中的第二细粒度区域设定为位于非可操作区域M1的第二个细粒度区域,即细粒度区域43。
当第二操作执行完对细粒度区域43的操作后,第二操作当前所针对的目标存储区域40中的第二细粒度区域为细粒度区域44,此时,非可操作区域的位置随第二操作的操作位置而更新,以使第二操作当前所针对的目标存储区域40中的第二细粒度区域位于非可操作区域M1的第二个细粒度区域。
如图7b所示,更新非可操作区域的位置后,在目标存储区域40中,可操作区域包括5个细粒度区域(细粒度区域41、细粒度区域42、细粒度区域46、细粒度区域47和细粒度区域48),非可操作区域M1包括3个细粒度区域(细粒度区域43、细粒度区域44和细粒度区域45)。
通过这种方式,能够实时更新非可操作区域的位置,提高细粒度处理的同步程度,从而进一步提高数据同步处理的效率。
在一种可能的实现方式中,所述目标存储区域可包括:循环缓冲存储区域。所述循环缓冲存储区域可用于循环存储数据。
图8示出根据本公开实施例的处理器操作方法的循环缓冲存储区域的示意图。如图8所示,目标存储区域50中包括循环缓冲存储区域51,其地址为start_addr~end_addr。
例如,第二操作为写操作,可将操作数写入循环缓冲存储区域51,其地址指针point从起始地址start_addr开始,依次向下存储数据,直到结束地址end_addr,即占满循环缓冲存储区域51的存储空间,此时,地址指针point跳回到start_addr,判断该地址是否被所需同步的第一操作使用完毕,如果使用完毕,则将数据存储到该地址,覆盖原有数据,之后地址指针point依次向下移动,直到end_addr,此时,可重新覆盖数据,循环上述过程。
在本实施例中,采用循环缓冲存储区域来存储数据,既可节省数据存储空间,也可提高存储空间利用率。
在一种可能的实现方式中,可将循环缓冲存储区域划分为多个细粒度区域。对于每个细粒度区域,可通过列表或标志位或其他方式来对细粒度区域中的数据是否可覆盖进行管理,例如,可设置覆盖标志位来表示细粒度区域中的数据是否可覆盖。
举例来说,第一操作为读操作,第二操作为写操作,即先写后读,可使用写指针wp和读指针rp分别表示第二操作和第一操作当前所针对的细粒度区域。在第二操作当前所针对的第二细粒度区域的覆盖标志位为可覆盖时,可执行第二操作,写入数据,数据写入完成后,将该第二细粒度区域的覆盖标志位设为不可覆盖,wp++,第二操作当前所针对的第二细粒度区域为下一个细粒度区域,如果wp>end_addr,则wp=start_addr;在第一操作当前所针对的第一细粒度区域与第二细粒度区域之间不重叠,且第一细粒度区域的覆盖标志位为不可覆盖时,可执行第一操作,读取数据,数据读取完成后,将该第一细粒度区域的覆盖标志位设为可覆盖,rp++,第一操作当前所针对的第一细粒度区域为下一个细粒度区域,如果rp>end_addr,则rp=start_addr;在第一细粒度区域与第二细粒度区域有重叠,即rp=wp时,则不可执行第一操作,需等待第二操作完成对当前所针对的第二细粒度区域的操作后,可执行第一操作。
在本实施例中,将循环缓冲存取区域划分为多个细粒度区域,使得多个操作可同时对循环缓冲存储区域进行操作,从而提高处理器的处理效率。
在一种可能的实现方式中,所述细粒度区域可包括状态标识,所述状态标识可包括针对所述细粒度区域的操作处 于已完成状态或未完成状态,
步骤S14d可包括:在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态标识是否为已完成状态;若是,则执行所述第一操作。
在一种可能的实现方式中,细粒度区域可包括状态标识,状态标识可包括操作细粒度区域的已完成状态或未完成状态。例如,状态标识可使用0和1来表示,其中,0表示操作细粒度区域的未完成状态,1表示操作细粒度区域的已完成状态,或者0表示操作细粒度区域的已完成状态,1表示操作细粒度区域的未完成状态。本公开对状态标识的表示方式不作限制。
在一种可能的实现方式中,第二操作可将目标存储区域中已操作完成的细粒度区域的状态标识设置为已完成状态,未操作或正在操作的细粒度区域的状态标识设置为未完成状态。也可将已操作完成的细粒度区域中的部分细粒度区域的状态标识设置为已完成状态,其他细粒度区域设置为未完成状态。例如,第二操作已操作完成5个细粒度区域,可将前3个细粒度区域的状态标识设置为已完成状态,其他细粒度区域设置为未完成状态。
在一种可能的实现方式中,在存在正在进行的针对目标存储区域的第二操作时,对于第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域,可在确定第一细粒度区域与第二细粒度区域之间不重叠后,判断第一细粒度区域的状态标识是否为已完成状态;如果第一细粒度区域的状态标识为已完成状态,可执行第一操作。
在本实施例中,细粒度区域包括状态标识,在第一细粒度区域与第二细粒度区域之间不重叠时,根据第一细粒度区域的状态标识,确定第一操作是否可执行,可在提高处理器的处理效率的同时,提高数据处理的正确性。
在一种可能的实现方式中,所述细粒度区域可包括状态标识,所述状态标识可包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
步骤S14d可包括:判断所述第一细粒度区域的状态标识是否为已完成状态;若是,则在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
也就是说,在存在正在进行的针对目标存储区域的第二操作时,对于第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域,可在确定第一细粒度区域的状态标识为已完成状态后,根据第一细粒度区域与第二细粒度区域之间重叠关系,确定第一操作是否可执行。在第一细粒度区域与第二细粒度区域之间不重叠时,可执行第一操作。
在本实施例中,细粒度区域包括状态标识,可在确定第一细粒度区域的状态标识为已完成状态后,根据第一细粒度区域与第二细粒度区域之间重叠关系,确定第一操作是否可执行,可在提高数据处理的正确性同时,提高处理器的处理效率。
在一种可能的实现方式中,所述第二操作为针对所述描述符的操作。
也就是说,第二操作的操作数与第一操作的操作数相同,即第二操作与第一操作为针对同一个描述符的操作,第二操作的操作数的存储区域与目标存储区域完全重叠。可将描述符所指示的张量数据的目标存储区域划分为多个细粒度区域后,根据本公开实施例中的方法,可以使得操作相同描述符的两个操作并行执行而不影响各操作的执行结果。
在一种可能的实现方式中,在第二操作的操作数与第一操作的操作数相同时,可根据操作的执行进程来分别确定第一细粒度区域与第二细粒度区域。
在一种可能的实现方式中,当在针对目标存储区域的第一操作执行前,判断是否存在正在进行的针对目标存储区域的第二操作时,第一操作当前所针对的目标存储区域中的第一细粒度区域,为第一操作将要执行的目标存储区域中的细粒度区域。例如,在针对目标存储区域的第一操作执行前,第一操作当前所针对的目标存储区域中的第一细粒度区域通常为目标存储区域的第一个细粒度区域。此时,针对第一细粒度区域的第一操作还未执行。而正在进行的第二操作当前所针对的目标存储区域中的第二细粒度区域,可以与第二操作的执行进程相关。若第二操作也刚开始执行,则第二细粒度区域也可为目标存储区域的第一个细粒度区域。此时,第一细粒度区域与第二细粒度区域重叠。若第二操作已经完成第一个细粒度区域的操作,当前所针对的目标存储区域中的第二细粒度区域为第P个细粒度区域(P为大于1的整数),则第一细粒度区域与第二细粒度区域不重叠。
在一种可能的实现方式中,当在第一操作针对目标存储区域的操作过程中,判断是否存在正在进行的针对目标存储区域的第二操作时,可根据第一操作的执行进程确定第一细粒度区域,根据第二操作的执行进程确定第二细粒度区域,进而判断第一细粒度区域与第二细粒度区域是否重叠。在第一细粒度区域与第二细粒度区域之间不重叠时,可执行第一操作。
在一种可能的实现方式中,若各操作执行过程的节拍一致,可只在针对目标存储区域的第一操作执行前,判断是否存在正在进行的针对目标存储区域的第二操作,并判断第一细粒度区域与第二细粒度区域是否重叠。其中,节拍一致是指在细粒度区域的尺寸相同的情况下,两个操作对于一个细粒度区域的操作时长相同。
在一种可能的实现方式中,若各操作执行过程的节拍不一致或不能确定是否一致,可在第一操作针对目标存储区域的操作过程中,每完成当前所针对的目标存储区域中的第一细粒度区域的操作后,再继续判断是否存在正在进行的针对目标操作区域的第二操作,以及继续判断第一细粒度区域与第二细粒度区域是否重叠,以确定第一操作是否可以继续执行。
在本实施例中,第二操作的操作数与第一操作的操作数相同时,可使用本公开实施例中的方法,实现针对同一个描述符的两个或多个操作的并行执行,或者根据各操作的执行进程来确定各操作当前所针对的细粒度区域,在第一细粒度区域与第二细粒度区域之间不重叠时,执行第一操作,使得针对同一个描述符的两个或多个操作可以并行执行而不影响各操作的执行效果,从而提高处理器的执行效率。
在一种可能的实现方式中,所述第二操作的操作数的存储区域与所述目标存储区域有重叠。
在一种可能的实现方式中,当第二操作的操作数的存储区域与目标存储区域有重叠,且第二操作正在进行针对重叠区域的操作时,可以将第二操作的操作数的存储区域与目标存储区域的分别划分为多个细粒度区域,或者将目标存储区域所在的整体存储区域划分为多个细粒度区域,然后根据本公开实施例中的方法,对重叠区域中的细粒度区域进行判断,确定是否可执行第一操作,从而可以使得操作数的存储区域有重叠区域的两个操作并行执行而不影响各操作的执行结果。
在一种可能的实现方式中,在第二操作为针对描述符的操作,且第二操作所针对的描述符与第一操作所针对的描述符不同时,可根据创建描述符时是否允许描述符所指示的张量数据的存储区域重叠,来确定第二操作的操作数的存储区域与目标存储区域是否可能重叠。
在一种可能的实现方式中,如果在创建描述符时,不允许描述符所指示的张量数据的存储区域重叠,则在第二操作所针对的描述符与第一操作所针对的描述符不同时,第二操作所针对的描述符所指示的张量数据的存储区域与目标存储区域不重叠,第一操作和第二操作的细粒度区域之间的不会重叠,不需要对针对不同描述符的操作进行细粒度区域的判断。
在一种可能的实现方式中,如果在创建描述符时,允许描述符所指示的张量数据的存储区域重叠,则在第二操作所针对的描述符与第一操作所针对的描述符不同时,第二操作所针对的描述符的存储区域可能与第一操作所针对的描述符所指示的目标存储区域存在重叠,此时,可以采用本公开实施例中的方法,使得针对具有重叠区域的不同描述符的两个操作可以并行执行。
在本实施例中,当第二操作的操作数的存储区域与目标存储区域有重叠时,可使用本公开实施例中的方法实现两个或多个操作的并行执行,从而提高处理器的执行效率。
在一种可能的实现方式中,所述方法还可包括:将目标存储区域所在的整体存储区域划分为多个细粒度区域。
在一种可能的实现方式中,目标存储区域可以为存储装置的整体存储区域中的部分存储区域或全部存储区域,所述整体存储区域包括预设的多个细粒度区域。
例如目标存储区域所在的整体存储区域为RAM1,RAM1可以包括预先设定m个细粒度区域(m为正整数)。目标存储区域在RAM1中可以占据RAM1中的n个细粒度区域(n为正整数,且n<=m)。需要说明的是,目标存储区域也可以包括某细粒度区域中的部分区域。在如上示例的RAM1中,假设每个细粒度区域为整体存储区域RAM1中的一行,每行为100比特。目标存储区域可以包括前面(n-1)个完整的细粒度区域,并且又包括最后一个细粒度区域的部分区域,例如为RAM1中第n行(第n个细粒度区域)中的前80个比特。
在一种可能的实现方式中,当将存储装置的整体存储区域划分为多个细粒度区域时,针对整体存储区域中任意目标存储区域的任意操作,且无论是第一操作所针对的描述符所指示的张量数据的目标存储区域,还是第二操作的操作数的存储区域与目标存储区域的重叠区域,都可以根据整体存储区域的细粒度划分结果,确定目标存储区域或重叠区域中的细粒度区域。任意操作的任意操作数在整体存储区域的中存储区域,具有相同尺寸的细粒度区域。
在一种可能的实现方式中,可以根据存储装置的硬件特性,确定整体存储区域的细粒度区域的尺寸和/或数量,即可以根据存储装置的硬件计算能力、硬件带宽中的至少一种,确定整体存储区域的细粒度区域的尺寸和/或数量。
在本实施例中,将目标存储区域所在的整体存储区域划分为多个细粒度区域,针对整体存储区域中任意目标存储 区域的任意操作,都可以按照相同的细粒度尺寸执行,不同操作按照本公开实施例中的方法并行时,可以更加方便地同步,提高操作并行度,进而提高处理器的处理效率。
在一种可能的实现方式中,所述方法还可包括:
根据第一操作中携带的第一细粒度划分信息,将所述目标存储区域划分为多个细粒度区域,及
根据第二操作中携带的第二细粒度划分信息,将所述第二操作的操作数的存储区域划分为多个细粒度区域。
在一种可能的实现方式中,可以在操作中携带细粒度划分信息,细粒度划分信息可以包括细粒度的尺寸和/或数量。不同的操作可以携带不同的细粒度划分信息。相同类型的操作可携带相同的细粒度划分信息。可在操作中操作数的设定位置携带细粒度划分信息,也可在操作码或操作数中携带是否进行细粒度划分的标识信息。本公开对细粒度划分信息中的内容及表现方式不做限定。
在一种可能的实现方式中,根据第一操作中携带的第一细粒度划分信息,将目标存储区域划分为多个第一细粒度区域。第一操作所针对的描述符指示的张量数据所在的整体存储区域中的其他区域,可不进行细粒度的划分,也可按照其他操作携带的细粒度划分信息,进行细粒度的划分。本公开对此不做限定。
可以理解的是,当第二操作的操作数与第一操作所针对的描述符所指示的张量数据一致时,第二操作的操作数的存储区域与目标存储区域完全重叠。而第一细粒度划分信息和第二细粒度划分信息可以一致,也可以不一致。当第一细粒度划分信息和第二细粒度划分信息不一致时,目标存储区域可同时按照第二细粒度划分信息进行细粒度划分。即,针对目标存储区域,不同的操作可以将其划分为不同尺寸或数量的多个细粒度区域。此时,可根据第一操作当前所针对的目标存储区域中的第一细粒度区域的物理地址,以及第二操作当前所述针对的目标存储区域中的第二细粒度区域之间的物理地址,判断第一细粒度区域与第二细粒度区域是否重叠,并根据判断结果进行第一操作和第二操作的并行执行。
在一种可能的实现方式中,各操作中携带的细粒度划分信息,可包括根据设定长度的操作数据所在区域、设定维数的操作数所在区域中的至少一种,确定出的所述细粒度区域的尺寸和/或数量,使得细粒度的划分结果更加符合操作中操作数的类型或属性。
在本实施例中,根据第一操作中携带的第一细粒度划分信息,将目标存储区域划分为多个细粒度区域,及根据第二操作中携带的第二细粒度划分信息,将第二操作的操作数的存储区域划分为多个细粒度区域。根据操作中携带的细粒度划分信息进行细粒度的划分,可使得细粒度的划分结果,更加符合各操作的处理需求,操作并行更加灵活。
应当理解,本领域技术人员可以根据实际情况将目标存储区域进行细粒度区域的划分与设置,本公开对此不作限制。
在一种可能的实现方式中,所述描述符可用于指示N维的张量数据的形状,N为大于或等于零的整数,其中,所述描述符的内容可包括表示张量数据的形状的至少一个形状参数。
在一种可能的实现方式中,描述符可用于指示N维的张量数据的形状。其中,N的取值可根据张量数据的维数(阶数)来确定,也可以根据张量数据的使用需要进行设定。例如,张量数据为三维数据,N的取值可以为3(根据维数来确定),描述符可用来指示该张量数据在三个维度方向上的形状(例如偏移量、尺寸等)。应当理解,本领域技术人员可以根据实际需要对N的取值进行设置,本公开对此不作限制。
在一种可能的实现方式中,描述符可包括标识和内容等,描述符的标识可用于对描述符进行区分,例如为编号;描述符的内容可包括表示张量数据的形状的至少一个形状参数(例如张量的各个维度方向上的尺寸等)。本公开对描述符的内容包括的具体形状参数不作限制。
在本实施例中,能够使用描述符来指示张量数据的形状,通过描述符指示的张量数据的形状,可确定多个张量数据之间的相互关系,从而提高处理器的存取效率。
在一种可能的实现方式中,描述符的标识和内容可存储在描述符存储空间中,该描述符存储空间可以为控制单元的内部存储器(例如寄存器、片上的SRAM或其他介质缓存等)中的存储空间。描述符所指示的张量数据的目标存储区域可以为所述控制单元的内部存储器(例如片上缓存)或与所述控制单元连接的外部存储器(片下存储器)中的存储空间。目标存储区域中的数据地址可以为实际的物理地址或虚拟地址。本公开对描述符存储空间及目标存储区域的位置以及数据地址的类型不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以位于同一块区域,例如,可使用片上缓存的一块连续区域存储描述符的相关内容,其地址为ADDR0-ADDR1023,其中,地址ADDR0-ADDR31可用 于存储描述符的标识,地址ADDR32-ADDR63可用于存储描述符的内容,地址ADDR64-ADDR1023可用于存储描述符指示的张量数据。其中,地址ADDR并不限于1位或一个字节,此处用来表示一个地址,是一个地址单位。本领域技术人员可以根据实际情况确定存储区域及其地址,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以分别存储在内部存储器的不同区域,例如,可以将寄存器作为描述符存储空间,在寄存器中存储描述符的标识及内容,将片上缓存作为整体存储区域,存储描述符所指示的张量数据。
在一种可能的实现方式中,还可以设置专门供描述符使用的专用寄存器(SR),描述符中的数据可以是立即数也可以从专用寄存器中获取。在使用寄存器存储描述符的标识和内容时,可以使用寄存器的编号来表示描述符的标识,例如,寄存器的编号为0时,其存储的描述符的标识为0。当寄存器中的描述符有效时,可根据描述符所指示的张量数据的大小在缓存空间中分配一块区域(例如在缓存中为每个张量数据创建一个张量缓存单元)用于存储该张量数据。应当理解,也可以采用预设的缓存空间存储该张量数据,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识及内容可存储在内部存储器,描述符所指示的张量数据可存储在外部存储器。例如,可以采用在片上存储描述符的标识及内容、在片下存储描述符所指示的张量数据的方式。
在一种可能的实现方式中,与描述符的标识对应的存储区域的数据地址可以是固定地址。例如,可以为张量数据划分单独的存储区域,每个张量数据在存储区域的起始地址与描述符的标识一一对应。在这种情况下,根据描述符的标识及对应关系,可直接确定描述符所指示的张量数据的目标存储区域。
在一种可能的实现方式中,所述描述符还可用于指示N维的张量数据的地址,其中,所述描述符的内容还可包括表示张量数据的地址的至少一个地址参数。
在一种可能的实现方式中,描述符还可用于指示N维的张量数据的地址,其中,地址可以是例如张量数据的起始地址、地址偏移量、寄存器地址或其他地址,本公开对地址类型不作限制。例如,地址可以为张量数据的起始地址,在与描述符的标识对应的存储区域的数据地址为固定地址时,描述符所指示的N维张量数据的起始地址为固定地址;在与描述符的标识对应的存储区域的数据地址为可变地址时,描述符所指示的N维张量数据的起始地址可根据其具体存储区域来确定。本公开对此不作限制。
在一种可能的实现方式中,描述符的内容还可包括表示张量数据的地址的至少一个地址参数。举例来说,张量数据为3维数据,可以使用描述符来指示该张量数据的地址,描述符的内容可包括表示该张量数据的地址的一个地址参数(例如张量数据的起始地址),也可以包括该张量数据的地址的多个地址参数(例如张量数据的起始地址+地址偏移量,或张量数据基于各维度的地址参数)。本领域技术人员可以根据实际需要对地址参数进行设置,本公开对此不作限制。
在本实施例中,能够使用描述符来指示张量数据的地址,通过描述符指示的张量数据的地址,可确定多个张量数据之间的相互关系,从而提高处理器的存取效率。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据所在的整体存储区域中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述张量数据所在的整体存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,张量数据的地址参数包括描述符的数据基准点在张量数据所在的整体存储区域中的基准地址。其中,基准地址可根据数据基准点的变化而不同。本公开对数据基准点的选取不作限制。
在一种可能的实现方式中,基准地址可包括整体存储区域的起始地址。在描述符的数据基准点是整体存储区域的第一个数据块时,描述符的基准地址即为整体存储区域的起始地址。在描述符的数据基准点是整体存储区域中第一个数据块以外的其他数据时,描述符的基准地址即为该数据块在整体存储区域中的物理地址。
在一种可能的实现方式中,张量数据的形状参数包括以下至少一种:张量数据所在的整体存储区域在N个维度方向的至少一个方向上的尺寸、张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、张量数据的存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。其中,数据描述位置是描述符所指示的张量数 据中的点或区域的映射位置,例如,张量数据为3维数据时,描述符可使用三维空间坐标(x,y,z)来表示该张量数据的形状,该张量数据的数据描述位置可以是使用三维空间坐标(x,y,z)表示的、该张量数据映射在三维空间中的点或区域的位置。
应当理解,本领域技术人员可以根据实际情况选择表示张量数据的形状参数,本公开对此不作限制。
如图2所示,整体存储区域21采用行优先的方式存储了一个二维数据,可通过(x,y)来表示(其中,X轴水平向右,Y轴垂直向下),X轴方向上的尺寸(每行的尺寸)为ori_x(图中未示出),Y轴方向上的尺寸(总行数)为ori_y(图中未示出),整体存储区域21的起始地址PA_start(基准地址)为第一个数据块22的物理地址。数据块23是整体存储区域21中的张量数据,其在X轴方向上的偏移量25表示为offset_x,在Y轴方向上的偏移量24表示为offset_y,在X轴方向上的尺寸表示为size_x,在Y轴方向上的尺寸表示为size_y。
在一种可能的实现方式中,使用描述符来定义数据块23时,描述符的数据基准点可使用整体存储区域21的第一个数据块,描述符的基准地址为整体存储区域21的起始地址PA_start,然后可以结合整体存储区域21在X轴的尺寸ori_x、在Y轴上的尺寸ori_y,以及数据块23在Y轴方向的偏移量offset_y、X轴方向上的偏移量offset_x、X轴方向上的尺寸size_x以及Y轴方向上的尺寸size_y来确定数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(1)来表示描述符的内容:
Figure PCTCN2020082775-appb-000020
应当理解,虽然上述示例中,描述符描述的是二维空间,但本领域技术人员可以根据实际情况对描述符的内容表示的维度进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据描述符的数据基准点在整体存储区域中的基准地址、处于N个维度方向的对角位置的至少两个顶点相对于数据基准点的位置,确定所述张量数据的描述符的内容。
举例来说,可以使用描述符的数据基准点在整体存储区域中的基准地址PA_base,以及对角位置的两个顶点相对于数据基准点的位置,确定出图2中数据块23的描述符的内容。首先,确定描述符的数据基准点以及其在整体存储区域中的基准地址PA_base,例如,可以在整体存储区域21中选取一个数据(例如,位置为(2,2)的数据)作为数据基准点,将该数据在整体存储区域21中的物理地址作为基准地址PA_base;然后,确定数据块23的对角位置的至少两个顶点相对于数据基准点的位置,例如,使用左上至右下方向的对角位置顶点相对于数据基准点的位置,其中,左上角顶点的相对位置为(x_min,y_min),右下角顶点的相对位置为(x_max,y_max),然后可以根据基准地址PA_base、左上角顶点的相对位置(x_min,y_min)以及右下角顶点的相对位置(x_max,y_max)确定出数据块73的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(2)来表示描述符的内容:
Figure PCTCN2020082775-appb-000021
应当理解,虽然上述示例中使用左上角和右下角两个顶点来确定描述符的内容,但本领域技术人员可以根据实际需要对至少两个顶点的具体顶点进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据描述符的数据基准点在整体存储区域中的基准地址,以及描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系,确定所述张量数据的描述符的内容。其中,数据描述位置与数据地址之间的映射关系可以根据实际需要进行设定,例如,描述符所指示的张量数据为三维空间数据时,可是使用函数f(x,y,z)来定义数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,可以使用下述公式(3)来表示描述符的内容:
Figure PCTCN2020082775-appb-000022
应当理解,本领域技术人员可以根据实际情况对数据描述位置与数据地址之间的映射关系进行设定,本公开对此不作限制。
在本实施例中,能够使用张量数据的基准地址和至少一个形状参考来确定描述符的内容,从而可根据各操作的处理需要使用不同的描述符。
在一种可能的实现方式中,根据描述符的标识,可确定描述符在描述符存储空间中的位置,进而从描述符存储空间中获取描述符的内容;然后可根据描述符的内容,确定描述符所指示的张量数据在整体存储区域中的数据地址。其中,数据地址的计算可通过硬件自动完成或通过软件方式实现。在描述符的内容的不同时,描述符所指示的张量数据在整体存储区域中的数据地址的计算方式也可以不同。
举例来说,在采用公式(1)表示描述符的内容的情况下,描述符所指示的张量数据在整体存储区域中的偏移量分别为offset_x和offset_y,尺寸为size_x*size_y,那么,该描述符所指示的张量数据在整体存储区域中的起始数据地址PA1 (x,y)可以使用下述公式(4)来确定:
PA1 (x,y)=PA_start+(offset_y-1)*ori_x+offset_x     (4)
对于描述符所指示的张量数据中的任意一个数据点,设其数据描述位置为(x q,y q),那么,该数据点在整体存储区域中的数据地址PA2 (x,y)可以使用下述公式(5)来确定:
PA2 (x,y)=PA_start+(offset_y+y q-1)*ori_x+(offset_x+x q)  (5)
应当理解,本领域技术人员可以根据实际情况确定数据地址的计算方法,本公开对此不作限制。
在本实施例中,能够根据描述符的标识,获取描述符的内容;并根据描述符的内容,可确定描述符所指示的张量数据在整体存储区域中的数据地址;根据数据地址,可确定描述符所指示的张量数据的目标存储区域。通过这种方式,可在数据存取过程中使用描述符,从而可降低数据存取的复杂度,提高处理器的处理效率。
需要说明的是,尽管以上述实施例作为示例介绍了处理器操作方法如上,但本领域技术人员能够理解,本公开应不限于此。事实上,用户完全可根据个人喜好和/或实际应用场景灵活设定各步骤,只要符合本公开的技术方案即可。
图3d示出根据本公开实施例的处理器操作装置的框图。如图3d所示,所述处理器操作装置包括:
区域确定模块81,用于在第一操作为针对描述符的操作时,获取所述描述符所指示的张量数据的目标存储区域;
操作判断模块82,用于判断是否存在正在进行的针对所述目标存储区域的第二操作;
重叠判断模块83,用于在存在所述第二操作时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否有重叠;
执行模块84,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
在一种可能的实现方式中,所述装置还包括:执行控制模块,用于在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
在一种可能的实现方式中,所述第一操作和所述第二操作中的至少一个操作为写操作。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量是根据硬件计算能力、硬件带宽中的至少一种确定的。
在一种可能的实现方式中,所述第一操作为第一处理指令中的操作,所述第二操作为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
在一种可能的实现方式中,所述装置还包括:位置记录模块,用于记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,
所述执行模块84,包括:第一执行子模块,用于当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
在一种可能的实现方式中,所述第一位置信息包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息包括第二操作已操作完成的细粒度区域的第二数量,
所述第一执行子模块,还用于:当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
在一种可能的实现方式中,所述目标存储区域包括可操作区域和非可操作区域,所述重叠判断模块83,包括:判断子模块,用于在存在所述第二操作,且所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域位于所述可操作区域内时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否重叠。
在一种可能的实现方式中,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述装置还包括:更新模块,用于当所述第 二操作所针对的所述目标存储区域中的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
在一种可能的实现方式中,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域位于所述非可操作区域内的设定位置,所述非可操作区域的位置随所述第二操作的操作位置更新。
在一种可能的实现方式中,所述目标存储区域包括:循环缓冲存储区域。
在一种可能的实现方式中,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,所述执行模块84,包括:
第一状态判断子模块,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态标识是否为已完成状态;
第二执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态时,执行所述第一操作。
在一种可能的实现方式中,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,所述执行模块84,包括:
第二状态判断子模块,用于判断所述第一细粒度区域的状态标识是否为已完成状态;
第三执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态,且所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
在一种可能的实现方式中,所述第二操作为针对所述描述符的操作。
在一种可能的实现方式中,所述第二操作的操作数的存储区域与所述目标存储区域有重叠。
在一种可能的实现方式中,所述装置还包括:第一设定模块,用于将目标存储区域所在的整体存储区域划分为多个细粒度区域。
在一种可能的实现方式中,所述装置还包括:
第二设定模块,用于根据第一操作中携带的第一细粒度划分信息,将所述目标存储区域划分为多个细粒度区域,及
第三设定模块,用于根据第二操作中携带的第二细粒度划分信息,将所述第二操作的操作数的存储区域划分为多个细粒度区域。
在一种可能的实现方式中,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
在一种可能的实现方式中,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据所在的整体存储区域中的基准地址;其中,所述张量数据的形状参数包括以下至少一种:所述张量数据所在的整体存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,还公开了一种人工智能芯片,其包括了上述处理器操作装置。
在一种可能的实现方式中,还公开了一种板卡,其包括存储器件、接口装置和控制器件以及上述人工智能芯片;其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;所述控制器件,用于对所述人工智能芯片的状态进行监控。
在一种可能的实现方式中,所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;所述芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;所述接口装置为:标准PCIE接口。
A1、一种处理器操作方法,所述方法包括:
在第一操作为针对描述符的操作时,获取所述描述符所指示的张量数据的目标存储区域;
判断是否存在正在进行的针对所述目标存储区域的第二操作;
在存在所述第二操作时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否有重叠;
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A2、根据权利要求A1所述的方法,所述方法还包括:
在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
A3、根据权利要求A1所述的方法,所述第一操作和所述第二操作中的至少一个操作为写操作。
A4、根据权利要求A1所述的方法,所述细粒度区域的尺寸和/或数量是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
A5、根据权利要求A1所述的方法,所述细粒度区域的尺寸和/或数量是根据硬件计算能力、硬件带宽中的至少一种确定的。
A6、根据权利要求A1所述的方法,所述第一操作为第一处理指令中的操作,所述第二操作为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
A7、根据权利要求A1-A6中任意一项所述的方法,所述方法还包括:
记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作,包括:
当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
A8、根据权利要求A7所述的方法,所述第一位置信息包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息包括第二操作已操作完成的细粒度区域的第二数量,
当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作,包括:
当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
A9、根据权利要求A1所述的方法,所述目标存储区域包括可操作区域和非可操作区域,在存在所述第二操作时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否重叠,包括:
在存在所述第二操作,且所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域位于所述可操作区域内时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否重叠。
A10、根据权利要求A9所述的方法,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述方法还包括:
当所述第二操作所针对的所述目标存储区域中的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
A11、根据权利要求A9所述的方法,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域位于所述非可操作区域内的设定位置,
所述非可操作区域的位置随所述第二操作的操作位置更新。
A12、根据权利要求A1所述的方法,所述目标存储区域包括:循环缓冲存储区域。
A13、根据权利要求A1所述的方法,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作,包括:
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态标识是否为已完成状态;
若是,则执行所述第一操作。
A14、根据权利要求A1所述的方法,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作,包括:
判断所述第一细粒度区域的状态标识是否为已完成状态;
若是,则在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A15、根据权利要求A1所述的方法,所述第二操作为针对所述描述符的操作。
A16、根据权利要求A1所述的方法,所述第二操作的操作数的存储区域与所述目标存储区域有重叠。
A17、根据权利要求A1-A16中任意一项所述的方法,所述方法还包括:
将目标存储区域所在的整体存储区域划分为多个细粒度区域。
A18、根据权利要求A1-A17中任意一项所述的方法,所述方法还包括:
根据第一操作中携带的第一细粒度划分信息,将所述目标存储区域划分为多个细粒度区域,及
根据第二操作中携带的第二细粒度划分信息,将所述第二操作的操作数的存储区域划分为多个细粒度区域。
A19、根据权利要求A1所述的方法,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A20、根据权利要求A19所述的方法,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A21、根据权利要求A20所述的方法,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据所在的整体存储区域中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述张量数据所在的整体存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A22、一种处理器操作装置,所述装置包括:
区域确定模块,用于在第一操作为针对描述符的操作时,获取所述描述符所指示的张量数据的目标存储区域;
操作判断模块,用于判断是否存在正在进行的针对所述目标存储区域的第二操作;
重叠判断模块,用于在存在所述第二操作时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前所针对的所述目标存储区域中的第二细粒度区域之间是否有重叠;
执行模块,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A23、根据权利要求A22所述的装置,所述装置还包括:
执行控制模块,用于在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
A24、根据权利要求A22所述的装置,所述第一操作和所述第二操作中的至少一个操作为写操作。
A25、根据权利要求A22所述的装置,所述细粒度区域的尺寸和/或数量是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
A26、根据权利要求A22所述的装置,所述细粒度区域的尺寸和/或数量是根据硬件计算能力、硬件带宽中的至少一种确定的。
A27、根据权利要求A22所述的方装置,所述第一操作为第一处理指令中的操作,所述第二操作为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
A28、根据权利要求A22-A27中任意一项所述的装置,所述装置还包括:
位置记录模块,用于记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,
所述执行模块,包括:
第一执行子模块,用于当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
A29、根据权利要求A28所述的装置,所述第一位置信息包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息包括第二操作已操作完成的细粒度区域的第二数量,
所述第一执行子模块,还用于:
当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
A30、根据权利要求A22所述的装置,所述目标存储区域包括可操作区域和非可操作区域,所述重叠判断模块,包括:
判断子模块,用于在存在所述第二操作,且所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域位于所述可操作区域内时,判断所述第一操作当前所针对的所述目标存储区域中的第一细粒度区域与所述第二操作当前 所针对的所述目标存储区域中的第二细粒度区域之间是否重叠。
A31、根据权利要求A30所述的装置,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述装置还包括:
更新模块,用于当所述第二操作所针对的所述目标存储区域中的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
A32、根据权利要求A30所述的装置,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域位于所述非可操作区域内的设定位置,
所述非可操作区域的位置随所述第二操作的操作位置更新。
A33、根据权利要求A22所述的装置,所述目标存储区域包括:循环缓冲存储区域。
A34、根据权利要求A22所述的装置,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
所述执行模块,包括:
第一状态判断子模块,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态标识是否为已完成状态;
第二执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态时,执行所述第一操作。
A35、根据权利要求A22所述的装置,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
所述执行模块,包括:
第二状态判断子模块,用于判断所述第一细粒度区域的状态标识是否为已完成状态;
第三执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态,且所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A36、根据权利要求A22所述的装置,所述第二操作为针对所述描述符的操作。
A37、根据权利要求A22所述的装置,所述第二操作的操作数的存储区域与所述目标存储区域有重叠。
A38、根据权利要求A22-A37中任意一项所述的装置,所述装置还包括:
第一设定模块,用于将目标存储区域所在的整体存储区域划分为多个细粒度区域。
A39、根据权利要求A22-A37中任意一项所述的装置,所述装置还包括:
第二设定模块,用于根据第一操作中携带的第一细粒度划分信息,将所述目标存储区域划分为多个细粒度区域,及
第三设定模块,用于根据第二操作中携带的第二细粒度划分信息,将所述第二操作的操作数的存储区域划分为多个细粒度区域。
A40、根据权利要求A22所述的装置,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A41、根据权利要求A40所述的装置,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A42、根据权利要求A41所述的装置,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据所在的整体存储区域中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述张量数据所在的整体存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A43、一种人工智能芯片,所述芯片包括如权利要求A22-A42中任意一项所述的处理器操作装置。
A44、一种电子设备,所述电子设备包括如权利要求A43所述的人工智能芯片。
A45、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求A43所述的人工智能芯片;
其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;
所述存储器件,用于存储数据;
所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;
所述控制器件,用于对所述人工智能芯片的状态进行监控。
A46、根据权利要求A45所述的板卡,所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;
所述芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;
所述接口装置为:标准PCIE接口。
随着人工智能算法的复杂度提高,需要处理的数据量和数据维度都在不断增大,通常需要多核和/或多芯片进行数据处理。在进行核间或芯片间的数据同步时,采用相关技术的同步方式的同步开销较大,处理效率较低。
根据本公开的实施例,提供了一种数据同步方法。图1e示出根据本公开实施例的数据同步方法的流程图。该数据同步方法可应用于处理器中,该处理器可包括通用处理器(例如中央处理器CPU、图形处理器GPU)和专用处理器(例如人工智能处理器、科学计算处理器或数字信号处理器等)。本公开对处理器的类型不作限制。
如图1e所示,该数据同步方法包括:
在步骤S11e中,在解码后的处理指令为描述符同步指令时,获取所述处理指令中的描述符的同步信息,所述描述符用于指示待同步的张量数据的形状;
在步骤S12e中,根据所述同步信息,执行所述处理指令。
举例来说,待同步的数据可包括N维的张量数据(N为大于或等于零的整数,例如N=1、2或3),其中,张量可以包含多种形式的数据组成方式,张量可以是不同维度的,比如标量可以看作是0维张量,向量可以看作1维张量,而矩阵可以是2维或2维以上的张量。张量的形状包括张量的维度、张量各个维度的尺寸等信息。例如对于张量:
Figure PCTCN2020082775-appb-000023
该张量的形状可以被描述符描述为(2,4),也即通过两个参数表示该张量为二维张量,且该张量的第一维度(列)的尺寸为2、第二维度(行)的尺寸为4。需要说明的是,本公开对于描述符指示张量形状的方式并不做限定。在存储器中存储张量数据时,根据其数据地址(或存储区域)无法确定张量数据的形状,进而也无法确定多个张量数据之间相互关系等相关信息,导致处理器对张量数据的存取效率较低,在进行数据同步时的复杂度也较大。
在该情况下,可设定描述符(张量描述符)来指示张量数据(N维的张量数据)的形状。其中,N的取值可根据张量数据的维数(阶数)来确定,也可以根据张量数据的使用需要进行设定。例如,在N的取值为3时,张量数据为三维的张量数据,描述符可用来指示该三维的张量数据在三个维度方向上的形状(例如偏移量、尺寸等)。应当理解,本领域技术人员可以根据实际需要对N的取值进行设置,本公开对此不作限制。
在一种可能的实现方式中,描述符可包括标识和内容等,描述符的标识可用于对描述符进行区分,例如为编号;描述符的内容可包括表示张量数据的形状的至少一个形状参数(例如张量的各个维度方向上的尺寸等),还可以包括表示张量数据的地址的至少一个地址参数(例如数据基准点的基准地址)。本公开对描述符的内容包括的具体参数不作限制。
通过采用描述符来指示张量数据的方式,能够表达张量数据的形状,进而也能够确定多个张量数据之间的相互关系等相关信息,提高对张量数据的存取效率,从而降低数据同步时的复杂度。
在数据处理过程中,可能需要对当前的处理器A1(例如人工智能芯片中的处理器核)中的张量数据进行数据同步,例如将另一个处理器A0中的一项运算的运算结果同步到处理器A1中做为另一项运算的输入数据。在该情况下,可以采用描述符同步指令实现数据同步。也即,当存在待同步的张量数据时,同步数据的发送方(例如另一个处理器A0)可以向处理器A1发送描述符同步指令,以指示当前的处理器A1进行数据同步。
在一种可能的实现方式中,在步骤S11e之前,所述方法还包括:
对接收到的处理指令进行解码,得到解码后的处理指令,
其中,所述解码后的处理指令包括操作码,所述操作码用于指示进行同步处理。
举例来说,当前的处理器A1在接收到处理指令时,可以对处理指令进行解码(解析),得到解码后的处理指令。该解码后的处理指令可至少包括操作码和操作数,操作码用于指示与所述处理指令对应的处理类型,操作数用于指示 待处理的数据。处理指令可包括数据存取指令、运算指令、描述符管理指令以及同步指令等。本公开对处理指令的具体类型及解码的具体方式不作限制。
在一种可能的实现方式中,如果解码后的处理指令的操作码指示进行描述符同步处理,则可确定该处理指令为描述符同步指令。在解码后的处理指令为描述符同步指令时,处理器可在步骤S11e中获取所述处理指令中的描述符的同步信息,以便对描述符所指示的待同步的张量数据进行同步。
在一种可能的实现方式中,描述符的同步信息可例如包括所述描述符的标识及所述描述符的内容中的至少一种。如果处理器中已注册有指示该待同步的张量数据的描述符且无需修改,则描述符同步指令中的同步信息可仅包括描述符的标识(例如在描述符的标识为TR1时,将描述符同步指令表示为Send TR1),处理器可根据处理指令中的该描述符的标识(TR1)实现张量数据的同步;如果处理器中未注册指示该待同步的张量数据的描述符,则描述符同步指令中的同步信息可包括描述符的内容,处理器可根据处理指令中的描述符内容实现张量数据的同步;如果处理器中已注册有指示该待同步的张量数据的描述符但需要修改描述符的内容,则描述符同步指令中的同步信息可同时包括描述符的标识和内容两者,处理器可根据处理指令中的描述符标识和内容实现张量数据的同步。本公开对描述符的同步信息所包括的具体内容不作限制。
在一种可能的实现方式中,在得到描述符同步指令的同步信息后,处理器可在步骤S12e中根据同步信息执行该处理指令(描述符同步指令),以实现张量数据的同步。
根据本公开实施例的数据同步方法,通过设定指示张量数据的形状的描述符,能够在解码后的处理指令为描述符同步指令时,获取处理指令中的描述符的同步信息,并根据描述符的同步信息执行指令以实现张量数据的同步,从而减少同步开销,提高数据同步的效率。
在一种可能的实现方式中,步骤S12e可包括:
在所述描述符所指示的张量数据的存储区域处于共用存储空间中时,根据所述同步信息,从所述共用存储空间中获取所述张量数据。
举例来说,多个处理器(多个核)可以具有共用存储空间,例如处理器A0和处理器A1均可以访问的片下存储器。该共用存储空间可以是多个核(多个处理器)均能够存取数据的存储空间,也可以是部分核(部分处理器)能够存取数据的存储空间,可以预先设定有核间的共用存储空间,本公开对共用存储空间的设定方式不作限制。
在一种可能的实现方式中,如果待同步的张量数据的存储地址处于共用存储空间中,则由于当前的处理器A1也可从共用存储空间存取数据,处理器A1根据描述符的内容就可以直接读取张量数据以实现同步。
在一种可能的实现方式中,如果描述符同步请求指令中的同步信息仅包括描述符的标识,例如描述符的标识为TR1,描述符同步请求指令表示为Send TR1,则处理器A1可内部查找该描述符的标识对应的描述符内容,进而根据描述符内容从共用存储空间中获取待同步的张量数据,从而实现整个同步过程。
在一种可能的实现方式中,如果该描述符同步指令中的同步信息包括描述符的标识和内容,则处理器A1可查找该描述符的标识对应的描述符,并根据描述符同步指令中的描述符内容,更新原来的描述符内容;进而根据更新后的描述符内容从共用存储空间中获取待同步的张量数据,从而实现张量数据的同步。
在一种可能的实现方式中,如果该描述符同步指令中的同步信息仅包括描述符的内容,则处理器A1可根据描述符的内容,注册指示该待同步的张量数据的描述符,并根据描述符的内容从共用存储空间中获取待同步的张量数据,从而实现张量数据的同步。
通过这种方式,能够根据描述符同步指令中的描述符的同步信息,获取描述符所指示的待同步的张量数据,实现张量数据的同步,从而避免不必要的数据传输,减少张量数据存取次数,提高同步的处理效率。
在一种可能的实现方式中,多个处理器(多个核)可以具有同步数据存储空间,专门用于存储同步数据。该同步数据存储空间可以是上述的共用存储空间,也可以是共用存储空间的一部分,还可以是与共用存储空间不同的存储空间,本公开对此不作限制。
在一种可能的实现方式中,同步数据存储空间可是多个核(多个处理器)均能够存取同步数据的存储空间,也可以是部分核(部分处理器)能够存取同步数据的存储空间,本公开对此不作限制。
在一种可能的实现方式中,如果该描述符同步指令中的同步信息包括待同步的张量数据的描述符的内容在同步数据存储空间中的地址,则处理器A1可根据该地址,从同步数据存储空间获取待同步的张量数据的描述符的内容,根据描述符的内容注册描述符并确定待同步的张量数据的数据地址,进而获取所述待同步的张量数据,从而实现整个同步 过程。
通过这种方式,可以进一步减少同步时处理器间的数据传输,提高同步的处理效率。
在一种可能的实现方式中,描述符的标识和内容可存储在描述符存储空间中,该描述符存储空间可以为处理器的内部存储器(例如寄存器、片上的SRAM或其他介质缓存等)中的存储空间。描述符所指示的张量数据的数据存储空间可为处理器的内部存储器(例如片上缓存)或与处理器连接的外部存储器(片下存储器)中的存储空间。数据存储空间中的数据地址可以为实际的物理地址或虚拟地址。本公开对描述符存储空间及数据存储空间的位置以及数据地址的类型不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以位于同一块区域,例如,可使用片上缓存的一块连续区域存储描述符的相关内容,其地址为ADDR0-ADDR1023,其中,地址ADDR0-ADDR31可用于存储描述符的标识,地址ADDR32-ADDR63可用于存储描述符的内容,地址ADDR64-ADDR1023可用于存储描述符指示的张量数据。其中,地址ADDR并不限于1位或一个字节,此处用来表示一个地址,是一个地址单位。本领域技术人员可以根据实际情况确定存储区域及其地址,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以分开存储在内部存储器的不同区域,例如,可以将寄存器作为描述符存储空间,在寄存器中存储描述符的标识及内容,将片上缓存作为数据存储空间,存储描述符所指示的张量数据。
在一种可能的实现方式中,还可以设置专门供描述符使用的专用寄存器(SR),描述符中的数据可以是立即数也可以从专用寄存器中获取。在使用寄存器存储描述符的标识和内容时,可以使用寄存器的编号来表示描述符的标识,例如,寄存器的编号为0时,其存储的描述符的标识为0。当寄存器中的描述符有效时,可根据描述符所指示的张量数据的大小在缓存空间中分配一块区域(例如在缓存中为每个张量数据创建一个张量缓存单元)用于存储该张量数据。应当理解,也可以采用预设的缓存空间存储该张量数据,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识及内容可存储在内部存储器,描述符所指示的张量数据可存储在外部存储器。例如,可以采用在片上存储描述符的标识及内容、在片下存储描述符所指示的张量数据的方式。
在一种可能的实现方式中,与描述符对应的数据存储空间的数据地址可以是固定地址。例如,可以为张量数据划分单独的数据存储空间,每个张量数据在数据存储空间的起始地址与描述符的标识一一对应。在这种情况下,处理器根据描述符的内容即可确定张量数据的数据地址。
在一种可能的实现方式中,在与描述符对应的数据存储空间的数据地址为可变地址时,所述描述符还可用于指示N维的张量数据的地址,其中,所述描述符的内容还可包括表示张量数据的地址的至少一个地址参数。例如,张量数据为3维数据,在描述符指向该张量数据的地址时,描述符的内容可包括表示该张量数据的地址的一个地址参数,例如张量数据的起始地址,也可以包括该张量数据的地址的多个地址参数,例如张量数据的起始地址+地址偏移量,或张量数据基于各维度的地址参数。本领域技术人员可以根据实际需要对地址参数进行设置,本公开对此不作限制。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址。其中,基准地址可根据数据基准点的变化而不同。本公开对数据基准点的选取不作限制。
在一种可能的实现方式中,所述基准地址可包括所述数据存储空间的起始地址。在描述符的数据基准点是数据存储空间的第一个数据块时,描述符的基准地址即为数据存储空间的起始地址。在描述符的数据基准点是数据存储空间中第一个数据块以外的其他数据时,描述符的基准地址即为该数据块在数据存储空间中的物理地址。
在一种可能的实现方式中,所述张量数据的形状参数包括以下至少一种:所述张量数据的数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。其中,数据描述位置是描述符所指示的张量数据中的点或区域的映射位置,例如,张量数据为3维数据时,描述符可使用三维空间坐标(x,y,z)来表示该张量数据的形状,该张量数据的数据描述位置可以是使用三维空间坐标(x,y,z)表示的、该张量数据映射在三维空间中的点或区域的位置。
应当理解,本领域技术人员可以根据实际情况选择表示张量数据的形状参数,本公开对此不作限制。
图2示出根据本公开一实施例的数据存储空间的示意图。如图2所示,数据存储空间21采用行优先的方式存储了一个二维数据,可通过(x,y)来表示(其中,X轴水平向右,Y轴垂直向下),X轴方向上的尺寸(每行的尺寸)为ori_x (图中未示出),Y轴方向上的尺寸(总行数)为ori_y(图中未示出),数据存储空间21的起始地址PA_start(基准地址)为第一个数据块22的物理地址。数据块23是数据存储空间21中的部分数据,其在X轴方向上的偏移量25表示为offset_x,在Y轴方向上的偏移量24表示为offset_y,在X轴方向上的尺寸表示为size_x,在Y轴方向上的尺寸表示为size_y。
在一种可能的实现方式中,使用描述符来定义数据块23时,描述符的数据基准点可使用数据存储空间21的第一个数据块,描述符的基准地址为数据存储空间21的起始地址PA_start,然后可以结合数据存储空间21在X轴的尺寸ori_x、在Y轴上的尺寸ori_y,以及数据块23在Y轴方向的偏移量offset_y、X轴方向上的偏移量offset_x、X轴方向上的尺寸size_x以及Y轴方向上的尺寸size_y来确定数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(1)来表示描述符的内容:
Figure PCTCN2020082775-appb-000024
应当理解,虽然上述示例中,描述符描述的是二维空间,但本领域技术人员可以根据实际情况对描述符的内容表示的维度进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置,确定所述张量数据的描述符的内容。
举例来说,可以使用描述符的数据基准点在数据存储空间中的基准地址PA_base,以及对角位置的两个顶点相对于数据基准点的位置,确定出图2中数据块23的描述符的内容。首先,确定描述符的数据基准点以及其在数据存储空间中的基准地址PA_base,例如,可以在数据存储空间21中选取一个数据(例如,位置为(2,2)的数据)作为数据基准点,将该数据在数据存储空间中的物理地址作为基准地址PA_base;然后,确定数据块23的对角位置的至少两个顶点相对于数据基准点的位置,例如,使用左上至右下方向的对角位置顶点相对于数据基准点的位置,其中,左上角顶点的相对位置为(x_min,y_min),右下角顶点的相对位置为(x_max,y_max),然后可以根据基准地址PA_base、左上角顶点的相对位置(x_min,y_min)以及右下角顶点的相对位置(x_max,y_max)确定出数据块23的描述符的内容。
在一种可能的实现方式中,可以使用下述公式(2)来表示描述符的内容:
Figure PCTCN2020082775-appb-000025
应当理解,虽然上述示例中使用左上角和右下角两个顶点来确定描述符的内容,但本领域技术人员可以根据实际需要对至少两个顶点的具体顶点进行设置,本公开对此不作限制。
在一种可能的实现方式中,可根据所述描述符的数据基准点在所述数据存储空间中的基准地址,以及所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系,确定所述张量数据的描述符的内容。其中,数据描述位置与数据地址之间的映射关系可以根据实际需要进行设定,例如,描述符所指示的张量数据为三维空间数据时,可是使用函数f(x,y,z)来定义数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,可以使用下述公式(3)来表示描述符的内容:
Figure PCTCN2020082775-appb-000026
应当理解,本领域技术人员可以根据实际情况对数据描述位置与数据地址之间的映射关系进行设定,本公开对此不作限制。
在采用公式(1)表示描述符的内容的情况下,对于张量数据中的任意一个数据点,设其数据描述位置为(x q,y q),那么,该数据点在数据存储空间中的数据地址PA2 (x,y)可以使用下述公式(4)来确定:
PA2 (x,y)=PA_start+(offset_y+y q-1)*ori_x+(offset_x+x q)  (4)
通过这种方式,处理器可以根据描述符的内容计算出描述符所指示的张量数据在数据存储空间中的数据地址,进而根据该地址执行对应的处理(例如数据运算、数据同步等),从而可降低数据存取的复杂度,提高处理器的处理效率。
图3e示出根据本公开实施例的数据同步装置的框图。该数据同步装置可应用于处理器,如图3e所示,该数据同步装置包括:
同步信息获取模块31e,用于在解码后的处理指令为描述符同步指令时,获取所述处理指令中的描述符的同步信息, 所述描述符用于指示待同步的张量数据的形状;
指令执行模块32e,用于根据所述同步信息,执行所述处理指令。
在一种可能的实现方式中,所述同步信息包括以下至少一种:所述描述符的标识及所述描述符的内容。
在一种可能的实现方式中,所述指令执行模块包括:数据获取子模块,用于在所述描述符所指示的张量数据的存储区域处于共用存储空间中时,根据所述同步信息,从所述共用存储空间中获取所述张量数据。
在一种可能的实现方式中,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
在一种可能的实现方式中,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址。
在一种可能的实现方式中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,所述装置还包括:解码模块,用于对接收到的处理指令进行解码,得到解码后的处理指令,其中,所述解码后的处理指令包括操作码,所述操作码用于指示进行同步处理。
在一种可能的实现方式中,还公开了一种人工智能芯片,其包括了上述数据同步装置。
在一种可能的实现方式中,还公开了一种板卡,其包括存储器件、接口装置和控制器件以及上述人工智能芯片;其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;所述控制器件,用于对所述人工智能芯片的状态进行监控。
A1、一种数据同步方法,所述方法包括:
在解码后的处理指令为描述符同步指令时,获取所述处理指令中的描述符的同步信息,所述描述符用于指示待同步的张量数据的形状;
根据所述同步信息,执行所述处理指令。
A2、根据权利要求A1所述的方法,所述同步信息包括以下至少一种:所述描述符的标识及所述描述符的内容。
A3、根据权利要求A1或A2所述的方法,根据所述同步信息,执行所述处理指令,包括:
在所述描述符所指示的张量数据的存储区域处于共用存储空间中时,根据所述同步信息,从所述共用存储空间中获取所述张量数据。
A4、根据权利要求A1-A3中任意一项所述的方法,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A5、根据权利要求A4所述的方法,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A6、根据权利要求A5所述的方法,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址。
A7、根据权利要求A6所述的方法,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A8、根据权利要求A1-A7中任意一项所述的方法,所述方法还包括:
对接收到的处理指令进行解码,得到解码后的处理指令,
其中,所述解码后的处理指令包括操作码,所述操作码用于指示进行同步处理。
A9、一种数据同步装置,所述装置包括:
同步信息获取模块,用于在解码后的处理指令为描述符同步指令时,获取所述处理指令中的描述符的同步信息,所述描述符用于指示待同步的张量数据的形状;
指令执行模块,用于根据所述同步信息,执行所述处理指令。
A10、根据权利要求A9所述的装置,所述同步信息包括以下至少一种:所述描述符的标识及所述描述符的内容。
A11、根据权利要求A9或A10所述的装置,所述指令执行模块包括:
数据获取子模块,用于在所述描述符所指示的张量数据的存储区域处于共用存储空间中时,根据所述同步信息,从所述共用存储空间中获取所述张量数据。
A12、根据权利要求A9-A11中任意一项所述的装置,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A13、根据权利要求A12所述的装置,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A14、根据权利要求A13所述的装置,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址。
A15、根据权利要求A14所述的装置,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A16、根据权利要求A9-A15中任意一项所述的装置,所述装置还包括:
解码模块,用于对接收到的处理指令进行解码,得到解码后的处理指令,
其中,所述解码后的处理指令包括操作码,所述操作码用于指示进行同步处理。
A17、一种人工智能芯片,所述芯片包括如权利要求A9-A16中任意一项所述的数据同步装置。
A18、一种电子设备,所述电子设备包括如权利要求A17所述的人工智能芯片。
A19、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求17所述的人工智能芯片;其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;所述控制器件,用于对所述人工智能芯片的状态进行监控。
A20、根据权利要求A19所述的板卡,
所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;
所述芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;所述接口装置为:标准PCIE接口。
随着人工智能技术的不断发展,需要处理的数据量和数据维度都在不断增大。在相关技术中,处理器通常通过获取指令的参数来确定数据地址,然后根据数据地址来判断指令之间的依赖关系,这种判断指令之间的依赖关系要先计算操作数的数据地址的方式,降低了处理器的处理效率。
根据本公开的实施例,提供了一种数据处理方法。图1f示出根据本公开实施例的数据处理方法的流程图。如图1f所示,该数据处理方法包括:
在步骤S11f中,在已解码的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,判断所述第一处理指令是否可执行,所述描述符用于指示张量的形状;
在步骤S12f中,在所述第一处理指令可执行时,根据所述描述符的标识,执行与所述第一处理指令对应的数据处理。
在一种可能的实现方式中,该数据处理方法可应用于处理器。处理器可包括通用处理器(例如中央处理器CPU、图形处理器GPU)和专用处理器(例如人工智能处理器、科学计算处理器或数字信号处理器等)。本公开对处理器的类型不作限制。
在一种可能的实现方式中,已解码的第一处理指令包括操作码以及一个或多个操作数,所述操作码用于指示与所述第一处理指令对应的处理类型。其中,第一处理指令可包括数据存取指令、运算指令、描述符管理指令以及同步通信指令等。本公开对第一处理指令的具体类型不作限制。
在一种可能的实现方式中,待处理的数据可包括N维的张量数据(N为大于或等于零的整数,例如N=1、2或3),其中,张量可以包含多种形式的数据组成方式,张量可以是不同维度的,比如标量可以看作是0维张量,向量可以看作1维张量,而矩阵可以是2维或2维以上的张量。张量的形状包括张量的维度、张量各个维度的尺寸等信息。举例而言,对于张量:
Figure PCTCN2020082775-appb-000027
该张量的形状可以被描述符描述为(2,4),也即通过两个参数表示该张量为二维张量,且该张量的第一维度(列)的尺寸为2、第二维度(行)的尺寸为4。需要说明的是,本申请对于描述符指示张量形状的方式并不做限定。在存储器中存储张量数据时,根据其数据地址(或存储区域)无法确定张量数据的形状,进而也无法确定多个张量数据之间相互关系等相关信息,导致处理器对张量数据的存取效率较低。
在一种可能的实现方式中,描述符可用于指示N维的张量数据的形状,N为大于或等于零的整数。其中,N的取值可根据张量数据的维数(阶数)来确定,也可以根据张量数据的使用需要进行设定。例如,在N的取值为3时,张量数据为三维数据,描述符可用来指示该张量数据在三个维度方向上的形状(例如偏移量、尺寸等)。应当理解,本领域技术人员可以根据实际需要对N的取值进行设置,本公开对此不作限制。
在一种可能的实现方式中,描述符可包括标识和内容等,描述符的标识可用于对描述符进行区分,例如为编号;描述符的内容可包括表示张量数据的形状的至少一个形状参数(例如张量的各个维度方向上的尺寸等),还可以包括表示张量数据的地址的至少一个地址参数(例如数据基准点的基准地址)。本公开对描述符的内容包括的具体参数不作限制。
在一种可能的实现方式中,描述符的标识和内容可存储在描述符存储空间中,该描述符存储空间可以为控制单元的内部存储器(例如寄存器、片上的SRAM或其他介质缓存等)中的存储空间。描述符所指示的张量数据的数据存储空间可为所述控制单元的内部存储器(例如片上缓存)或与所述控制单元连接的外部存储器(片下存储器)中的存储空间。数据存储空间中的数据地址可以为实际的物理地址或虚拟地址。本公开对描述符存储空间及数据存储空间的位置以及数据地址的类型不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以位于同一块区域,例如,可使用片上缓存的一块连续区域存储描述符的相关内容,其地址为ADDR0-ADDR1023,其中,地址ADDR0-ADDR31可用于存储描述符的标识,地址ADDR32-ADDR63可用于存储描述符的内容,地址ADDR64-ADDR1023可用于存储描述符指示的张量数据。其中,地址ADDR并不限于1位或一个字节,此处用来表示一个地址,是一个地址单位。本领域技术人员可以根据实际情况确定存储区域及其地址,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识、内容以及描述符所指示的张量数据可以分开存储在内部存储器的不同区域,例如,可以将寄存器作为描述符存储空间,在寄存器中存储描述符的标识及内容,将片上缓存作为数据存储空间,存储描述符所指示的张量数据。
在一种可能的实现方式中,还可以设置专门供描述符使用的专用寄存器(SR),描述符中的数据可以是立即数也可以从专用寄存器中获取。在使用寄存器存储描述符的标识和内容时,可以使用寄存器的编号来表示描述符的标识,例如,寄存器的编号为0时,其存储的描述符的标识为0。当寄存器中的描述符有效时,可根据描述符所指示的张量数据的大小在缓存空间中分配一块区域(例如在缓存中为每个张量数据创建一个张量缓存单元)用于存储该张量数据。应当理解,也可以采用预设的缓存空间存储该张量数据,本公开对此不作限制。
在一种可能的实现方式中,描述符的标识及内容可存储在内部存储器,描述符所指示的张量数据可存储在外部存储器。例如,可以采用在片上存储描述符的标识及内容、在片下存储描述符所指示的张量数据的方式。
在一种可能的实现方式中,与描述符对应的数据存储空间的数据地址可以是固定地址。例如,可以为张量数据划分单独的数据存储空间,每个张量数据在数据存储空间的起始地址与描述符的标识一一对应。在这种情况下,控制单元可根据描述符的内容,通过张量控制模块确定与操作数对应的数据的数据地址,然后执行第一处理指令。
在一种可能的实现方式中,在与描述符的标识对应的数据存储空间的数据地址为可变地址时,所述描述符还可用 于指示N维的张量数据的地址,其中,所述描述符的内容还可包括表示张量数据的地址的至少一个地址参数。例如,张量数据为3维数据,在描述符指示该张量数据的地址时,描述符的内容可包括表示该张量数据的地址的一个地址参数,例如张量数据的起始地址,也可以包括该张量数据的地址的多个地址参数,例如张量数据的起始地址+地址偏移量,或张量数据基于各维度的地址参数。本领域技术人员可以根据实际需要对地址参数进行设置,本公开对此不作限制。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述数据存储空间中的基准地址。其中,基准地址可根据数据基准点的变化而不同。本公开对数据基准点的选取不作限制。
在一种可能的实现方式中,所述基准地址可包括所述数据存储空间的起始地址。在描述符的数据基准点是数据存储空间的第一个数据块时,描述符的基准地址即为数据存储空间的起始地址。在描述符的数据基准点是数据存储空间中第一个数据块以外的其他数据时,描述符的基准地址即为该数据块在数据存储空间中的物理地址。
在一种可能的实现方式中,所述张量数据的形状参数包括以下至少一种:所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。其中,数据描述位置是描述符所指示的张量数据中的点或区域的映射位置,例如,张量数据为3维数据时,描述符可使用三维空间坐标(x,y,z)来表示该张量数据的形状,该张量数据的数据描述位置可以是使用三维空间坐标(x,y,z)表示的、该张量数据映射在三维空间中的点或区域的位置。
应当理解,本领域技术人员可以根据实际情况选择表示张量数据的形状参数,本公开对此不作限制。
在一种可能的实现方式中,可以在步骤S11f中,在已解码的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,判断所述第一处理指令是否可执行。其中,描述符的标识是否相同,可表示描述符所指示的张量数据是否相同。与数据的存储地址相比,描述符的标识更加简单,通过描述符的标识判断是否存在同样操作此描述符的前序指令的过程,比通过数据的存储地址判断是否存在前序指令的过程也要更加简单高效,其中前序指令可以为与第一处理指令具有依赖关系的处理指令。
在一种可能的实现方式中,可根据描述符的标识以及预设的执行条件来判断第一处理指令是否可执行。例如,在使用寄存器存储描述符的标识时,其中,每个寄存器保存一个描述符标识,访问同一寄存器的多个指令可按指令提交顺序执行,因此可判断指令队列中第一处理指令之前的、访问同一寄存器的指令是否均已完成;并在访问同一寄存器的指令执行完成后,确定第一处理指令可执行。预设的执行条件可以是,先注册所需描述符、描述符未使用完毕不可注销等。本公开对预设的执行条件不作限制。
在一种可能的实现方式中,步骤S11f可包括:根据所述描述符的标识,判断是否存在未处理完成的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;当不存在第二处理指令时,确定所述第一处理指令可执行。
也就是说,在第一处理指令的操作数包括描述符的标识时,可根据描述符的标识,确定出指令队列中是否存在在第一处理指令之前的、操作数中具有该描述符的标识的第二处理指令,将查找到的第二处理指令作为与第一处理指令具有依赖关系的处理指令。在第一处理指令的操作数中具有多个描述符的标识的情况下,可分别判断对应于每个描述符的依赖关系,也就是说,将操作数中具有多个描述符中的至少一个描述符的标识的前序指令作为具有依赖关系的第二处理指令。
当存在未处理完成的第二处理指令时,第一处理指令不可执行;当不存在第二处理指令时,第一处理指令可执行。
举例来说,在第一处理指令的操作数包括至少一个描述符的标识时,判断是否存在未执行完成的第二处理指令时,可对操作数包括的所有描述符的标识进行判断,在第一处理指令的操作数中存在至少一个描述符的标识与第二处理指令的操作数中的描述符的标识相同时,第一处理指令与第二处理指令具有依赖关系,在第二处理指令未执行完成时,第一处理指令不可执行。
例如,在第一处理指令为ADD;TR10;TR11;TR12,第二处理指令为ADD;TR10;TR11;TR12时,第一处理指令与第二操作指令的操作数中的描述符的标识完全相同,则第一处理指令与第二处理指令具有依赖关系。在第二处理指令未执行完成时,第一处理指令不可执行。
在第一处理指令为ADD;TR10;TR11;TR13,第二处理指令为ADD;TR10;TR11;TR12时,第一处理指令与第二操作指令的操作数中有两个描述符的标识(TR10和TR11)相同,则第一处理指令与第二处理指令具有依赖关系。 在第二处理指令未执行完成时,第一处理指令不可执行。
在第一处理指令为ADD;TR10;TR12;TR13,第二处理指令为ADD;TR10;TR14;TR15时,第一处理指令与第二操作指令的操作数中有一个描述符的标识(TR10)相同,则第一处理指令与第二处理指令具有依赖关系。在第二处理指令未执行完成时,第一处理指令不可执行。
在第一处理指令为ADD;TR10;TR11;TR12,第二处理指令为ADD;TR13;TR14;TR15时,第一处理指令与第二操作指令的操作数中描述符的标识完全不同,则第一处理指令与第二处理指令没有依赖关系。在第二处理指令未执行完成时,第一处理指令可执行。
在第一处理指令为SUM;TR10,第二处理指令为SUM;TR10时,第一处理指令与第二操作指令的操作数中描述符的标识完全相同,则第一处理指令与第二处理指令具有依赖关系。在第二处理指令未执行完成时,第一处理指令不可执行。
通过这种方式,可以根据描述符的标识来直接判断指令是否可执行,无需多次获取指令中所涉及的操作数的基地址和操作范围,计算得到指令中操作数的数据地址及操作范围,降低了处理器判断指令是否可执行的复杂度,简化了指令中操作数的数据地址的分析过程,提高了处理器的执行效率。
在一种可能的实现方式中,所述第一处理指令和所述第二处理指令中的至少一个包括针对所述描述符的写操作。
例如,第一处理指令为针对描述符TR2的读指令,第二处理指令也为针对描述符TR2的读指令,即第一处理指令和第二处理指令都不包括针对描述符TR2的写操作,则第一处理指令可执行。如果第二处理指令为针对TR2的写指令,则在第二处理指令未处理完成时,第一处理指令不可执行。
通过这种方式,一个描述符同时允许多个指令操作,可提高指令的并发执行效率,从而提高处理器的处理效率。
在一种可能的实现方式中,所述第一处理指令的操作数可包括至少一个描述符的标识,步骤S11f可包括:根据所述至少一个描述符的标识,分别确定各描述符的第一状态,所述第一状态包括已注册状态或未注册状态;在各描述符的第一状态均为已注册状态时,确定所述第一处理指令可执行。也就是说,操作数包括的所有描述符的状态均为已注册时,第一处理指令可执行。
例如,第一处理指令的操作数中包括两个描述符的标识TR3和TR4。根据描述符的标识TR3和TR4,可确定出TR3和TR4的状态(已注册或未注册),当TR3和TR4中至少一个的状态为未注册时,第一处理指令不可执行;此时,可调用描述符注册指令对TR3和/或TR4进行注册,注册成功后将TR3和/或TR4的状态变更为已注册。在描述符TR3和TR4的状态均为已注册时,第一处理指令可执行。
在一种可能的实现方式中,描述符的第一状态可有多种表示方式。例如,可在描述符中设置第一标志位来表示第一状态,例如,在寄存器中保存描述符的标识,寄存器的最高位用于作为第一标志位,从次高位开始存储描述符的相关信息。也可设置状态对应表,将描述符的第一状态写入状态对应表中。本领域技术人员可以根据实际需要设置第一状态的表示方式,本公开对此不作限制。
通过这种方式,可根据描述符的第一状态来判断指令是否可执行,降低了处理器判断指令是否可执行的复杂度。以注销操作为例,当该描述符即将被注销时,只需要将该状态改变,即可完成操作,无需对描述符相关存储区域进行清空,再有其他描述符使用这块空间时,对该区域直接覆盖即可。以运算操作为例,首先可直接判断该操作符的状态,当该操作符无效时,通过第一状态即可判断该指令不可执行,从而无需进行进一步判断,即可阻塞该指令。
在一种可能的实现方式中,所述第一处理指令的操作数可包括至少一个描述符的标识,步骤S11f可包括:根据所述至少一个描述符的标识,分别确定各描述符的第二状态,所述第二状态包括可操作状态或不可操作状态;在各描述符的第二状态均为可操作状态时,确定所述第一处理指令可执行。
举例来说,在第一处理指令的前序指令当前正在对描述符进行操作(例如写入或读取)的情况下,描述符的当前状态为不可操作状态。在该状态下,无法执行第一处理指令,可阻塞或缓存第一处理指令。反之,在当前没有对描述符进行操作的前序指令的情况下,可将描述符的当前状态设置为可操作状态。在该状态下,能够执行第一处理指令。
在一种可能的实现方式中,当对该描述符进行操作的前序指令为两条以上时,可操作状态用“0”表示,不可操作状态用“1”表示,当所有前序指令操作完毕后,第二状态的标志位置为“0”,否则为“1”;或,可操作状态用“0”表示,不可操作状态用“N”表示,N为操作该描述符的前序指令的数量,每一个前序指令操作完毕则N-1,直至标志位的值为0,该描述符的第二状态为可操作状态。本公开对状态的具体表示方式不作限制。
在一种可能的实现方式中,描述符的第二状态可包括可操作状态或不可操作状态,其中,第二状态可通过多种方 式表示。例如,可在描述符中设置第二标志位来表示第二状态,也可将描述符的第二状态写入状态对应表中。其中,状态对应表可存储在寄存器中,并可通过硬件方式来实现对状态对应表中第一状态和第二状态的判断。本领域技术人员可以根据实际需要设置第二状态的表示方式,本公开对此不作限制。
通过这种方式,可根据描述符的第二状态来判断指令是否可操作,降低了处理器判断指令是否可操作的复杂度。以运算操作为例,直接判断该指令涉及的描述符的第二状态是否为可操作状态,而无需对该指令所涉及的操作数据,获取操作数的基地址以及操作范围,从而获取运算的实际操作区域,再进行判断区域间是否有重叠,得到该指令是否为可操作状态的结论。
在一种可能的实现方式中,通过步骤S11f确定第一处理指令可执行时,可以在步骤S12f中,根据所述描述符的标识,执行与所述第一处理指令对应的数据处理。也就是说,第一处理指令可执行时,可根据描述符的标识,通过计算得到描述符所指示的张量数据的数据地址,然后从数据地址中读取张量数据并执行与第一处理指令对应的数据处理。
在一种可能的实现方式中,根据描述符的标识,可直接得到描述符所指示的张量数据的数据地址,例如,描述符的内容为张量数据的数据地址时,无需计算,可直接从描述符存储空间读取数据地址,并从数据地址中读取张量数据,执行与第一处理指令对应的数据处理。
在一种可能的实现方式中,步骤S12f可包括:根据所述描述符的标识,从描述符存储空间获取所述描述符的内容;根据所述描述符的内容,确定与所述操作数对应的数据在数据存储空间中的数据地址;根据所述数据地址,执行与所述第一处理指令对应的数据处理。
在本实施例中,在第一处理指令可执行时,可根据操作数中描述符的标识,从描述符存储空间获取所述描述符的内容。也就是说,根据描述符的标识,可确定描述符在描述符存储空间中的位置,进而从描述符存储空间中获取描述符的内容。从而,可以降低软件编程的复杂度,无需在软件侧了解硬件侧数据存储方式,对硬件实际存储地址进行计算;同时也可以降低指令的复杂度,无需将多次使用的参数(如:描述符中的内容)在每次使用时都写入指令中。
在获取描述符的内容后,可根据描述符的内容,确定与操作数对应的数据在数据存储空间中的数据地址。其中,数据地址的计算可通过硬件自动完成或通过软件方式实现。在描述符的内容的不同时,与操作数对应的数据在数据存储空间中的数据地址的计算方式也可以不同。本公开对数据地址的计算方式不作限制。
例如,在采用公式(1)表示描述符的内容的情况下,对于张量数据中的任意一个数据点,设其数据描述位置为(x q,y q),那么,该数据点在数据存储空间中的数据地址PA2 (x,y)可以使用下述公式(4)来确定:
PA2 (x,y)=PA_start+(offset_y+y q-1)*ori_x+(offset_x+x q)  (4)
在得到与操作数对应的数据在数据存储空间中的数据地址后,可根据数据地址,执行与第一处理指令对应的数据处理。
举例来说,对于第一处理指令为运算指令ADD;A;B,如果操作数A和B中分别包括描述符的标识TR5和TR6,则可根据TR5和TR6,分别从描述符存储空间获取描述符TR5和TR6的内容(例如形状参数和地址参数);然后根据描述符TR5和TR6的内容,分别计算数据A和B的数据地址,数据A在数据存储空间中的地址1为ADDR64-ADDR127,数据B在数据存储空间中的地址2为ADDR1023-ADDR1087。然后,从地址1和地址2中分别读取数据,执行加法(ADD)运算,得到运算结果(A+B)。
在一种可能的实现方式中,所述方法还可包括:在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一项;根据所述描述符的注册参数,判断所述第一处理指令是否可执行;在所述第一处理指令可执行时,执行所述第一处理指令。
在本实施例中,在第一处理指令为描述符注册指令时,可从第一处理指令中获取描述符的注册参数,其中,注册参数可包括描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一项;然后根据描述符的注册参数,判断第一处理指令是否可执行,即可根据描述符的注册参数,判断描述符是否可注册。例如,在描述符的标识被占用或描述符存储空间不足的情况下,描述符无法注册成功。应当理解,本领域技术人员可根据实际情况对注册参数的判断进行设置,本公开对此不作限制。
在一种可能的实现方式中,根据所述描述符的注册参数,判断所述第一处理指令是否可执行,可包括:在满足所述描述符的标识未被占用、存储所述描述符的内容的第一存储区域未被占用,以及存储所述描述符所指示的张量数据的第二存储区域未被占用中的至少一项时,确定所述第一处理指令可执行。也就说是,在注册参数满足描述符的标识 未被占用、第一存储区域未被占用或第二存储区域未被占用中的至少一项时,第一处理指令可执行。
在第一处理指令可执行时,执行所述第一处理指令(描述符注册指令)。例如,可首先确定描述符的内容在描述符存储空间的第一存储区域以及描述符所指示的张量数据的内容在数据存储区域的第二存储区域;然后,根据注册参数以及第二存储区域,确定描述符的内容,即建立描述符与第二存储区域之间的对应关系;然后,将描述符的内容存储到第一存储区域,完成描述符的注册。
在一种可能的实现方式中,所述方法还包括:在所述第一处理指令为描述符注销指令时,根据所述第一处理指令中描述符的标识,判断是否存在未完成处理的第四处理指令,所述第四处理指令为指令队列中的、操作数包括所述描述符的标识的处理指令;在不存在未完成处理的第四处理指令时,执行所述第一处理指令。
在本实施例中,在第一处理指令为描述符注销指令时,可根据描述符的标识判断在指令队列中是否有操作数包括描述符的标识的第四处理指令,当存在未完成处理的第四处理指令时,第一处理指令不可执行;当不存在未完成处理的第四处理指令时,执行第一处理指令即描述符注销指令,此时,可分别释放描述符在描述符存储空间的存储区域以及描述符所指示的数据在数据存储空间的存储区域。
举例来说,第一处理指令为描述符注销指令,注销的描述符的标识为TR7,可首先在指令队列中查找是否有操作数包括TR7的第四处理指令,例如,指令队列中有两个第四处理指令:针对TR7的运算指令和读指令;然后判断这两个第四处理指令(针对TR7的运算指令和读指令)是否执行完成;在这两个第四处理指令均未执行完成时,第一处理指令(描述符注销指令)不可执行;当两个第四处理指令均执行完成时,第一处理指令可执行。之后,执行第一处理指令(描述符注销指令),分别释放TR7在描述符存储空间的存储区域以及TR6指示的数据在数据存储空间的存储区域。
在一种可能的实现方式中,在第一处理指令为描述符注销指令时,可根据描述符的标识,确定描述符的第一状态是否为已注册。在描述符的第一状态为已注册时,第一处理指令(描述符注销指令)可执行。否则,第一处理指令(描述符注销指令)不可执行。即,操作数中的描述符为已注册状态时,描述符注销指令才可执行。
在一种可能的实现方式中,所述方法还可包括:在所述第一处理指令不可执行时,阻塞或缓存所述第一处理指令。也就是说,在第一处理指令不可执行时,可以阻塞第一处理指令,暂停第一处理指令及之后的其他指令的执行,直到第二处理指令执行完成后,再执行第一处理指令及之后的其他指令;也可以缓存第一处理指令,将第一处理指令存储到预设的缓存空间,而不影响其他指令的执行,在第二处理指令执行完成后,再执行缓存空间中的第一处理指令。本公开对第一处理指令不可执行时的处理方式不作限制。
根据本公开的实施例的数据处理方法,在已解码的处理指令的操作数中包括描述符的标识时,能够通过描述符的标识来判断指令是否可执行,并在指令可执行时,根据描述符的标识来执行与指令对应的数据处理,从而可降低处理器判断指令是否可执行的复杂度,提高处理器的处理效率。
需要说明的是,尽管以上述实施例作为示例介绍了数据处理方法如上,但本领域技术人员能够理解,本公开应不限于此。事实上,用户完全可根据个人喜好和/或实际应用场景灵活设定各步骤,只要符合本公开的技术方案即可。
图3f示出根据本公开实施例的数据处理装置的框图。如图3f所示,所述数据处理装置包括:
判断模块31f,用于在已解码的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,判断所述第一处理指令是否可执行,所述描述符用于指示张量的形状;
执行模块32f,用于在所述第一处理指令可执行时,根据所述描述符的标识,执行与所述第一处理指令对应的数据处理。
在一种可能的实现方式中,所述执行模块32f,包括:内容获取子模块,用于根据所述描述符的标识,从描述符存储空间获取所述描述符的内容;地址确定子模块,用于根据所述描述符的内容,确定与所述操作数对应的数据在数据存储空间中的数据地址;第一执行子模块,用于根据所述数据地址,执行与所述第一处理指令对应的数据处理。
在一种可能的实现方式中,所述判断模块31f,包括:指令判断子模块,用于根据所述描述符的标识,判断是否存在未处理完成的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;第一执行确定子模块,用于当不存在第二处理指令时,确定所述第一处理指令可执行。
在一种可能的实现方式中,所述第一处理指令和所述第二处理指令中的至少一个包括针对所述描述符的写操作。
在一种可能的实现方式中,所述第一处理指令的操作数包括至少一个描述符的标识,其中,所述判断模块31f,包括:第一状态确定子模块,用于根据所述至少一个描述符的标识,分别确定各描述符的第一状态,所述第一状态包括已注册状态或未注册状态;第二执行确定子模块,用于在各描述符的第一状态均为已注册状态时,确定所述第一处理 指令可执行。
在一种可能的实现方式中,所述第一处理指令的操作数包括至少一个描述符的标识,其中,所述判断模块31f,包括:第二状态确定子模块,用于根据所述至少一个描述符的标识,分别确定各描述符的第二状态,所述第二状态包括可操作状态或不可操作状态;第三执行确定子模块,用于在各描述符的第二状态均为可操作状态时,确定所述第一处理指令可执行。
在一种可能的实现方式中,所述装置还包括:注销判断模块,用于在所述第一处理指令为描述符注销指令时,根据所述第一处理指令中描述符的标识,判断是否存在未完成处理的第四处理指令,所述第四处理指令为指令队列中的、操作数包括所述描述符的标识的处理指令;注销执行模块,用于在不存在未完成处理的第四处理指令时,执行所述第一处理指令。
在一种可能的实现方式中,所述装置还包括:参数获取模块,用于在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一项;注册判断模块,用于根据所述描述符的注册参数,判断所述第一处理指令是否可执行;注册执行模块,用于在所述第一处理指令可执行时,执行所述第一处理指令。
在一种可能的实现方式中,所述注册判断模块,包括:条件判断子模块,用于在满足所述描述符的标识未被占用、存储所述描述符的内容的第一存储区域未被占用,以及存储所述描述符所指示的张量数据的第二存储区域未被占用中的至少一项时,确定所述第一处理指令可执行。
在一种可能的实现方式中,所述装置还包括:执行控制模块,用于在所述第一处理指令不可执行时,阻塞或缓存所述第一处理指令。
在一种可能的实现方式中,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
在一种可能的实现方式中,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
在一种可能的实现方式中,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;其中,所述张量数据的形状参数包括以下至少一种:所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
在一种可能的实现方式中,还公开了一种人工智能芯片,其包括了上述数据处理装置。
A1、一种数据处理方法,所述方法包括:
在已解码的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,判断所述第一处理指令是否可执行,所述描述符用于指示张量的形状;
在所述第一处理指令可执行时,根据所述描述符的标识,执行与所述第一处理指令对应的数据处理。
A2、根据权利要求A1所述的方法,根据所述描述符的标识,执行与所述第一处理指令对应的数据处理,包括:
根据所述描述符的标识,从描述符存储空间获取所述描述符的内容;
根据所述描述符的内容,确定与所述操作数对应的数据在数据存储空间中的数据地址;
根据所述数据地址,执行与所述第一处理指令对应的数据处理。
A3、根据权利要求A1所述的方法,根据所述描述符的标识,判断所述第一处理指令是否可执行,包括:
根据所述描述符的标识,判断是否存在未处理完成的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;
当不存在第二处理指令时,确定所述第一处理指令可执行。
A4、根据权利要求A3所述的方法,所述第一处理指令和所述第二处理指令中的至少一个包括针对所述描述符的写操作。
A5、根据权利要求A1所述的方法,所述第一处理指令的操作数包括至少一个描述符的标识,
其中,根据所述描述符的标识,判断所述第一处理指令是否可执行,包括:
根据所述至少一个描述符的标识,分别确定各描述符的第一状态,所述第一状态包括已注册状态或未注册状态;
在各描述符的第一状态均为已注册状态时,确定所述第一处理指令可执行。
A6、根据权利要求A1所述的方法,所述第一处理指令的操作数包括至少一个描述符的标识,
其中,根据所述描述符的标识,判断所述第一处理指令是否可执行,包括:
根据所述至少一个描述符的标识,分别确定各描述符的第二状态,所述第二状态包括可操作状态或不可操作状态;
在各描述符的第二状态均为可操作状态时,确定所述第一处理指令可执行。
A7、根据权利要求A1-A6中任意一项所述的方法,所述方法还包括:
在所述第一处理指令为描述符注销指令时,根据所述第一处理指令中描述符的标识,判断是否存在未完成处理的第四处理指令,所述第四处理指令为指令队列中的、操作数包括所述描述符的标识的处理指令;
在不存在未完成处理的第四处理指令时,执行所述第一处理指令。
A8、根据权利要求A1-A7中任意一项所述的方法,所述方法还包括:
在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一项;
根据所述描述符的注册参数,判断所述第一处理指令是否可执行;
在所述第一处理指令可执行时,执行所述第一处理指令。
A9、根据权利要求A8所述的方法,根据所述描述符的注册参数,判断所述第一处理指令是否可执行,包括:
在满足所述描述符的标识未被占用、存储所述描述符的内容的第一存储区域未被占用,以及存储所述描述符所指示的张量数据的第二存储区域未被占用中的至少一项时,确定所述第一处理指令可执行。
A10、根据权利要求A1-A9中任意一项所述的方法,所述方法还包括:
在所述第一处理指令不可执行时,阻塞或缓存所述第一处理指令。
A11、根据权利要求A1所述的方法,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A12、根据权利要求A11所述的方法,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A13、根据权利要求A12所述的方法,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A14、一种数据处理装置,所述装置包括:
判断模块,用于在已解码的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,判断所述第一处理指令是否可执行,所述描述符用于指示张量的形状;
执行模块,用于在所述第一处理指令可执行时,根据所述描述符的标识,执行与所述第一处理指令对应的数据处理。
A15、根据权利要求A14所述的装置,所述执行模块,包括:
内容获取子模块,用于根据所述描述符的标识,从描述符存储空间获取所述描述符的内容;
地址确定子模块,用于根据所述描述符的内容,确定与所述操作数对应的数据在数据存储空间中的数据地址;
第一执行子模块,用于根据所述数据地址,执行与所述第一处理指令对应的数据处理。
A16、根据权利要求A14所述的装置,所述判断模块,包括:
指令判断子模块,用于根据所述描述符的标识,判断是否存在未处理完成的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;
第一执行确定子模块,用于当不存在第二处理指令时,确定所述第一处理指令可执行。
A17、根据权利要求A16所述的装置,所述第一处理指令和所述第二处理指令中的至少一个包括针对所述描述符的写操作。
A18、根据权利要求A14所述的装置,所述第一处理指令的操作数包括至少一个描述符的标识,
其中,所述判断模块,包括:
第一状态确定子模块,用于根据所述至少一个描述符的标识,分别确定各描述符的第一状态,所述第一状态包括已注册状态或未注册状态;
第二执行确定子模块,用于在各描述符的第一状态均为已注册状态时,确定所述第一处理指令可执行。
A19、根据权利要求A14所述的装置,所述第一处理指令的操作数包括至少一个描述符的标识,
其中,所述判断模块,包括:
第二状态确定子模块,用于根据所述至少一个描述符的标识,分别确定各描述符的第二状态,所述第二状态包括可操作状态或不可操作状态;
第三执行确定子模块,用于在各描述符的第二状态均为可操作状态时,确定所述第一处理指令可执行。
A20、根据权利要求A14-A19中任意一项所述的装置,所述装置还包括:
注销判断模块,用于在所述第一处理指令为描述符注销指令时,根据所述第一处理指令中描述符的标识,判断是否存在未完成处理的第四处理指令,所述第四处理指令为指令队列中的、操作数包括所述描述符的标识的处理指令;
注销执行模块,用于在不存在未完成处理的第四处理指令时,执行所述第一处理指令。
A21、根据权利要求A14-A20中任意一项所述的装置,所述装置还包括:
参数获取模块,用于在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一项;
注册判断模块,用于根据所述描述符的注册参数,判断所述第一处理指令是否可执行;
注册执行模块,用于在所述第一处理指令可执行时,执行所述第一处理指令。
A22、根据权利要求A21所述的装置,所述注册判断模块,包括:
条件判断子模块,用于在满足所述描述符的标识未被占用、存储所述描述符的内容的第一存储区域未被占用,以及存储所述描述符所指示的张量数据的第二存储区域未被占用中的至少一项时,确定所述第一处理指令可执行。
A23、根据权利要求A14-A22中任意一项所述的装置,所述装置还包括:
执行控制模块,用于在所述第一处理指令不可执行时,阻塞或缓存所述第一处理指令。
A24、根据权利要求A14所述的装置,所述描述符用于指示N维的张量数据的形状,N为大于或等于零的整数,
其中,所述描述符的内容包括表示张量数据的形状的至少一个形状参数。
A25、根据权利要求A24所述的装置,所述描述符还用于指示N维的张量数据的地址,其中,所述描述符的内容还包括表示张量数据的地址的至少一个地址参数。
A26、根据权利要求A25所述的装置,所述张量数据的地址参数包括所述描述符的数据基准点在所述张量数据的数据存储空间中的基准地址;
其中,所述张量数据的形状参数包括以下至少一种:
所述数据存储空间在N个维度方向的至少一个方向上的尺寸、所述张量数据的存储区域在N个维度方向的至少一个方向上的尺寸、所述存储区域在N个维度方向的至少一个方向上的偏移量、处于N个维度方向的对角位置的至少两个顶点相对于所述数据基准点的位置、所述描述符所指示的张量数据的数据描述位置与数据地址之间的映射关系。
A27、一种人工智能芯片,所述芯片包括如权利要求A14-A26中任意一项所述的数据处理装置。
A28、一种电子设备,所述电子设备包括如权利要求A27所述的人工智能芯片。
A29、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求A27所述的人工智能芯片;
其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;
所述存储器件,用于存储数据;
所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;
所述控制器件,用于对所述人工智能芯片的状态进行监控。
A30、根据权利要求A29所述的板卡,所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;
所述芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;
所述接口装置为:标准PCIE接口。
随着人工智能技术的不断发展,需要处理的数据量和数据维度都在不断增大。在相关技术中,当多个操作针对相同的存储区域进行操作时,需要等待前一条操作完毕,后一条操作才能执行,降低了处理器的处理效率。
根据本公开的实施例,提供了一种处理器操作方法。
图1g示出根据本公开实施例的处理器操作方法的流程图。所述处理器操作方法可应用于处理器。
如图1g所示,该处理器操作方法包括:
步骤S11g,在第一操作为针对目标存储区域的操作时,判断是否存在正在进行的针对所述目标存储区域的第二操作,所述目标存储区域包括至少一个细粒度区域。
其中,第一操作可以是读操作或者写操作,类似的,第二操作也可以是读操作或者写操作。本公开对第一操作和第二操作的具体类型不作限制。一个操作可包括一个或多个操作数。目标存储区域可以是第一操作和第二操作的一个或多个操作数所对应的存储区域。目标存储区域所在的整体存储区域可以是处理器的内部存储器(例如片上缓存或寄存器等),也可以是连接到处理器的外部存储器(例如片下存储器等)。
在一种可能的实现方式中,第一操作和/或第二操作可以包括一个或多个操作数,目标存储区域可以是第一操作和第二操作中的任意操作数对应的存储区域。目标存储区域为第一操作中的至少一个操作数和第二操作中的至少一个操作数共同对应的存储区域。例如,对于第一操作中的第一操作数和第二操作中的第二操作数,第一操作数可以为第一操作中的任意操作数,第二操作数可以为第二操作中的任意操作数。当第一操作数和第二操作数为相同的操作数时,目标存储区域可以为第一操作数的存储区域或第二操作的存储区域。当第一操作数的存储区域和第二操作数的存储区域有重叠区域时,目标存储区域为重叠区域。
在一种可能的实现方式中,目标存储区域包括至少一个细粒度区域。其中,细粒度区域的尺寸和/或数量的确定方式,可以包括根据硬件设计确定的方式、根据目标操作数的相关操作确定的方式、根据操作中相关参数进行定义的方式中的其中一种或任意组合。其中,根据硬件设计确定的方式,即在硬件设计时确定细粒度区域的尺寸,譬如确定存储区域的一行或多行为一个细粒度区域。根据目标操作数的相关操作确定的方式,包括根据目标操作数的处理需求、存储方式、或传输方式等进行确定的方式,例如目标操作数为一个二维矩阵数据,其规模为M*N(M,N均为正整数),表示存储所占字节数,即一行M字节,共有N行,可以确定M字节为一个细粒度区域,该目标操作数所对应的目标存储区域包括N个细粒度区域。根据操作中相关参数进行定义的方式,包括根据操作中携带的细粒度的尺寸和/或数量,将目标存储区域划分为多个细粒度区域。当第一操作中的第一操作数和第二操作中的第二操作数共同对应此目标存储区域时,第一操作和第二操作可以根据目标存储区域中划分出的多个细粒度区域,采用本公开实施例中的方法。
需要说明的是,多个细粒度区域的尺寸可以相同,也可以不同。例如,第一操作可以携带第一细粒度的尺寸(各细粒度区域的数据位数),并可以将该第一细粒度的尺寸设置为64位,而第二操作可以携带第二细粒度尺寸(例如各细粒度区域的数据位数),并可以将该第二细粒度的尺寸设置为256位。即在执行第一操作时,将每64位作为一个细粒度区域,而在执行第二操作时,每256位作为一个细粒度区域。又如,第一操作和第二操作所携带的细粒度尺寸(例如各细粒度区域的数据位数)均为512位。同样的,第一操作也可以携带第一细粒度的数量(例如设置为4个),而第二操作携带第二细粒度的数量(例如设置为8个)。即在执行第一操作时,将目标存储区域划分为4个细粒度区域,而在执行第二操作时,将目标存储区域划分为8个细粒度区域。可以理解,操作中还可以同时携带细粒度的尺寸、数量这两个参数。可以根据需求确定各细粒度区域的尺寸和/或数量,本公开对此不做限定。
在一种可能的实现方式中,可通过根据该目标存储区域的占用状态来判断是否存在正在进行的针对目标存储区域的第二操作。例如,处理器可以通过查询占用状态列表来判断目标存储区域是否被占用,如被占用,则判断结果为存在正在进行的针对目标存储区域的第二操作。其中,该占用状态列表可以是预先设置并存储在存储器上,也可以是在处理器开始执行某个任务之前生成,并在该任务完成之后注销。当各存储区域的占用状态发生变化时,处理器更新该占用状态列表的内容以记录各存储区域的占用状态。
在一种可能的实现方式中,可以通过查询各操作的执行状态来判断是否存在正在进行的针对目标存储区域的第二操作。例如,可以记录各操作的操作数所对应的存储区域,并记录各操作的执行状态。若针对目标存储区域的操作的执行状态为未完成,则判断结果为存在正在进行的针对目标操作区域的第二操作。还可以通过判断操作数的占用状态,来确定操作数对应的目标存储区域是否被占用,从而确定是否存在正在进行的针对目标操作区域的第二操作。本公开对判断是否存在正在进行的针对目标操作区域的第二操作的判断依据不做限定。
在一种可能的实现方式中,在针对目标存储区域的第一操作执行前,可判断是否存在正在进行的针对目标存储区 域的第二操作。
在一种可能的实现方式中,在第一操作针对目标存储区域的执行过程中,也可以判断是否存在正在进行的针对目标存储区域的第二操作。
步骤S12g,在存在所述第二操作时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否重叠。
第一细粒度区域和第二细粒度区域可以为目标存储区域中多个细粒度区域中的任意细粒度区域。可以理解的是,针对目标存储区域的操作,即为针对目标存储区域中各细粒度区域的操作。例如,目标存储区域A为第1行至第10行,每1行为一个细粒度区域,目标存储区域A包括10个细粒度区域。针对目标存储区域A的写操作可以看做针对此10个细粒度区域的写操作。其执行过程可以为,写第1个细粒度区域(第1行),第1个细粒度区域写完后写第2个细粒度区域(第2行),第2个细粒度区域写完后写第3个细粒度区域(第3行),以此类推,直至写完第10个细粒度区域(第10行),完成目标存储区域A的写操作。
当有针对目标存储区域的操作时,随着操作的执行,目标存储区域中的细粒度区域的状态,可以包括已被操作完成状态、正在进行操作状态和未被操作状态。操作当前所针对的细粒度区域的状态为正在进行操作状态。由此,当存在针对目标存储区域的操作时,可以认为是存在针对目标存储区域中的一个细粒度区域的操作,正在被操作的细粒度区域,即为操作当前所针对的细粒度区域。
在一种可能的实现方式中,第一操作当前所针对的第一细粒度区域,可以包括将要执行的第一操作所针对的细粒度区域,通常为第一个细粒度区域。也可以包括正在执行的第一操作当前所针对的细粒度区域,可以为任意一个细粒度区域。第二操作当前所针对的第二细粒度区域,可以为正在执行的第二操作当前所针对的细粒度区域,可以为任意一个细粒度区域。
在一种可能的实现方式中,当在针对目标存储区域的第一操作执行前,判断是否存在正在进行的针对目标存储区域的第二操作时,第一操作当前所针对的第一细粒度区域,为第一操作将要执行的细粒度区域。例如,在针对目标存储区域的第一操作执行前,第一操作当前所针对的第一细粒度区域通常为目标存储区域的第一个细粒度区域。此时,第一操作还未对第一细粒度区域执行操作。而正在进行的第二操作当前所针对的第二细粒度区域,可以与第二操作的执行进程相关。若第二操作也刚开始执行,则第二细粒度区域也可为目标存储区域的第一个细粒度区域。此时,第一细粒度区域与第二细粒度区域重叠。若第二操作已经完成第一个细粒度区域的操作,当前所针对的第二细粒度区域为第P个细粒度区域(P为大于1的整数),则第一细粒度区域与第二细粒度区域不重叠。
在一种可能的实现方式中,当在第一操作针对目标存储区域的操作过程中,判断是否存在正在进行的针对目标存储区域的第二操作时,可根据第一操作的执行进程确定第一细粒度区域,根据第二操作的执行进程确定第二细粒度区域,进而判断第一细粒度区域与第二细粒度区域是否重叠。
在一种可能的实现方式中,若各操作执行过程的节拍一致,可只在针对目标存储区域的第一操作执行前,判断是否存在正在进行的针对目标存储区域的第二操作,并判断第一细粒度区域与第二细粒度区域是否重叠。其中,节拍一致是指在细粒度区域的尺寸相同的情况下,两个操作对于一个细粒度区域的操作时长相同。
在一种可能的实现方式中,若各操作执行过程的节拍不一致或不能确定是否一致,可在第一操作针对目标存储区域的操作过程中,每完成当前所针对的第一细粒度区域的操作后,再继续判断是否存在正在进行的针对目标操作区域的第二操作,以及继续判断第一细粒度区域与第二细粒度区域是否重叠,以确定第一操作是否可以继续执行。
在一种可能的实现方式中,可根据物理地址、指针位置、细粒度区域标识等,来判断第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域之间是否重叠。例如,可记录各操作当前的物理地址,根据第一操作当前的物理地址以及第二操作当前的物理地址,以及物理地址与细粒度区域之间的对应关系,分别确定第一操作当前所针对的第一细粒度区域以及第二操作当前所针对的第二细粒度区域,进而判断第一细粒度区域与第二细粒度区域是否重叠。物理地址可以包括细粒度区域的起始地址、终止地址、设定位置的地址或实时操作地址中的一种或任意组合。再例如,可为各操作设置指针,指针指向操作当前所针对的细粒度区域。根据第一操作的指针位置和第二操作的指针位置,分别确定第一操作当前所针对的第一细粒度区域以及第二操作当前所针对的第二细粒度区域,进而判断第一细粒度区域与第二细粒度区域是否重叠。再例如,还可以为各细粒度区域设置标识,通过记录操作当前所针对的细粒度区域的标识来判断第一细粒度区域与第二细粒度区域是否重叠。标识可以包括字母、数字或符号的任意组合。还可以通过其他方式判断第一细粒度区域与第二细粒度区域是否重叠,本公开对第一细粒度区域与第二细粒度区域之 间是否重叠的判断依据不作限制。
步骤S13g,在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
在一种可能的实现方式中,如果第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域不重叠,可以是第一细粒度区域是第二操作已经操作完成的细粒度区域,也可以是第二操作不需要进行操作的细粒度区域,此时执行第一操作不会对第二操作的操作过程及操作结果产生影响,可以执行第一操作。
根据本实施例,能够在第一操作针对的目标存储区域包括至少一个细粒度区域,且存在正在进行的针对目标存储区域的第二操作时,判断第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域之间是否有重叠,在两者无重叠时,执行第一操作。这样,第一操作和第二操作当前所针对的细粒度区域无重叠即可执行,使得第一操作和第二操作可以同时对目标存储区域进行操作,提高了处理器的处理效率。
在一种可能的实现方式中,所述方法还可包括:在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
在一种可能的实现方式中,第一细粒度区域与第二细粒度区域有重叠,包括第一细粒度区域与第二细粒度区域完全重叠或部分重叠。第一细粒度区域与第二细粒度区域有重叠时,若执行第一操作,则第一操作针对重叠部分区域的操作,可以影响第二操作的执行导致第二操作的操作结果不准确,也可以影响第一操作的执行导致第一操作的操作结果不准确。此时,可阻塞第一操作,即暂停第一操作的执行,可以在第二操作对当前所针对的第二细粒度区域操作完成后,执行第一操作。即第一细粒度区域与第二细粒度区域不重叠时,执行第一操作。
在本实施例中,在第一细粒度区域与第二细粒度区域有重叠时,阻塞第一操作,能够避免由于各操作的细粒度区域的重叠而导致的操作错误、操作结果不准确,保证各操作的正确性。
图5a和图5b示出根据本公开实施例的处理器操作方法的应用场景的示意图。如图5a和图5b所示,整体存储区域20d中包括目标存储区域21d,其中,目标存储区域21d被划分为4个细粒度区域,依次为细粒度区域22d、细粒度区域23d、细粒度区域24d和细粒度区域25d。
如图5a所示,当前仅包括写操作,用写指针wp表示写操作当前所针对的细粒度区域。在写操作刚开始时,写指针wp指向细粒度区域22d,可首先判断是否存在正在进行的针对目标存储区域21d的第二操作,如果判断结果为不存在第二操作,则开始对细粒度区域22d进行写操作;当完成对细粒度区域22d的写操作后,写指针wp增加,即wp++,并指向下一个细粒度区域23d,进行同样的判断后,开始对细粒度区域23d进行写操作;当完成对细粒度区域23d的写操作后,写指针wp增加,指向下一个细粒度区域24d,进行同样的判断后,开始对细粒度区域24d进行写操作。
又如图5b所示,当前包括两个操作,读操作和写操作,其中读操作为第一操作,写操作为第二操作。并且使用写操作的写指针wp和读操作的读指针rp分别表示写操作和读操作当前所针对的细粒度区域。
在执行读操作(第一操作)时,判断是否存在正在进行的针对目标存储区域21d的第二操作。经判断,当前存在第二操作写操作,进一步判断读操作(第一操作)当前所针对的第一细粒度区域(图5b中的细粒度区域22d)与写操作(第二操作)当前所针对的第二细粒度区域(图5b中的细粒度区域24d)之间是否重叠,例如可根据细粒度区域的编号(22d和24d),或根据rp与wp之间的关系(rp=0,wp=2,rp<wp),确定出第一细粒度区域与第二细粒度区域之间不重叠,然后,可执行读操作(第一操作)。
当完成对细粒度区域22d的读操作后,rp增加,即rp++,并指向下一个细粒度区域23d,进行同样的判断后,第一操作开始对细粒度区域23d进行操作;当完成对细粒度区域23d的读操作后,rp增加并指向下一个细粒度区域24d。在该情况下,继续判断第一细粒度区域与第二细粒度区域之间是否重叠,如果细粒度区域编号相同或指针rp=wp,即可判断第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域重叠,则第一操作不可执行,阻塞第一操作。当第二操作完成对细粒度区域24d的操作后,wp增加,并指向下一个细粒度区域25d时,rp<wp,可以执行第一操作。
在一种可能的实现方式中,所述第一操作和所述第二操作中可至少一个操作为写操作。即,当对目标数据的操作为写后读(第二操作为写操作,第一操作为读操作)、读后写(第二操作为读操作,第一操作为写操作)或者写后写(第二操作和第一操作均为写操作)时,可采用本公开实施例中的方法。
例如,如果第一操作为读操作,第二操作为写操作,第一操作需要读取的目标操作数需要是第二操作写操作后的数据,第二操作所针对的第二细粒度区域的编号为8,则第一操作仅能够读取编号在8之前的细粒度区域的数据。也就是说,如果第一操作当前所针对的第一细粒度区域为编号1~7的细粒度区域中的任意一个,则可以执行第一操作。
在一种可能的实现方式中,如果第一操作和第二操作均为读操作,则第一操作和第二操作的细粒度区域之间的关系不会影响操作结果,可以采用本公开实施例中的方法,也可直接执行第一操作而不进行细粒度区域的判断。
在本实施例中,当第一操作和第二操作中的至少一个操作为写操作时,通过使用本公开实施例中的方法,通过将目标存储区域划分为一个或多个细粒度区域,并以细粒度区域为单位执行操作,可以使得读后写、写后读、写后写等操作既能够正确的执行,得到准确的执行结果,又可以减少操作之间的等待时间,提高处理器的执行效率。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量可以是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
可以理解,确定所述细粒度区域的尺寸和/或数量可以是在操作生成前预先设定好的,也可以是每条操作生成时实时确定的。其中,在操作前预先设定好细粒度区域的尺寸和/或数量,可以包括根据预先设定好的预设长度的数据所在区域、预先设定好的预设维度的数据所在区域中的至少一种,确定细粒度区域的尺寸和/或数量。而设定长度的数据和预设维度的数据可以与各操作的操作数无关,也可以预先根据各操作的操作数综合确定,可以根据需求确定。而在每条操作生成时实时确定细粒度区域的尺寸和/或数量,可以包括根据各操作的操作数,确定设定长度的数据或设定维度的数据,即,可以根据各操作的操作数的不同,实时确定设定长度的数据所在区域、设定维数的数据所在区域中的至少一种,确定细粒度区域的尺寸和/或数量。
举例来说,可根据设定长度的数据所在区域的大小,确定细粒度区域的尺寸和/或数量。例如,可根据目标操作数中设定长度的数据所在存储区域的尺寸,来设定细粒度区域的尺寸,该区域可以为固定的位宽。例如,目标操作数B是20*10*5的三维数据,其在目标存储区域的存储方式为40*25(即每行40位数据,共25行),则可将设定长度设定为40位,将目标存储区域的每1行设为一个细粒度区域,目标操作数B的存储区域可划分为25个细粒度区域;也可将存储区域的每5行设为一个细粒度区域,目标操作数B的存储区域可划分为5个细粒度区域。本公开对此不作限制。
可以理解的是,根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种,可以在目标存储区域中确定细粒度区域的尺寸和/或数量,也可以在目标存储区域所在的整体存储区域中确定细粒度区域的尺寸和/或数量,以及在整体存储区域中的其他区域确定细粒度区域的尺寸和/或数量。上述示例仅给出其中一种情况,本公开不限定根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种,确定细粒度区域的尺寸和/或数量的适用划分范围。
在一种可能的实现方式中,还可根据设定维数的数据所在区域的大小,确定细粒度区域的尺寸和/或数量。例如,目标操作数C是20*10的二维数据,可根据设定维数为1维、长度为20的数据,将目标操作数C的存储区域划分为10个细粒度区域。
此外,还可同时根据目标操作数的存储区域中的设定长度的数据所在区域的大小和设定维度的数据所在区域的大小,确定细粒度区域的尺寸和/或数量。例如,针对目标操作数C,可根据设定维数为2维、尺寸为4*2的数据来划分细粒度区域,从而将目标操作数C的存储区域划分为25个细粒度区域。
应当理解,本领域技术人员可根据实际情况设定划分细粒度区域的尺寸和/或数量,本公开对此不作限制。
在本实施例中,通过根据设定长度的数据所在区域的大小和/或设定维度的数据所在区域的大小,来确定所述细粒度区域的尺寸和/或数量,可针对数据特性来完成对细粒度区域的划分,能够提高细粒度区域划分的灵活性,从而提高多操作的执行的效率,也可以使得细粒度区域的划分结果能够更加符合不同操作数的特性,从而适应不同类型操作数的处理需求,进一步提高多操作的整体执行效率。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量可以是根据硬件计算能力、硬件带宽中的至少一种确定的。
其中,硬件计算能力可以是硬件在一个计算周期内并行处理的数据量,硬件带宽可以是数据传输能力,例如单位时间内传输的数据量。
举例来说,应用该处理器操作方法的处理器,其硬件计算能力为一个计算周期内并行处理100位数据,硬件带宽为单位时间内传输200位数据,对于大小为1000位的目标存储区域,可根据硬件计算能力将该目标存储区域划分为10个细粒度区域,其中,每个细粒度区域包括100位数据;也可根据硬件带宽将该目标存储区域划分为5个细粒度区域,其中,每个细粒度区域包括200位数据。
应该理解,硬件计算能力、硬件带宽可根据处理器硬件的不同而不同,本公开对硬件计算能力、硬件带宽不作限制。
可以理解的是,根据硬件计算能力、硬件带宽中的至少一种,可以在目标存储区域中确定细粒度区域的尺寸和/或数量,也可以在目标存储区域所在的整体存储区域中确定细粒度区域的尺寸和/或数量,以及在整体存储区域中的其他区域确定细粒度区域的尺寸和/或数量。上述示例仅给出其中一种情况,本公开不限定根据硬件计算能力、硬件带宽中的至少一种,确定细粒度区域的尺寸和/或数量的适用划分范围。
通过这种方式,可根据处理器的处理能力(硬件计算能力和/或硬件带宽)来确定所述细粒度区域的尺寸和/或数量,使得细粒度区域的划分结果更加符合不同硬件使用环境的需求,使得根据细粒度区域执行的操作与处理器的处理能力趋于同步,能够尽可能地发挥硬件的执行效率,从而提高处理器的处理效率。
在一种可能的实现方式中,所述第一操作可以为第一处理指令中的操作,所述第二操作可以为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
其中,第一处理指令和第二处理指令可包括数据存取指令、运算指令、同步指令和通信指令等一种或多种,譬如该指令为读且运算指令。本公开对第一处理指令和第二处理指令的具体类型不作限制。
在一种可能的实现方式中,第一指令可以与第二指令有依赖关系,例如,第一指令需要使用第二指令的计算结果等依赖关系。第一指令也可以与第二指令没有依赖关系。当第一指令与第二指令有依赖关系时,通过本公开实施例中的方法,第一指令与第二指令可以并行执行。
在本实施例中,第一操作和第二操作可以是不同指令中的操作,利用本公开实施例中的方法,可以提高指令执行效率。
在一种可能的实现方式中,第一操作和第二操作也可以为同一处理指令中的两个操作,第二操作可以与第一操作无关,或者第二操作可以基于第一操作的结果。其中,该处理指令可以包括数据存取指令、运算指令、同步指令和通信指令等一种或多种,譬如该指令为“读和加”运算指令,则第一操作为读操作,第二操作为加法运算操作。本公开对该处理指令的具体类型不作限制。
在一种可能的实现方式中,所述方法还可包括:记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,
步骤S13g可包括:当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
在一种可能的实现方式中,位置信息可包括细粒度区域的标识信息。标识信息可以包括数字、字母符号的任意组合。本公开对此不做限定。
例如,位置信息可使用细粒度区域的编号信息来表示,可将目标存储区域被划分为6个细粒度区域,其编号依次为0-5。在执行针对目标存储区域的第一操作和第二操作时,可分别记录第一操作当前操作的第一细粒度区域的第一位置信息(例如编号为2)和第二操作当前操作的第二细粒度区域的第二位置信息(例如编号为5);然后根据编号信息之间的关系(2<5),可知,第一位置信息与第二位置信息不一致;此时,执行第一操作。
在一种可能的实现方式中,位置信息可包括细粒度区域的地址信息。地址信息可以包括细粒度区域的起始地址信息、终止地址信息、细粒度区域中预设位置的地址信息、地址偏移量信息中的至少一个。例如,细粒度区域的位置信息为ADDR15-ADDR31。
通过这种方式,可使用位置信息直接高效地判断第一细粒度区域与第二细粒度区域是否重叠,确定是否执行第一操作,可提高处理器的执行效率。
在一种可能的实现方式中,所述第一位置信息可包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息可包括第二操作已操作完成的细粒度区域的第二数量,
当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作,可包括:当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
举例来说,第一操作为第二操作之后的操作,其目标存储区域被划分为6个细粒度区域,其位置信息可使用已操作完成的细粒度区域的数量来表示。在执行针对目标存储区域的第一操作和第二操作时,可分别记录第一操作已操作完成的细粒度区域的第一数量(例如第一数量为3)和第二操作已操作完成的细粒度区域的第二数量(例如第二数量为5);然后根据第一操作与第二操作的执行顺序,以及第一数量与第二数量的关系,可知,第一操作为第二操作之后的操作,且第一数量3小于第二数量5,此时,执行第一操作。
通过这种方式,可根据已操作完成的细粒度区域的数量来直观地判断第一细粒度区域与第二细粒度区域是否重叠,进而确定是否执行第一操作,可简化判断过程,提高处理器的执行效率。
在一种可能的实现方式中,所述目标存储区域可包括可操作区域和非可操作区域,步骤S12g可包括:在存在所述第二操作,且所述第一操作当前所针对的第一细粒度区域位于所述可操作区域内时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否有重叠。
在一种可能的实现方式中,目标存储区域中可包括一个或多个非可操作区域、也可包括连续或不连续的非可操作区域。
在一种可能的实现方式中,目标存储区域中可包括一个或多个可操作区域、也可包括连续或不连续的可操作区域。本公开对此不做限定。
在一种可能的实现方式中,在第一操作为针对目标存储区域的操作时,可首先判断是否存在正在进行的针对目标存储区域的第二操作;当存在第二操作时,判断第一操作所针对的第一细粒度区域是否位于可操作区域内;当存在第二操作,且第一操作所针对的第一细粒度区域位于可操作区域内时,然后再判断第一操作所针对的第一细粒度区域与第二操作所针对的第二细粒度区域之间是否有重叠;当第一细粒度区域与第二细粒度区域之间没有重叠时,执行第一操作。
在一种可能的实现方式中,所述非可操作区域可以包括禁止操作区域和非禁止操作区域。如果第一操作为写操作,当目标操作数的部分数据不可修改时,可将该部分数据所在的存储区域设定为禁止操作区域,以避免误修改该部分数据;如果正在进行的第二操作为读取第一操作之前的数据的读操作(读后写),则可将第二操作所在的一个或多个细粒度区域设定为非禁止操作区域,当第二操作完成对非禁止操作区域的读取后,可将该非禁止操作区域变更为可操作区域。本公开对非可操作区域的分类及划分方式不作限制。
在本实施例中,可先判断第一操作的细粒度区域是否可操作,再判断不同操作的细粒度区域之间的关系,一方面提高了判断的效率,另一方面可以对指定数据进行保护以防止有误操作发生,也可以对指定的空间禁止读写,从而预留出该空间,用于执行其他操作,进一步提高了处理器在执行细粒度同步时的灵活性。
在一种可能的实现方式中,所述非可操作区域可以为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述方法还可包括:当所述第二操作所针对的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
也就是说,包括第二细粒度区域在内的非可操作区域可以不随第二操作所针对的第二细粒度区域的更新而更新,当第二操作所针对的第二细粒度区域移出非可操作区域后,更新非可操作区域的位置。例如,非可操作区域可以为包括所述第二细粒度区域在内的Q个细粒度区域(Q为大于1的整数),当前的非可操作区域包括第2至第2+Q-1个细粒度区域。当第二操作在非可操作区域内执行完Q个细粒度区域后,移出非可操作区域,则非可操作区域的位置随着第二操作所针对的细粒度区域的位置进行更新,更新后的非可操作区域包括第2+Q个至2+Q+Q-1个细粒度区域。其中,Q的大小可以根据需求任意确定。
图6a和图6b示出根据本公开实施例的处理器操作方法的应用场景的示意图。如图6a所示,目标存储区域30d包括8个细粒度区域,其中,可操作区域包括5个细粒度区域(细粒度区域31d、细粒度区域35d、细粒度区域36d、细粒度区域37d和细粒度区域38d),非可操作区域M0包括3个细粒度区域(细粒度区域32d、细粒度区域33d和细粒度区域34d)。其中,第二操作当前所针对的第二细粒度区域为细粒度区域32。
------------------------------------------------------------------------------------------
当第二操作执行完对细粒度区域32d的操作后,第二操作当前所针对的第二细粒度区域为细粒度区域33d,此时,第二操作当前所针对的第二细粒度区域(细粒度区域33d)未移出非可操作区域,不更新非可操作区域的位置;当第二操作执行完对细粒度区域33d的操作后,第二操作当前所针对的第二细粒度区域为细粒度区域34d,此时,第二操作当前所针对的第二细粒度区域(细粒度区域34d)还未移出非可操作区域,不更新非可操作区域的位置;当第二操作执行完对细粒度区域34d的操作后,第二操作当前所针对的第二细粒度区域为细粒度区域35d,此时,第二操作当前所针对的第二细粒度区域(细粒度区域35d)已移出非可操作区域,更新非可操作区域的位置到细粒度区域(35d、36d和37d)。需要说明的是,本公开对非可操作区域的大小不做限定。
如图6b所示,更新非可操作区域的位置后,在目标存储区域30d中可操作区域包括5个细粒度区域(细粒度区域31d、细粒度区域32d、细粒度区域33d、细粒度区域34d和细粒度区域38d),非可操作区域M0包括3个细粒度区域(细粒度区域35d、细粒度区域36d和细粒度区域37d)。
通过这种方式,不需要实时更新非可操作区域的位置,能够降低更新非可操作区域所产生的开销。
在一种可能的实现方式中,所述非可操作区域可以为包括所述第二细粒度区域在内的多个细粒度区域,且所述第 二细粒度区域位于所述非可操作区域内的设定位置,所述非可操作区域的位置随所述第二操作的操作位置更新。
也就是说,当非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域时,可以设定第二细粒度区域在非可操作区域中的位置(例如中间位置、最后位置等),非可操作区域的位置随第二操作的操作位置而更新。例如,非可操作区域可以为包括所述第二细粒度区域在内的Q个细粒度区域,当前的非可操作区域包括第2至第2+Q-1个细粒度区域,第二细粒度区域在非可操作区域内的设定位置为第R个(其中R≤Q)。当第二操作执行完成对当前所针对的细粒度区域的操作后,第二操作开始执行针对下一个细粒度区域的操作,此时,非可操作区域的位置随第二操作的操作位置而更新,更新后的非可操作区域包括第2+1至第2+Q个细粒度区域。其中,Q的大小及R的取值可根据需求确定。本公开对非可操作区域包括的细粒度区域的数量、第二细粒度区域位于非可操作区域内的位置均不作限制。
图7a和图7b示出根据本公开实施例的处理器操作方法的应用场景的示意图。如图7a所示,目标存储区域40中包括8个细粒度区域,其中,可操作区域包括5个细粒度区域(细粒度区域41、细粒度区域45、细粒度区域46、细粒度区域47和细粒度区域48),非可操作区域M1包括3个细粒度区域(细粒度区域42、细粒度区域43和细粒度区域44)。其中,第二操作当前所针对的第二细粒度区域设定为位于非可操作区域M1的第二个细粒度区域,即细粒度区域43。
当第二操作执行完对细粒度区域43的操作后,第二操作当前所针对的第二细粒度区域为细粒度区域44,此时,非可操作区域的位置随第二操作的操作位置而更新,以使第二操作当前所针对的第二细粒度区域位于非可操作区域M1的第二个细粒度区域。
如图7b所示,更新非可操作区域的位置后的目标存储区域40中,可操作区域包括5个细粒度区域(细粒度区域41、细粒度区域42、细粒度区域46、细粒度区域47和细粒度区域48),非可操作区域M1包括3个细粒度区域(细粒度区域43、细粒度区域44和细粒度区域45)。
通过这种方式,能够实时更新非可操作区域的位置,提高细粒度处理的同步程度,从而进一步提高数据同步处理的效率。
在一种可能的实现方式中,所述目标存储区域可包括:循环缓冲存储区域。所述循环缓冲存储区域可用于循环存储数据。
图8示出根据本公开实施例的处理器操作方法的循环缓冲存储区域的示意图。如图8所示,目标存储区域50中包括循环缓冲存储区域51,其地址为start_addr~end_addr。
例如,第二操作为写操作,可将目标操作数写入循环缓冲存储区域51中,其地址指针point从start_addr开始,依次向下存储数据,直到end_addr,即占满循环缓冲存储区域51的存储空间,此时,地址指针point跳回到start_addr,判断该地址是否被所需同步的第一操作使用完毕,如果使用完毕,则将数据存储到该地址,覆盖原有数据,之后地址指针point依次向下移动,直到end_addr,此时,可重新覆盖数据,循环上述过程。
在本实施例中,采用循环缓冲存储区域来存储数据,既可节省数据存储空间,也可提高存储空间使用效率。
在一种可能的实现方式中,可将循环缓冲存储区域划分为多个细粒度区域。对于每个细粒度区域,可通过列表或标志位或其他方式来对细粒度区域中的数据是否可覆盖进行管理,例如,可设置覆盖标志位来表示细粒度区域中的数据是否可覆盖。
举例来说,第一操作为读操作,第二操作为写操作,即先写后读,可使用写指针wp和读指针rp分别表示第二操作和第一操作当前所针对的细粒度区域。在第二操作当前所针对的第二细粒度区域的覆盖标志位为可覆盖时,可执行第二操作,写入数据,数据写入完成后,将该第二细粒度区域的覆盖标志位设为不可覆盖,wp++,第二操作当前所针对的第二细粒度区域为下一个细粒度区域,如果wp>end_addr,则wp=start_addr;在第一操作当前所针对的第一细粒度区域与第二细粒度区域之间不重叠,且第一细粒度区域的覆盖标志位为不可覆盖时,可执行第一操作,读取数据,数据读取完成后,将该第一细粒度区域的覆盖标志位设为可覆盖,rp++,第一操作当前所针对的第一细粒度区域为下一个细粒度区域,如果rp>end_addr,则rp=start_addr;在第一细粒度区域与第二细粒度区域有重叠,即rp=wp时,则不可执行第一操作,需等待第二操作完成对当前所针对的第二细粒度区域的操作后,可执行第一操作。
在本实施例中,将循环缓冲存取区域划分为多个细粒度区域,使得多个操作可同时对循环缓冲存储区域进行操作,从而提高处理器的处理效率。
在一种可能的实现方式中,所述细粒度区域可包括状态标识,所述状态标识可包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
步骤S13g可包括:在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态 标识是否为已完成状态;若是,则执行所述第一操作。
在一种可能的实现方式中,细粒度区域可包括状态标识,状态标识可包括针对细粒度区域的操作处于已完成状态或未完成状态。例如,状态标识可使用0和1来表示,其中,0表示针对细粒度区域的操作处于未完成状态,1表示针对细粒度区域的操作处于已完成状态,或者0表示针对细粒度区域的操作处于已完成状态,1表示针对细粒度区域的操作处于未完成状态。本公开对状态标识的表示方式不作限制。
在一种可能的实现方式中,第二操作可将目标存储区域中已操作完成的细粒度区域的状态标识设置为已完成状态,未操作或正在操作的细粒度区域的状态标识设置为未完成状态。也可将已操作完成的细粒度区域中的部分细粒度区域的状态标识设置为已完成状态,其他细粒度区域设置为未完成状态。例如,第二操作已操作完成5个细粒度区域,可将前3个细粒度区域的状态标识设置为已完成状态,其他细粒度区域设置为未完成状态。
在一种可能的实现方式中,在存在正在进行的针对目标存储区域的第二操作时,对于第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域,可在确定第一细粒度区域与第二细粒度区域之间不重叠后,判断第一细粒度区域的状态标识是否为已完成状态;如果第一细粒度区域的状态标识为已完成状态,可执行第一操作。
在本实施例中,细粒度区域包括状态标识,在第一细粒度区域与第二细粒度区域之间不重叠时,根据第一细粒度区域的状态标识,确定第一操作是否可执行,可在提高处理器的处理效率的同时,提高数据处理的正确性。
在一种可能的实现方式中,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,步骤S13g可包括:判断所述第一细粒度区域的状态标识是否为已完成状态;若是,则在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
也就是说,在存在正在进行的针对目标存储区域的第二操作时,对于第一操作当前所针对的第一细粒度区域与第二操作当前所针对的第二细粒度区域,可在确定第一细粒度区域的状态标识为已完成状态后,根据第一细粒度区域与第二细粒度区域之间重叠关系,确定第一操作是否可执行。在第一细粒度区域与第二细粒度区域之间不重叠时,可执行第一操作。
在本实施例中,细粒度区域包括状态标识,可在确定第一细粒度区域的状态标识为已完成状态后,根据第一细粒度区域与第二细粒度区域之间重叠关系,确定第一操作是否可执行,可在提高数据处理的正确性同时,提高处理器的处理效率。
在一种可能的实现方式中,所述第一操作和所述第二操作的目标操作数一致,所述目标存储区域为所述目标操作数的存储区域。
在一种可能的实现方式中,当第一操作的目标操作数和第二操作的目标操作数一致时,目标存储区域可以是一个目标操作数的存储区域。此目标操作数的存储区域即为目标存储区域。将目标存储区域划分为多个细粒度区域后,根据本公开实施例中的方法,可以使得操作相同目标操作数的两个操作并行执行而不影响各操作的执行结果。
在本实施例中,可使用本公开实施例中的方法,实现针对相同操作数的两个操作的并行执行,提高处理器的执行效率。
在一种可能的实现方式中,所述目标存储区域为第一操作中第一操作数的第一存储区域和第二操作中第二操作数的第二存储区域之间的重叠区域。
在一种可能的实现方式中,当两个操作数的存储区域存在重叠区域时,目标存储区域即为重叠区域。可以将两个操作的存储区域中的重叠区域划分为多个细粒度区域,根据本公开实施例中的方法,可以使得操作数的存储区域有重叠区域的两个操作并行执行而不影响各操作的执行结果。
在本实施例中,当两个操作的操作数的存储区域有重叠时,可使用本公开实施例中的方法实现两个操作的并行执行,提高处理器的执行效率。
在一种可能的实现方式中,所述方法还可包括:将目标存储区域所在的整体存储区域划分为多个细粒度区域。
在一种可能的实现方式中,目标存储区域可以为存储装置的整体存储区域中的部分存储区域或全部存储区域,所述整体存储区域包括预设的多个细粒度区域。
例如目标存储区域所在的整体存储区域为RAM1,RAM1可以包括预先设定m个细粒度区域(m为正整数)。目标存储区域在RAM1中可以占据RAM1中的n个细粒度区域(n为正整数,且n<=m)。需要说明的是,目标存储区域也可以包括某细粒度区域中的部分区域。在如上示例的RAM1中,假设每个细粒度区域为整体存储区域RAM1中的一行,每行为100比特。目标存储区域可以包括前面(n-1)个完整的细粒度区域,并且又包括最后一个细粒度区域的部分区域, 例如为RAM1中第n行(第n个细粒度区域)中的前80个比特。
在一种可能的实现方式中,当将存储装置的整体存储区域划分为多个细粒度区域时,针对整体存储区域中任意目标存储区域的任意操作,且无论目标存储区域为第一操作和第二操作的相同目标操作数的存储区域,还是目标存储区域为第一操作中第一操作数的存储区域和第二操作中第二操作数的存储区域的重叠区域,都可以根据整体存储区域的细粒度划分结果,确定目标存储区域中的细粒度区域。任意操作的任意操作数在整体存储区域的中存储区域,具有相同尺寸的细粒度区域。
在一种可能的实现方式中,可以根据存储装置的硬件特性,确定整体存储区域的细粒度区域的尺寸和/或数量,即可以根据存储装置的硬件计算能力、硬件带宽中的至少一种,确定整体存储区域的细粒度区域的尺寸和/或数量。
在本实施例中,将目标存储区域所在的整体存储区域划分为多个细粒度区域,针对整体存储区域中任意目标存储区域的任意操作,都可以按照相同的细粒度尺寸执行,不同操作按照本公开实施例中的方法并行执行时,可以更加方便地同步,提高操作并行度,进而提高处理器的处理效率。
在一种可能的实现方式中,所述方法还可包括:
根据第一操作中携带的第一细粒度划分信息,将所述第一操作中第一操作数的第一存储区域划分为多个细粒度区域,及
根据第二操作中携带的第二细粒度划分信息,将所述第二操作中第二操作数的第二存储区域划分为多个细粒度区域。
在一种可能的实现方式中,可以在操作中携带细粒度划分信息,细粒度划分信息可以包括细粒度的尺寸和/或数量。不同的操作可以携带不同的细粒度划分信息。相同类型的操作可携带相同的细粒度划分信息。可在操作中操作数的设定位置携带细粒度划分信息,也可在操作码或操作数中携带是否进行细粒度划分的标识信息。本公开对细粒度划分信息中的内容及表现方式不做限定。
在一种可能的实现方式中,根据第一操作中携带的第一细粒度划分信息,将第一操作数的第一存储区域划分为多个第一细粒度区域。第一操作数所在的整体存储区域中的其他区域,可不进行细粒度的划分,也可按照其他操作携带的细粒度划分信息,进行细粒度的划分。本公开对此不做限定。
可以理解的是,当第二操作的第二操作数与第一操作的第一操作数一致时,第一存储区域与第二存储区域完全重叠。而第一细粒度划分信息和第二细粒度划分信息可以一致,也可以不一致。当第一细粒度划分信息和第二细粒度划分信息不一致时,第一存储区域可同时按照第二细粒度划分信息进行细粒度划分。即,针对同一个存储区域,不同的操作可以将其划分为不同尺寸或数量的多个细粒度区域。此时,可根据第一操作当前所针对的第一细粒度区域的物理地址,以及第二操作当前所述针对的第二细粒度区域之间的物理地址,判断第一细粒度区域与第二细粒度区域是否重叠,并根据判断结果进行第一操作和第二操作的并行执行。
在一种可能的实现方式中,各操作中携带的细粒度划分信息,可包括根据设定长度的操作数据所在区域、设定维数的操作数所在区域中的至少一种,确定出的所述细粒度区域的尺寸和/或数量,使得细粒度的划分结果更加符合操作中操作数的类型或属性。
在本实施例中,根据第一操作中携带的第一细粒度划分信息,将所述第一操作中第一操作数的第一存储区域划分为多个细粒度区域,及根据第二操作中携带的第二细粒度划分信息,将所述第二操作中第二操作数的第二存储区域划分为多个细粒度区域。根据操作中携带的细粒度划分信息进行细粒度的划分,可使得细粒度的划分结果,更加符合各操作的处理需求,操作并行更加灵活。
应当理解,本领域技术人员可以根据实际情况将目标存储区域进行细粒度区域的划分与设置,本公开对此不作限制。
需要说明的是,尽管以上述实施例作为示例介绍了处理器操作方法如上,但本领域技术人员能够理解,本公开应不限于此。事实上,用户完全可根据个人喜好和/或实际应用场景灵活设定各步骤,只要符合本公开的技术方案即可。
图3g示出根据本公开实施例的处理器操作装置的框图。如图3g所示,所述处理器操作装置包括:
操作判断模块71g,用于在第一操作为针对目标存储区域的操作时,判断是否存在正在进行的针对所述目标存储区域的第二操作,所述目标存储区域包括至少一个细粒度区域;
重叠判断模块72g,用于在存在所述第二操作时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否有重叠;
执行模块73g,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
在一种可能的实现方式中,所述装置还包括:执行控制模块,用于在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
在一种可能的实现方式中,所述第一操作和所述第二操作中的至少一个操作为写操作。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
在一种可能的实现方式中,所述细粒度区域的尺寸和/或数量是根据硬件计算能力、硬件带宽中的至少一种确定的。
在一种可能的实现方式中,所述第一操作为第一处理指令中的操作,所述第二操作为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
在一种可能的实现方式中,所述装置还包括:位置记录模块,用于记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,所述执行模块73,包括:第一执行子模块,用于当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
在一种可能的实现方式中,所述第一位置信息包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息包括第二操作已操作完成的细粒度区域的第二数量,第一执行子模块,还用于:当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
在一种可能的实现方式中,所述目标存储区域包括可操作区域和非可操作区域,所述重叠判断模块72,包括:判断子模块,用于在存在所述第二操作,且所述第一操作当前所针对的第一细粒度区域位于所述可操作区域内时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否重叠。
在一种可能的实现方式中,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述装置还包括:
更新模块,用于当所述第二操作所针对的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
在一种可能的实现方式中,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域位于所述非可操作区域内的设定位置,所述非可操作区域的位置随所述第二操作的操作位置更新。
在一种可能的实现方式中,所述目标存储区域包括:循环缓冲存储区域。
在一种可能的实现方式中,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
所述执行模块73g,包括:第一状态判断子模块,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态标识是否为已完成状态;第二执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态时,执行所述第一操作。
在一种可能的实现方式中,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
所述执行模块73g,包括:第二状态判断子模块,用于判断所述第一细粒度区域的状态标识是否为已完成状态;第三执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态,且所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
在一种可能的实现方式中,所述第一操作和所述第二操作的目标操作数一致,所述目标存储区域为所述目标操作数的存储区域。
在一种可能的实现方式中,所述目标存储区域为第一操作中第一操作数的第一存储区域和第二操作中第二操作数的第二存储区域之间的重叠区域。
在一种可能的实现方式中,所述装置还包括:第一设定模块,用于将目标存储区域所在的整体存储区域划分为多个细粒度区域。
在一种可能的实现方式中,所述装置还包括:
第二设定模块,用于根据第一操作中携带的第一细粒度划分信息,将所述第一操作中第一操作数的第一存储区域划分为多个细粒度区域,及
第三设定模块,用于根据第二操作中携带的第二细粒度划分信息,将所述第二操作中第二操作数的第二存储区域 划分为多个细粒度区域。
在一种可能的实现方式中,还公开了一种人工智能芯片,其包括了上述处理器操作装置。
在一种可能的实现方式中,还公开了一种板卡,其包括存储器件、接口装置和控制器件以及上述人工智能芯片;其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;所述存储器件,用于存储数据;所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;所述控制器件,用于对所述人工智能芯片的状态进行监控。
在一种可能的实现方式中,所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;所述人工智能芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;所述接口装置为:标准PCIE接口。
A1、一种处理器操作方法,所述方法包括:
在第一操作为针对目标存储区域的操作时,判断是否存在正在进行的针对所述目标存储区域的第二操作,所述目标存储区域包括至少一个细粒度区域;
在存在所述第二操作时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否有重叠;
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A2、根据权利要求A1所述的方法,所述方法还包括:
在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
A3、根据权利要求A1所述的方法,所述第一操作和所述第二操作中的至少一个操作为写操作。
A4、根据权利要求A1所述的方法,所述细粒度区域的尺寸和/或数量是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
A5、根据权利要求A1所述的方法,所述细粒度区域的尺寸和/或数量是根据硬件计算能力、硬件带宽中的至少一种确定的。
A6、根据权利要求A1所述的方法,所述第一操作为第一处理指令中的操作,所述第二操作为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
A7、根据权利要求A1-A6中任意一项所述的方法,所述方法还包括:
记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作,包括:
当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
A8、根据权利要求A7所述的方法,所述第一位置信息包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息包括第二操作已操作完成的细粒度区域的第二数量,
当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作,包括:
当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
A9、根据权利要求A1所述的方法,所述目标存储区域包括可操作区域和非可操作区域,在存在所述第二操作时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否重叠,包括:
在存在所述第二操作,且所述第一操作当前所针对的第一细粒度区域位于所述可操作区域内时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否重叠。
A10、根据权利要求A9所述的方法,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述方法还包括:
当所述第二操作所针对的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
A11、根据权利要求A9所述的方法,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域位于所述非可操作区域内的设定位置,
所述非可操作区域的位置随所述第二操作的操作位置更新。
A12、根据权利要求A1所述的方法,所述目标存储区域包括:循环缓冲存储区域。
A13、根据权利要求A1所述的方法,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操 作处于已完成状态或未完成状态,
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作,包括:
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态标识是否为已完成状态;
若是,则执行所述第一操作。
A14、根据权利要求A1所述的方法,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态;
在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作,包括:
判断所述第一细粒度区域的状态标识是否为已完成状态;
若是,则在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A15、根据权利要求A1所述的方法,所述第一操作和所述第二操作的目标操作数一致,所述目标存储区域为所述目标操作数的存储区域。
A16、根据权利要求A1所述的方法,所述目标存储区域为第一操作中第一操作数的第一存储区域和第二操作中第二操作数的第二存储区域之间的重叠区域。
A17、根据权利要求A1-A16中任意一项所述的方法,所述方法还包括:
将目标存储区域所在的整体存储区域划分为多个细粒度区域。
A18、根据权利要求A1-A17中任意一项所述的方法,所述方法还包括:
根据第一操作中携带的第一细粒度划分信息,将所述第一操作中第一操作数的第一存储区域划分为多个细粒度区域,及
根据第二操作中携带的第二细粒度划分信息,将所述第二操作中第二操作数的第二存储区域划分为多个细粒度区域。
A19、一种处理器操作装置,所述装置包括:
操作判断模块,用于在第一操作为针对目标存储区域的操作时,判断是否存在正在进行的针对所述目标存储区域的第二操作,所述目标存储区域包括至少一个细粒度区域;
重叠判断模块,用于在存在所述第二操作时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否有重叠;
执行模块,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A20、根据权利要求A19所述的装置,所述装置还包括:
执行控制模块,用于在所述第一细粒度区域与所述第二细粒度区域有重叠时,阻塞所述第一操作。
A21、根据权利要求A19所述的装置,所述第一操作和所述第二操作中的至少一个操作为写操作。
A22、根据权利要求A19所述的装置,所述细粒度区域的尺寸和/或数量是根据设定长度的数据所在区域、设定维数的数据所在区域中的至少一种确定的。
A23、根据权利要求A19所述的装置,所述细粒度区域的尺寸和/或数量是根据硬件计算能力、硬件带宽中的至少一种确定的。
A24、根据权利要求A19所述的装置,所述第一操作为第一处理指令中的操作,所述第二操作为第二处理指令中的操作,所述第二处理指令为指令队列中在所述第一处理指令之前的处理指令。
A25、根据权利要求A19-A24中任意一项所述的装置,所述装置还包括:
位置记录模块,用于记录所述第一操作当前操作的第一细粒度区域的第一位置信息和所述第二操作当前操作的第二细粒度区域的第二位置信息,
所述执行模块,包括:
第一执行子模块,用于当所述第一位置信息与所述第二位置信息不一致时,执行所述第一操作。
A26、根据权利要求A25所述的装置,所述第一位置信息包括第一操作已操作完成的细粒度区域的第一数量,所述第二位置信息包括第二操作已操作完成的细粒度区域的第二数量,
所述第一执行子模块,还用于:
当所述第一操作为所述第二操作之后的操作,且所述第一数量小于所述第二数量时,执行所述第一操作。
A27、根据权利要求A19所述的装置,所述目标存储区域包括可操作区域和非可操作区域,所述重叠判断模块,包括:
判断子模块,用于在存在所述第二操作,且所述第一操作当前所针对的第一细粒度区域位于所述可操作区域内时,判断所述第一操作当前所针对的第一细粒度区域与所述第二操作当前所针对的第二细粒度区域之间是否重叠。
A28、根据权利要求A27所述的装置,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域在所述非可操作区域内的位置随所述第二操作的操作位置更新,所述装置还包括:
更新模块,用于当所述第二操作所针对的第二细粒度区域移出所述非可操作区域后,更新所述非可操作区域的位置。
A29、根据权利要求A27所述的装置,所述非可操作区域为包括所述第二细粒度区域在内的多个细粒度区域,且所述第二细粒度区域位于所述非可操作区域内的设定位置,
所述非可操作区域的位置随所述第二操作的操作位置更新。
A30、根据权利要求A19所述的装置,所述目标存储区域包括:循环缓冲存储区域。
A31、根据权利要求A19所述的装置,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
所述执行模块,包括:
第一状态判断子模块,用于在所述第一细粒度区域与所述第二细粒度区域之间不重叠时,判断所述第一细粒度区域的状态标识是否为已完成状态;
第二执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态时,执行所述第一操作。
A32、根据权利要求A19所述的装置,所述细粒度区域包括状态标识,所述状态标识包括针对所述细粒度区域的操作处于已完成状态或未完成状态,
所述执行模块,包括:
第二状态判断子模块,用于判断所述第一细粒度区域的状态标识是否为已完成状态;
第三执行子模块,用于在所述第一细粒度区域的状态标识为已完成状态,且所述第一细粒度区域与所述第二细粒度区域之间不重叠时,执行所述第一操作。
A33、根据权利要求A19所述的装置,所述第一操作和所述第二操作的目标操作数一致,所述目标存储区域为所述目标操作数的存储区域。
A34、根据权利要求A19所述的装置,所述目标存储区域为第一操作中第一操作数的第一存储区域和第二操作中第二操作数的第二存储区域之间的重叠区域。
A35、根据权利要求A19-A34中任意一项所述的装置,所述装置还包括:
第一设定模块,用于将目标存储区域所在的整体存储区域划分为多个细粒度区域。
A36、根据权利要求A19-A35中任意一项所述的装置,所述装置还包括:
第二设定模块,用于根据第一操作中携带的第一细粒度划分信息,将所述第一操作中第一操作数的第一存储区域划分为多个细粒度区域,及
第三设定模块,用于根据第二操作中携带的第二细粒度划分信息,将所述第二操作中第二操作数的第二存储区域划分为多个细粒度区域。
A37、一种人工智能芯片,所述人工智能芯片包括如权利要求A19-A36中任意一项所述的处理器操作装置。
A38、一种电子设备,所述电子设备包括如权利要求A37所述的人工智能芯片。
A39、一种板卡,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求A37所述的人工智能芯片;
其中,所述人工智能芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;
所述存储器件,用于存储数据;
所述接口装置,用于实现所述人工智能芯片与外部设备之间的数据传输;
所述控制器件,用于对所述人工智能芯片的状态进行监控。
A40、根据权利要求A39所述的板卡,所述存储器件包括:多组存储单元,每一组所述存储单元与所述人工智能芯片通过总线连接,所述存储单元为:DDR SDRAM;
所述人工智能芯片包括:DDR控制器,用于对每个所述存储单元的数据传输与数据存储的控制;
所述接口装置为:标准PCIE接口。
以上已经描述了本公开的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。

Claims (10)

  1. 一种数据处理方法,其特征在于,所述方法包括:
    在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;
    根据所述描述符的内容,执行所述第一处理指令。
  2. 根据权利要求1所述的方法,其特征在于,根据所述描述符的内容,执行所述第一处理指令,包括:
    根据所述描述符的内容,确定与所述第一处理指令的操作数对应的数据在数据存储空间中的数据地址;
    根据所述数据地址,执行与所述第一处理指令对应的数据处理。
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在所述第一处理指令为描述符注册指令时,获取所述第一处理指令中描述符的注册参数,所述注册参数包括所述描述符的标识、张量形状以及描述符所指示的张量数据的内容中的至少一种;
    根据所述描述符的注册参数,确定所述描述符的内容在描述符存储空间中的第一存储区域,以及所述描述符所指示的张量数据的内容在数据存储空间中的第二存储区域;
    根据所述描述符的注册参数以及所述第二存储区域,确定所述描述符的内容,以建立所述描述符与所述第二存储区域之间的对应关系;
    将所述描述符的内容存储到所述第一存储区域。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在所述第一处理指令为描述符注销指令时,获取所述第一处理指令中描述符的标识;
    根据所述描述符的标识,分别释放所述描述符在描述符存储空间中的存储区域以及所述描述符所指示的张量数据的内容在数据存储空间中的存储区域。
  5. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在所述第一处理指令为描述符修改指令时,获取所述第一处理指令中描述符的修改参数,所述修改参数包括所述描述符的标识、待修改的张量形状以及描述符所指示的张量数据的内容中的至少一种;
    根据所述描述符的修改参数,确定所述描述符的待更新内容;
    根据待更新内容,更新描述符存储空间中的所述描述符的内容和/或数据存储空间中张量数据的内容。
  6. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    根据所述描述符的标识,确定是否存在未完成处理的第二处理指令,所述第二处理指令包括指令队列中在所述第一处理指令之前的,且操作数中具有所述描述符的标识的处理指令;
    在存在未完成处理的第二处理指令时,阻塞或缓存所述第一处理指令。
  7. 一种数据处理装置,其特征在于,所述装置包括:
    内容获取模块,用于在解码后的第一处理指令的操作数包括描述符的标识时,根据所述描述符的标识,获取所述描述符的内容,所述描述符用于指示张量的形状;
    指令执行模块,用于根据所述描述符的内容,执行所述第一处理指令。
  8. 一种神经网络芯片,其特征在于,所述芯片包括如权利要求7所述的数据处理装置。
  9. 一种电子设备,其特征在于,所述电子设备包括如权利要求8所述的神经网络芯片。
  10. 一种板卡,其特征在于,所述板卡包括:存储器件、接口装置和控制器件以及如权利要求8所述的神经网络芯片;
    其中,所述神经网络芯片与所述存储器件、所述控制器件以及所述接口装置分别连接;
    所述存储器件,用于存储数据;
    所述接口装置,用于实现所述神经网络芯片与外部设备之间的数据传输;
    所述控制器件,用于对所述神经网络芯片的状态进行监控。
PCT/CN2020/082775 2019-04-04 2020-04-01 数据处理方法及装置以及相关产品 WO2020200244A1 (zh)

Priority Applications (20)

Application Number Priority Date Filing Date Title
KR1020207036505A KR102550451B1 (ko) 2019-04-04 2020-04-01 데이터 처리방법과 장치 및 관련 제품
EP20217329.0A EP3825843B1 (en) 2019-04-04 2020-04-01 Data processing method and apparatus, and related product
EP20783678.4A EP3800547A4 (en) 2019-04-04 2020-04-01 DATA PROCESSING METHOD AND DEVICE AND RELEVANT PRODUCT
EP20217328.2A EP3825842B1 (en) 2019-04-04 2020-04-01 Data processing method and apparatus, and related product
KR1020207036494A KR102569336B1 (ko) 2019-04-04 2020-04-01 데이터 처리방법과 장치 및 관련 제품
KR1020207036492A KR102519470B1 (ko) 2019-04-04 2020-04-01 데이터 처리방법과 장치 및 관련 제품
EP20217330.8A EP3825846A1 (en) 2019-04-04 2020-04-01 Data processing method and apparatus, and related product
EP20217332.4A EP3828698B1 (en) 2019-04-04 2020-04-01 Data processing method and apparatus, and related product
EP20217331.6A EP3825847B1 (en) 2019-04-04 2020-04-01 Data processing method and apparatus, and related product
JP2021510522A JP7073580B2 (ja) 2019-04-04 2020-04-01 データ処理方法、装置、及び関連製品
EP20217333.2A EP3825848A1 (en) 2019-04-04 2020-04-01 Data processing method and apparatus, and related product
KR1020207036508A KR102379406B1 (ko) 2019-04-04 2020-04-01 데이터 처리방법과 장치 및 관련 제품
KR1020207036496A KR102522416B1 (ko) 2019-04-04 2020-04-01 데이터 처리방법과 장치 및 관련 제품
KR1020207032006A KR20210002518A (ko) 2019-04-04 2020-04-01 데이터 처리방법과 장치 및 관련 제품
KR1020207036500A KR102579192B1 (ko) 2019-04-04 2020-04-01 데이터 처리방법과 장치 및 관련 제품
US17/137,245 US20210150325A1 (en) 2019-04-04 2020-12-29 Data processing method and apparatus, and related product
US17/242,209 US11836491B2 (en) 2019-04-04 2021-04-27 Data processing method and apparatus, and related product for increased efficiency of tensor processing
US17/327,627 US11687339B2 (en) 2019-04-19 2021-05-21 Data processing method and apparatus, and related product
US18/369,819 US20240004650A1 (en) 2019-04-04 2023-09-18 Data processing method and apparatus, and related product
US18/374,176 US20240028334A1 (en) 2019-04-04 2023-09-28 Data processing method and apparatus, and related product for increased efficiency of tensor processing

Applications Claiming Priority (14)

Application Number Priority Date Filing Date Title
CN201910272411.9A CN111782133A (zh) 2019-04-04 2019-04-04 数据处理方法及装置以及相关产品
CN201910272660.8A CN111782267B (zh) 2019-04-04 2019-04-04 数据处理方法及装置以及相关产品
CN201910272625.6 2019-04-04
CN201910272660.8 2019-04-04
CN201910272625.6A CN111782577B (zh) 2019-04-04 2019-04-04 数据处理装置及方法以及相关产品
CN201910272411.9 2019-04-04
CN201910319165.8A CN111831722A (zh) 2019-04-19 2019-04-19 数据同步方法及装置以及相关产品
CN201910319165.8 2019-04-19
CN201910320091.XA CN111831337B (zh) 2019-04-19 2019-04-19 数据同步方法及装置以及相关产品
CN201910320091.X 2019-04-19
CN201910341003.4A CN111857829A (zh) 2019-04-25 2019-04-25 处理器操作方法及装置以及相关产品
CN201910340177.9A CN111857828B (zh) 2019-04-25 2019-04-25 处理器操作方法及装置以及相关产品
CN201910341003.4 2019-04-25
CN201910340177.9 2019-04-25

Related Child Applications (3)

Application Number Title Priority Date Filing Date
US17/137,245 Continuation US20210150325A1 (en) 2019-04-04 2020-12-29 Data processing method and apparatus, and related product
US17/242,209 Continuation US11836491B2 (en) 2019-04-04 2021-04-27 Data processing method and apparatus, and related product for increased efficiency of tensor processing
US17/327,627 Continuation US11687339B2 (en) 2019-04-19 2021-05-21 Data processing method and apparatus, and related product

Publications (1)

Publication Number Publication Date
WO2020200244A1 true WO2020200244A1 (zh) 2020-10-08

Family

ID=72664648

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/082775 WO2020200244A1 (zh) 2019-04-04 2020-04-01 数据处理方法及装置以及相关产品

Country Status (4)

Country Link
EP (7) EP3825842B1 (zh)
JP (7) JP7073580B2 (zh)
KR (7) KR102569336B1 (zh)
WO (1) WO2020200244A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115577760A (zh) * 2021-07-14 2023-01-06 华为技术有限公司 一种数据处理方法、系统及相关设备

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20240127107A1 (en) * 2022-10-14 2024-04-18 Microsoft Technology Licensing, Llc Program accelerators with multidimensional nested command structures
KR102640910B1 (ko) * 2023-08-11 2024-02-23 리벨리온 주식회사 인공지능 연산과 연관된 데이터 복구 방법 및 시스템

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107347253A (zh) * 2015-02-25 2017-11-14 米雷普里卡技术有限责任公司 用于专用处理器的硬件指令生成单元
WO2018217360A1 (en) * 2017-05-24 2018-11-29 Microsoft Technology Licensing, Llc Tensor register files
CN109522052A (zh) * 2018-11-27 2019-03-26 北京中科寒武纪科技有限公司 一种计算装置及板卡
CN109543832A (zh) * 2018-11-27 2019-03-29 北京中科寒武纪科技有限公司 一种计算装置及板卡

Family Cites Families (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63311450A (ja) * 1987-06-12 1988-12-20 Fujitsu Ltd ファイルアクセス排他制御方式
JPH0353320A (ja) * 1989-07-21 1991-03-07 Nec Corp マイクロプログラム制御方式
JP2643110B2 (ja) * 1991-06-03 1997-08-20 日本電気株式会社 補助記憶装置を利用した連立1次方程式の解の高速計算方式
EP0663083B1 (en) * 1992-09-29 2000-12-20 Seiko Epson Corporation System and method for handling load and/or store operations in a superscalar microprocessor
US6292879B1 (en) * 1995-10-25 2001-09-18 Anthony S. Fong Method and apparatus to specify access control list and cache enabling and cache coherency requirement enabling on individual operands of an instruction of a computer
US6023530A (en) * 1995-11-13 2000-02-08 Applied Intelligent Systems, Inc. Vector correlation system for automatically locating patterns in an image
JP4227218B2 (ja) * 1997-04-30 2009-02-18 キヤノン株式会社 動的メモリ管理装置及びその制御方法
US6212628B1 (en) * 1998-04-09 2001-04-03 Teranex, Inc. Mesh connected computer
US6192384B1 (en) * 1998-09-14 2001-02-20 The Board Of Trustees Of The Leland Stanford Junior University System and method for performing compound vector operations
US6662280B1 (en) * 1999-11-10 2003-12-09 Advanced Micro Devices, Inc. Store buffer which forwards data based on index and optional way match
JP4355878B2 (ja) 2000-03-01 2009-11-04 日立建機株式会社 クローラ式車両のトラックフレーム
JP4060639B2 (ja) * 2002-05-15 2008-03-12 日本電信電話株式会社 データ管理装置
JP3646137B2 (ja) * 2003-03-25 2005-05-11 独立行政法人科学技術振興機構 命令発行方法及び装置、中央演算装置、命令発行プログラム及びそれを記憶したコンピュータ読み取り可能な記憶媒体
US8443169B2 (en) * 2005-03-28 2013-05-14 Gerald George Pechanek Interconnection network connecting operation-configurable nodes according to one or more levels of adjacency in multiple dimensions of communication in a multi-processor and a neural processor
US10547698B2 (en) * 2006-11-08 2020-01-28 Cricket Media, Inc. Dynamic characterization of nodes in a semantic network for desired functions such as search, discovery, matching, content delivery, and synchronization of activity and information
US7930504B2 (en) * 2008-02-01 2011-04-19 International Business Machines Corporation Handling of address conflicts during asynchronous memory move operations
US20100325395A1 (en) * 2009-06-19 2010-12-23 Doug Burger Dependence prediction in a memory system
KR101270763B1 (ko) * 2011-02-21 2013-06-03 서울대학교산학협력단 재구성형 프로세싱 어레이 구조 생성 방법
EP2929434B1 (en) * 2012-12-06 2019-01-16 Coherent Logix Incorporated Processing system with synchronization instruction
US9710150B2 (en) * 2014-01-07 2017-07-18 Qualcomm Incorporated System and method for context-based touch processing
WO2016040666A1 (en) * 2014-09-10 2016-03-17 Amazon Technologies, Inc. Scalable log-based transaction management
DK3812900T3 (da) * 2016-12-31 2024-02-12 Intel Corp Systemer, fremgangsmåder og apparater til heterogen beregning
US10387298B2 (en) * 2017-04-04 2019-08-20 Hailo Technologies Ltd Artificial neural network incorporating emphasis and focus techniques
WO2018193354A1 (en) * 2017-04-17 2018-10-25 Cerebras Systems Inc. Wavelet representation for accelerated deep learning
US10817293B2 (en) * 2017-04-28 2020-10-27 Tenstorrent Inc. Processing core with metadata actuated conditional graph execution
US10248908B2 (en) * 2017-06-19 2019-04-02 Google Llc Alternative loop limits for accessing data in multi-dimensional tensors
JP6870527B2 (ja) * 2017-08-04 2021-05-12 富士通株式会社 部品見積もりプログラム、部品見積もりシステム及び部品見積もり方法
GB2568776B (en) * 2017-08-11 2020-10-28 Google Llc Neural network accelerator with parameters resident on chip
CN108364065B (zh) 2018-01-19 2020-09-11 上海兆芯集成电路有限公司 采布斯乘法的微处理器

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107347253A (zh) * 2015-02-25 2017-11-14 米雷普里卡技术有限责任公司 用于专用处理器的硬件指令生成单元
WO2018217360A1 (en) * 2017-05-24 2018-11-29 Microsoft Technology Licensing, Llc Tensor register files
CN109522052A (zh) * 2018-11-27 2019-03-26 北京中科寒武纪科技有限公司 一种计算装置及板卡
CN109543832A (zh) * 2018-11-27 2019-03-29 北京中科寒武纪科技有限公司 一种计算装置及板卡

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
NIGHT LEE: "CUDNN Study Notes (2)", 26 February 2018 (2018-02-26), pages 1 - 5, XP055740415, Retrieved from the Internet <URL:https://yq.aliyun.com/articles/497075> *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115577760A (zh) * 2021-07-14 2023-01-06 华为技术有限公司 一种数据处理方法、系统及相关设备

Also Published As

Publication number Publication date
EP3825848A1 (en) 2021-05-26
JP7121100B2 (ja) 2022-08-17
KR102522416B1 (ko) 2023-04-14
JP7121102B2 (ja) 2022-08-17
KR20210002518A (ko) 2021-01-08
JP7073580B2 (ja) 2022-05-23
KR102519470B1 (ko) 2023-04-06
EP3825847A1 (en) 2021-05-26
JP7121101B2 (ja) 2022-08-17
JP7239547B2 (ja) 2023-03-14
JP7150802B2 (ja) 2022-10-11
KR20210002743A (ko) 2021-01-08
EP3800547A4 (en) 2022-03-23
JP2021140744A (ja) 2021-09-16
KR20210003932A (ko) 2021-01-12
KR20210002744A (ko) 2021-01-08
KR102550451B1 (ko) 2023-06-30
EP3825842B1 (en) 2023-09-06
KR20210002741A (ko) 2021-01-08
JP2021120847A (ja) 2021-08-19
KR102379406B1 (ko) 2022-03-25
JP2021120848A (ja) 2021-08-19
EP3825842A1 (en) 2021-05-26
KR20210002742A (ko) 2021-01-08
EP3825846A1 (en) 2021-05-26
JP2021520591A (ja) 2021-08-19
JP2021140745A (ja) 2021-09-16
KR102569336B1 (ko) 2023-08-21
EP3825847B1 (en) 2022-05-11
EP3825843A1 (en) 2021-05-26
KR20210003931A (ko) 2021-01-12
EP3828698B1 (en) 2022-07-20
EP3825843B1 (en) 2022-11-30
JP2021170312A (ja) 2021-10-28
EP3800547A1 (en) 2021-04-07
EP3828698A1 (en) 2021-06-02
KR102579192B1 (ko) 2023-09-14
JP2021120849A (ja) 2021-08-19

Similar Documents

Publication Publication Date Title
WO2020200244A1 (zh) 数据处理方法及装置以及相关产品
US20210150325A1 (en) Data processing method and apparatus, and related product
CN111857828B (zh) 处理器操作方法及装置以及相关产品
US20240111536A1 (en) Data processing apparatus and related products
CN111782274B (zh) 数据处理装置及相关产品
CN111783992A (zh) 数据处理装置及相关产品
CN111857829A (zh) 处理器操作方法及装置以及相关产品

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2021510522

Country of ref document: JP

Kind code of ref document: A

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

Ref document number: 20783678

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020783678

Country of ref document: EP

Effective date: 20201228

NENP Non-entry into the national phase

Ref country code: DE