Extended execution method, device, equipment and storage medium of AI instructions

By obtaining the extended AI instruction sequence pre-configured by the user, using the AI ​​instruction configuration information in general registers and local internal registers, the problem of high instruction cache miss rate in AI calculations is solved, and the computing efficiency is improved.

CN119376793BActive Publication Date: 2025-08-26太初(无锡)电子科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411943369.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-08-26
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

Due to the limited bit width of AI instruction, the instruction cache miss rate in AI calculations increases and the calculation efficiency is reduced.

Method used

By obtaining the user-configured extended AI instruction sequence, using the AI ​​instruction configuration information in general registers and local internal registers, the extended AI instructions are executed to reduce the instruction cache miss rate.

Benefits of technology

Improve the efficiency of AI computing, and by extending the combination of AI instructions and registers, it accommodates more AI instruction configuration information, reducing the instruction cache miss rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376793B_ABST
    Figure CN119376793B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose an extended execution method, apparatus, device, and storage medium for AI instructions. The method includes: obtaining an extended AI instruction sequence pre-configured by the user, and executing the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence; when executing any extended AI instruction, calling the pre-stored AI instruction configuration information from the general register or the local internal register according to the instruction addressing information of the target field in the extended AI instruction; and executing the corresponding AI instruction according to the AI ​​instruction configuration information. Based on this, with the help of extended AI instructions as well as general registers and local internal registers, a 32-bit instruction can accommodate more AI instruction configuration information, thereby reducing the miss rate of the instruction cache and improving computing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of AI algorithm execution technology, and in particular to an extended execution method, apparatus, device, and storage medium for AI instructions. Background Art

[0002] With the rapid development of artificial intelligence (AI) technology, RISC-V has become an ideal choice for AI chips due to its openness, flexibility, and high scalability. RISC-V supports user-defined instruction set extensions, allowing chip designers to customize AI accelerators to meet the rapidly changing demands of AI workloads while improving the performance and efficiency of AI computing.

[0003] When performing AI calculations, matrix acceleration instructions are usually used to achieve higher data reuse and reduce memory bandwidth requirements. However, due to the limited bit width of AI instructions, multiple AI loading and calculation instructions are required to achieve larger-scale matrix calculations. The increase in the number of required instructions will lead to an increase in the miss rate of the instruction cache and a decrease in computing efficiency. Summary of the Invention

[0004] Embodiments of the present application provide an extended execution method, apparatus, device, and storage medium for AI instructions to reduce the miss rate of the instruction cache and improve computing efficiency.

[0005] In a first aspect, an embodiment of the present application provides a method for extending execution of an AI instruction, the method comprising:

[0006] Obtaining an extended AI instruction sequence pre-configured by the user, and executing the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence;

[0007] When any extended AI instruction is executed, the pre-stored AI instruction configuration information is called from the general register or the local internal register according to the instruction address information of the target field in the extended AI instruction;

[0008] Execute the corresponding AI command according to the AI ​​command configuration information;

[0009] According to the instruction address information of the target field in the extended AI instruction, the pre-stored AI instruction configuration information is called from the general register or the local internal register, including:

[0010] Obtaining the index address in the first target field and the field value in the second target field;

[0011] If the field value is the first preset field value, calling the pre-stored AI instruction configuration information from the index address of the general register;

[0012] If the field value is the second preset field value, the pre-stored AI instruction configuration information is called from the index address of the local internal register.

[0013] Furthermore, the method further comprises:

[0014] Obtain the user's instruction configuration information, which includes multiple instruction information and sequence information. Each instruction information includes instruction type and field configuration information;

[0015] For any instruction information, obtain the extended AI instruction template corresponding to the instruction type, and fill the field configuration information into the extended AI instruction template to obtain the extended AI instruction corresponding to the instruction information;

[0016] The extended AI instructions are sorted according to the sequence information to obtain an extended AI instruction sequence.

[0017] Furthermore, the method further comprises:

[0018] Each time an instruction is executed, the instruction is parsed. If the parsed instruction is an extended AI instruction, it is determined that any extended AI instruction is executed.

[0019] Furthermore, the extended AI instructions are executed asynchronously by the AI ​​accelerator.

[0020] Furthermore, the method further comprises:

[0021] During execution of any extended AI instruction, if a preset target operation is performed, obtaining the field value of the third target field in the extended AI instruction and the target register address in the fourth target field;

[0022] If the field value of the third target field is the third preset field value, determining the general register as the target register;

[0023] If the field value of the third target field is the fourth preset field value, determining the local internal register as the target register;

[0024] Performs the preset target operation based on the target register address.

[0025] Furthermore, the preset target operation is an operation of writing an answer word.

[0026] In a second aspect, an embodiment of the present application provides an extended execution device for AI instructions, the device comprising:

[0027] A first execution module is configured to obtain an extended AI instruction sequence pre-configured by a user and execute the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence;

[0028] A calling module, configured to call pre-stored AI instruction configuration information from a general register or a local internal register according to instruction addressing information of a target field in the extended AI instruction when any extended AI instruction is executed;

[0029] A second execution module, configured to execute corresponding AI instructions according to the AI ​​instruction configuration information;

[0030] The calling module is specifically used to:

[0031] Obtaining the index address in the first target field and the field value in the second target field;

[0032] If the field value is the first preset field value, calling the pre-stored AI instruction configuration information from the index address of the general register;

[0033] If the field value is the second preset field value, the pre-stored AI instruction configuration information is called from the index address of the local internal register.

[0034] In a third aspect, an embodiment of the present application further provides an electronic device, the electronic device comprising:

[0035] one or more processors;

[0036] a storage device for storing one or more programs,

[0037] When one or more programs are executed by one or more processors, the one or more processors implement the extended execution method of the AI ​​instructions provided in any embodiment of the present application.

[0038] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, characterized in that when the program is executed by a processor, an extended execution method of the AI ​​instruction provided in any embodiment of the present application is implemented.

[0039] The technical solution of the embodiments of the present application obtains a user-preconfigured extended AI instruction sequence and executes the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence. When any extended AI instruction is executed, the pre-stored AI instruction configuration information is called from a general register or a local internal register based on the instruction address information of the target field in the extended AI instruction. The corresponding AI instruction is then executed according to the AI ​​instruction configuration information. Based on this, by utilizing the extended AI instructions, general registers, and local internal registers, a 32-bit instruction can accommodate more AI instruction configuration information, thereby reducing the instruction cache miss rate and improving computing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1This is a flowchart of the extended execution method of the AI ​​instruction provided in Example 1 of the present application.

[0041] Figure 2 This is a structural diagram of an extended execution device for AI instructions provided in Example 2 of the present application.

[0042] Figure 3 This is a structural diagram of an electronic device provided in Example 3 of the present application.

[0043] Figure 4 A schematic diagram of an extended AI instruction bit field provided in Example 1 of the present application. DETAILED DESCRIPTION

[0044] The present application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are intended only to illustrate the present application and are not intended to limit the present application. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions of the present application, not all of the structures.

[0045] Example 1:

[0046] Figure 1 This is a flow chart of the extended execution method of the AI ​​instruction provided in Example 1 of this application, as shown in FIG. Figure 1 As shown, the extended execution method of AI instructions provided in this embodiment can be applied to an extended execution platform of AI instructions on a device with data processing capabilities such as a computer, and can be used with some application software to achieve a better experience. Specifically, the method may include the following steps:

[0047] Step 101: Acquire an extended AI instruction sequence pre-configured by a user, and execute the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence.

[0048] In this step, the extended AI instruction sequence includes multiple extended AI instructions with an execution order. When configuring and generating the extended AI instruction sequence, the user's instruction configuration information can be obtained first. The instruction configuration information includes multiple instruction information and sequence information. Each instruction information includes instruction type and field configuration information.

[0049] Then, for any instruction information, obtain the extended AI instruction template corresponding to the instruction type, and fill the field configuration information into the extended AI instruction template to obtain the extended AI instruction corresponding to the instruction information; sort each extended AI instruction according to the sequence information to obtain the extended AI instruction sequence.

[0050] There are multiple types of instructions. In a specific example, there may be a configuration instruction (CFG), a load operand A instruction (LDA), a load operand B instruction (LDB), a write back instruction (ST), and a continuous load instruction (CTN).

[0051] In general registers and local internal registers, the functions that can be configured by each instruction type can be configured through the set instruction. Each function can exist in the register in the form of AI instruction configuration information.

[0052] Specifically, CFG (configuration command), by sending this command, can achieve:

[0053] (1) You can configure whether to enable the sparsification acceleration function when loading data.

[0054] (2) The precision of the input data can be configured, including but not limited to FP64, FP32, FP16, BF16, FP8, etc.

[0055] (3) You can configure whether to enable the fast format conversion function, that is, no calculation is performed, and only the precision conversion of the input data is performed. When fast format conversion is enabled, operand B does not need to be loaded.

[0056] (4) When the precision is FP8, the data format can be configured as E4M3 or E5M2.

[0057] (5) The rounding mode for dot product and accumulation operations of floating-point operands can be configured.

[0058] LDA (Load Operand A) is a command that loads operand A from the local storage unit and implements:

[0059] (1) The starting address of the instruction when accessing the local storage component can be configured.

[0060] (2) You can configure how many operands A the instruction loads.

[0061] (3) The address stride mode of this instruction can be configured. If more than one data is loaded, the hardware will automatically calculate the subsequent addresses. It supports zero address stride, non-zero address stride, and two-dimensional address stride.

[0062] (4) You can configure whether to perform a PADDING (zero padding) operation when loading operand A.

[0063] (5) The mask used by this instruction when loading operand A can be configured. The width of the loaded vector is determined by the hardware design and is not configurable. By using the mask, excess data can be set to zero to prevent it from contaminating the dot product result.

[0064] (6) You can configure whether the instruction writes a reply word and the address of the reply word.

[0065] (7) You can configure whether this instruction performs cumulative calculations on the dot product results.

[0066] LDB (Load Operand B) is a command that loads operand B from the local storage unit and implements:

[0067] (1) The starting address of the instruction when accessing the local storage component can be configured.

[0068] (2) The address stride mode of this instruction can be configured. If more than one data is loaded, the hardware will automatically calculate the subsequent addresses. It supports zero address stride, non-zero address stride, and one-dimensional stride.

[0069] (3) It is configurable whether to perform a transposition operation on operand B when the instruction loads it.

[0070] (4) The mask used by this instruction when loading operand B can be configured. The width of the loaded vector is determined by the hardware design and is not configurable. By using the mask, excess data can be set to zero to prevent it from contaminating the dot product result.

[0071] (5) You can configure whether the instruction writes a reply word and the address of the reply word.

[0072] ST (write back instruction), by sending this instruction, the accumulated result can be written back to the local storage component and achieve:

[0073] (1) The precision of the calculation result written back by this instruction can be configured, including but not limited to FP64, FP32, FP16, BF16, FP8, INT32, etc.

[0074] (2) You can configure whether the instruction performs scaling / offset operations on the accumulated results.

[0075] (3) You can configure how this instruction loads the offset coefficients and scales sparsity.

[0076] (4) You can configure whether the calculation result written back by this instruction supports non-reducible numbers.

[0077] (5) You can configure how to handle overflow when the calculation result written back by this instruction exceeds the precision representation range.

[0078] (6) You can configure whether to enable the absolute maximum value statistics of the write-back result for this instruction.

[0079] (7) You can configure whether the instruction writes back the absolute maximum value and the write-back address.

[0080] (8) You can configure how many calculation results the instruction writes back, which entry in the accumulation result buffer 0 / 1 the calculation result is, and whether the buffer is cleared after the accumulation result is taken out.

[0081] (9) The starting address of this instruction when it is written back to the local storage component can be configured.

[0082] (10) The address stride mode of this instruction can be configured. If more than one data is loaded, the hardware will automatically calculate the subsequent addresses. It supports zero address stride, non-zero address stride, and one-dimensional stride.

[0083] (11) The address of the reply word written by this instruction can be configured.

[0084] CTN: (Continuous Load Instruction), by sending this instruction, you can notify the hardware to automatically execute LDA and LDB instructions multiple times, and LDA and LDB can also be configured with the multiple functions mentioned above.

[0085] In addition, the extended AI instruction fields can be found in Figure 4 , Figure 4 A schematic diagram of an extended AI instruction bit field provided in Example 1 of the present application.

[0086] like Figure 4 As shown, xs1 / xs2 indicate the source register type: the present invention uses two source registers, an internal register and a general-purpose register. These registers store specific instruction configuration information, rs2 and rs1, for AI calculations, respectively. When xs1 / xs2 is 0, instruction information rs2 is fetched from the internal register; when it is 1, instruction information rs1 is fetched from the general-purpose register. rs1 / rs2 indicate the source register index address: rs1 corresponds to the index address of the xs2 register, and rs2 corresponds to the index address of the xs1 register.

[0087] xd indicates the type of target register: xd = 1 indicates a target operation on a general register, and xd = 0 indicates a target operation on an internal register, which is usually a write to the answer word. rd indicates the address of the target register.

[0088] funct7 is used to indicate the function corresponding to the instruction: in the present invention, all AI instructions are set to the same fixed value.

[0089] In addition, this embodiment may set the operation code (opcode) to a custom operation code to avoid conflicts with future standard extensions.

[0090] It should be noted that an extended AI instruction template can be set for each instruction type. The extended AI instruction template can be set to a specific extended AI instruction that is most commonly used for that instruction type, so as to speed up the user's configuration of instruction sequences in common scenarios.

[0091] The functions of each of the above instruction types are implemented using existing traditional AI instructions. The specific implementation methods can be referenced in related technologies and will not be detailed here. The user pre-populates the instruction configuration information corresponding to each function into a general register or a local internal register using the set instruction. This allows the user to directly access the instruction configuration information of the corresponding function through addressing during subsequent execution, thereby implementing the function.

[0092] In addition, in this embodiment, each time an instruction is executed, the instruction is parsed. If the parsed instruction is an extended AI instruction, it is determined that any extended AI instruction has been executed. Since the funct7 field is set to a fixed value, if the funct7 field of the instruction parsed is the fixed value, it can be determined that the instruction is an extended AI instruction.

[0093] Step 102: When any extended AI instruction is executed, pre-stored AI instruction configuration information is called from a general register or a local internal register according to instruction addressing information of a target field in the extended AI instruction.

[0094] In this step, the index address in the first target field and the field value in the second target field can be obtained; if the field value is the first preset field value, the pre-stored AI instruction configuration information is called from the index address of the general register; if the field value is the second preset field value, the pre-stored AI instruction configuration information is called from the index address of the local internal register.

[0095] The first target field may be xs1 / xs2 in the aforementioned specific example, and the second target field may be rs1 / rs2 in the aforementioned specific example. Based on these two fields, the AI ​​instruction configuration information corresponding to the extended AI instruction can be obtained from the register.

[0096] In addition, the extended AI instructions are executed asynchronously by the AI ​​accelerator. That is, when the extended AI instruction is executed, the subsequent steps can be handed over to the AI ​​accelerator.

[0097] Step 103: Execute the corresponding AI instruction according to the AI ​​instruction configuration information.

[0098] In this step, the AI ​​instruction configuration information includes AI instruction information that can realize a certain function, which can be a specific code, code block, etc. By executing the code or code block, the function can be realized.

[0099] In addition, during the execution of any extended AI instruction, if a preset target operation is performed, the field value of the third target field in the extended AI instruction and the target register address in the fourth target field are obtained; if the field value of the third target field is the third preset field value, the general register is determined as the target register; if the field value of the third target field is the fourth preset field value, the local internal register is determined as the target register; and the preset target operation is performed based on the target register address.

[0100] The third target field may be xd, and the fourth target field may be rd. The preset target operation may be a write reply word operation. If the AIE completes executing the current instruction, it may initiate a write reply word request to an internal register or local storage component to notify the user that the asynchronous event is complete.

[0101] To further illustrate the extended execution process in this embodiment, the convolution algorithm may be used as an example for illustration:

[0102] Initial configuration is performed using CFG. Then, before calculation, weight vectors (e.g., vectors B0-B31) are loaded using the LDB instruction, pre-loading them into the dot product array. Data from the same location on multiple convolution kernels can be placed into the dot product array. The number of loaded vectors corresponds to the number of dot product units in the dot product array, determined by the hardware design.

[0103] Then load several eigenvalue vectors (such as vectors A0~A127) through the LDA instruction.

[0104] The first step in LDA is to wait for the weight vector to be loaded before placing vector A0 into the dot product array. At this point, without requiring a compute instruction, the AIE automatically performs the dot product calculation of all weight vectors with the eigenvalue vector A0. If accumulation is enabled in LDA, the hardware adds the dot product result to the data in the accumulation buffer and stores the result in the accumulation buffer. Otherwise, the hardware directly stores the dot product result in the accumulation buffer.

[0105] The second step of LDA involves placing vector A1 into the dot product array. AIE automatically performs the same computational operations as in the first step. Similarly, an LDA can load multiple eigenvalue vectors, perform multiple dot products, and perform accumulation operations. Furthermore, all loaded eigenvalue vectors can be mapped into the input feature map.

[0106] The ST instruction can be used to retrieve the accumulated result from the accumulated result buffer, scale / offset it according to the configuration, and convert the output format before writing the result back to the storage component. If the ST instruction has statistics and write back the absolute maximum value enabled, the absolute maximum value of the calculated result can also be written back to the local storage component.

[0107] In addition, based on the method of this embodiment, several instruction sequences can be given to achieve different purposes:

[0108] Sequence 1: CFG→CTN→ST, automatically configures multiple LDB / LDA operations, allowing the hardware to implement larger-scale dot product operations.

[0109] Sequence 2: LDB→LDA→LDA→LDA→ST, loading a large number of eigenvalues ​​while reusing weight values.

[0110] Sequence three: CFG→LDA→ST, turns on fast format conversion and transcendental function mode. At this time, there is no need to load OPB, and DPA automatically assigns values ​​to OPB.

[0111] In this embodiment, a user-preconfigured extended AI instruction sequence is obtained and executed according to the extended AI instruction sequence. When any extended AI instruction is executed, pre-stored AI instruction configuration information is retrieved from a general register or a local internal register based on the instruction address information of the target field in the extended AI instruction. The corresponding AI instruction is then executed based on the AI ​​instruction configuration information. Based on this, by utilizing the extended AI instructions, general registers, and local internal registers, a 32-bit instruction can accommodate more AI instruction configuration information, thereby reducing the instruction cache miss rate and improving computing efficiency.

[0112] Example 2:

[0113] Figure 2 This is a structural diagram of an extended execution device for an AI instruction provided in Example 2 of this application. The extended execution device for an AI instruction provided in this embodiment of the application can execute the extended execution method for an AI instruction provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects of the execution method. The device can be implemented in software and / or hardware, such as Figure 2 As shown, the extended execution device of the AI ​​instruction specifically includes: a first execution module 201, a calling module 202, and a second execution module 203.

[0114] The first execution module is configured to obtain an extended AI instruction sequence pre-configured by a user and execute the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence;

[0115] A calling module, configured to call pre-stored AI instruction configuration information from a general register or a local internal register according to instruction addressing information of a target field in the extended AI instruction when any extended AI instruction is executed;

[0116] The second execution module is used to execute the corresponding AI instruction according to the AI ​​instruction configuration information.

[0117] Example 3:

[0118] Figure 3 This is a structural diagram of an electronic device provided in Example 3 of the present application, such as Figure 3 As shown, the electronic device includes a processor 310, a memory 320, an input device 330 and an output device 340; the number of processors 310 in the electronic device can be one or more. Figure 3 In the figure, a processor 310 is used as an example; the processor 310, memory 320, input device 330 and output device 340 in the electronic device can be connected via a bus or other means. Figure 3 The bus connection is taken as an example.

[0119] The memory 320, as a computer-readable storage medium, can be used to store software programs, computer executable programs, and modules, such as the program instructions / modules corresponding to the extended execution method of AI instructions in the embodiments of the present invention. The processor 310 executes the software programs, instructions, and modules stored in the memory 320 to execute various functional applications and data processing of the electronic device, that is, to implement the extended execution method of AI instructions described above:

[0120] Obtaining an extended AI instruction sequence pre-configured by the user, and executing the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence;

[0121] When any extended AI instruction is executed, the pre-stored AI instruction configuration information is called from the general register or the local internal register according to the instruction address information of the target field in the extended AI instruction;

[0122] Execute the corresponding AI command according to the AI ​​command configuration information.

[0123] Furthermore, the method further comprises:

[0124] Obtain the user's instruction configuration information, which includes multiple instruction information and sequence information. Each instruction information includes instruction type and field configuration information;

[0125] For any instruction information, obtain the extended AI instruction template corresponding to the instruction type, and fill the field configuration information into the extended AI instruction template to obtain the extended AI instruction corresponding to the instruction information;

[0126] The extended AI instructions are sorted according to the sequence information to obtain an extended AI instruction sequence.

[0127] Furthermore, the method further comprises:

[0128] Each time an instruction is executed, the instruction is parsed. If the parsed instruction is an extended AI instruction, it is determined that any extended AI instruction is executed.

[0129] Furthermore, according to the instruction address information of the target field in the extended AI instruction, the pre-stored AI instruction configuration information is called from the general register or the local internal register, including:

[0130] Obtaining the index address in the first target field and the field value in the second target field;

[0131] If the field value is the first preset field value, calling the pre-stored AI instruction configuration information from the index address of the general register;

[0132] If the field value is the second preset field value, the pre-stored AI instruction configuration information is called from the index address of the local internal register.

[0133] Furthermore, the extended AI instructions are executed asynchronously by the AI ​​accelerator.

[0134] Furthermore, the method further comprises:

[0135] During execution of any extended AI instruction, if a preset target operation is performed, obtaining the field value of the third target field in the extended AI instruction and the target register address in the fourth target field;

[0136] If the field value of the third target field is the third preset field value, determining the general register as the target register;

[0137] If the field value of the third target field is the fourth preset field value, determining the local internal register as the target register;

[0138] Performs the preset target operation based on the target register address.

[0139] Furthermore, the preset target operation is an operation of writing an answer word.

[0140] The memory 320 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal, etc. Furthermore, the memory 320 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 320 may further include a memory remotely located relative to the processor 310, and these remote memories may be connected to the electronic device via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0141] Example 4:

[0142] The fourth embodiment of the present application further provides a storage medium containing computer-executable instructions. When the computer-executable instructions are executed by a computer processor, the computer-executable instructions are used to execute an extended execution method of an AI instruction. The method includes:

[0143] Obtaining an extended AI instruction sequence pre-configured by the user, and executing the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence;

[0144] When any extended AI instruction is executed, the pre-stored AI instruction configuration information is called from the general register or the local internal register according to the instruction address information of the target field in the extended AI instruction;

[0145] Execute the corresponding AI command according to the AI ​​command configuration information.

[0146] Furthermore, the method further comprises:

[0147] Obtain the user's instruction configuration information, which includes multiple instruction information and sequence information. Each instruction information includes instruction type and field configuration information;

[0148] For any instruction information, obtain the extended AI instruction template corresponding to the instruction type, and fill the field configuration information into the extended AI instruction template to obtain the extended AI instruction corresponding to the instruction information;

[0149] The extended AI instructions are sorted according to the sequence information to obtain an extended AI instruction sequence.

[0150] Furthermore, the method further comprises:

[0151] Each time an instruction is executed, the instruction is parsed. If the parsed instruction is an extended AI instruction, it is determined that any extended AI instruction is executed.

[0152] Furthermore, according to the instruction address information of the target field in the extended AI instruction, the pre-stored AI instruction configuration information is called from the general register or the local internal register, including:

[0153] Obtaining the index address in the first target field and the field value in the second target field;

[0154] If the field value is the first preset field value, calling the pre-stored AI instruction configuration information from the index address of the general register;

[0155] If the field value is the second preset field value, the pre-stored AI instruction configuration information is called from the index address of the local internal register.

[0156] Furthermore, the extended AI instructions are executed asynchronously by the AI ​​accelerator.

[0157] Furthermore, the method further comprises:

[0158] During execution of any extended AI instruction, if a preset target operation is performed, obtaining the field value of the third target field in the extended AI instruction and the target register address in the fourth target field;

[0159] If the field value of the third target field is the third preset field value, determining the general register as the target register;

[0160] If the field value of the third target field is the fourth preset field value, determining the local internal register as the target register;

[0161] Performs the preset target operation based on the target register address.

[0162] Furthermore, the preset target operation is an operation of writing an answer word.

[0163] Of course, the storage medium containing computer-executable instructions provided in the embodiments of the present application is not limited to the above method operations, and can also execute related operations in the extended execution method of the AI ​​instructions provided in any embodiment of the present application.

[0164] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present application can be implemented with the help of software and necessary general-purpose hardware. Of course, it can also be implemented with hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the existing technology, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.

[0165] It is worth noting that in the embodiment of the above-mentioned search device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.

[0166] Note that the above are only preferred embodiments of the present application and the technical principles employed. Those skilled in the art will understand that the present application is not limited to the specific embodiments herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments and may include many other equivalent embodiments without departing from the scope of the present application. The scope of the present application is determined by the scope of the appended claims.

Claims

1. A method for extending the execution of AI instructions, characterized in that: The method comprises: Acquire an extended AI instruction sequence pre-configured by a user, and execute the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence; When any of the extended AI instructions is executed, calling pre-stored AI instruction configuration information from a general register or a local internal register according to instruction addressing information of a target field in the extended AI instruction; Execute the corresponding AI instruction according to the AI ​​instruction configuration information; The calling of pre-stored AI instruction configuration information from a general register or a local internal register according to the instruction addressing information of the target field in the extended AI instruction includes: Obtaining the index address in the first target field and the field value in the second target field; If the field value is a first preset field value, calling pre-stored AI instruction configuration information from the index address of the general register; If the field value is a second preset field value, calling pre-stored AI instruction configuration information from the index address of the local internal register; Obtaining the user's instruction configuration information, wherein the instruction configuration information includes multiple instruction information and sequence information, and each instruction information includes an instruction type and field configuration information; For any instruction information, obtain the extended AI instruction template corresponding to the instruction type, and fill the field configuration information into the extended AI instruction template to obtain the extended AI instruction corresponding to the instruction information; The extended AI instructions are sorted according to the sequence information to obtain an extended AI instruction sequence.

2. The method according to claim 1, characterized in that The method further comprises: Each time an instruction is executed, the instruction is parsed. If the instruction is parsed as an extended AI instruction, it is determined that any of the extended AI instructions has been executed.

3. The method according to claim 1, characterized in that The extended AI instructions are asynchronously executed by the AI ​​accelerator.

4. The method according to claim 1, wherein The method further comprises: During execution of any of the extended AI instructions, if a preset target operation is performed, obtaining a field value of a third target field and a target register address in a fourth target field in the extended AI instruction; If the field value of the third target field is a third preset field value, determining the general register as the target register; If the field value of the third target field is the fourth preset field value, determining the local internal register as the target register; The preset target operation is performed based on the target register address.

5. The method according to claim 4, characterized in that The preset target operation is an operation of writing an answer word.

6. An extended execution device for AI instructions, characterized in that: The device comprises: A first execution module is configured to obtain an extended AI instruction sequence pre-configured by a user, and execute the extended AI instructions in the extended AI instruction sequence according to the extended AI instruction sequence; a calling module, configured to call pre-stored AI instruction configuration information from a general register or a local internal register according to instruction addressing information of a target field in the extended AI instruction when any of the extended AI instructions is executed; A second execution module, configured to execute the corresponding AI instruction according to the AI ​​instruction configuration information; The calling module is specifically used for: Obtaining the index address in the first target field and the field value in the second target field; If the field value is a first preset field value, calling pre-stored AI instruction configuration information from the index address of the general register; If the field value is a second preset field value, calling pre-stored AI instruction configuration information from the index address of the local internal register; The device is specifically used for: Obtaining the user's instruction configuration information, wherein the instruction configuration information includes multiple instruction information and sequence information, and each instruction information includes an instruction type and field configuration information; For any instruction information, obtain the extended AI instruction template corresponding to the instruction type, and fill the field configuration information into the extended AI instruction template to obtain the extended AI instruction corresponding to the instruction information; The extended AI instructions are sorted according to the sequence information to obtain an extended AI instruction sequence.

7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the extended execution method of the AI ​​instruction as described in any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the extended execution method of the AI ​​instruction as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Batched instruction parsing method, batched instruction parsing apparatus and batched instruction parsing device

    CN108804140A

  • Gateway instruction conversion method and apparatus, and electronic device

    CN116170254A