CN116028062A - Target code generation method, NPU instruction display method and device - Google Patents

Target code generation method, NPU instruction display method and device Download PDF

Info

Publication number
CN116028062A
CN116028062A CN202310043431.5A CN202310043431A CN116028062A CN 116028062 A CN116028062 A CN 116028062A CN 202310043431 A CN202310043431 A CN 202310043431A CN 116028062 A CN116028062 A CN 116028062A
Authority
CN
China
Prior art keywords
instruction
target
field
type
npu
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202310043431.5A
Other languages
Chinese (zh)
Inventor
陆天翼
梁爽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Chaoxing Future Technology Co ltd
Original Assignee
Beijing Chaoxing Future Technology Co ltd
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
Application filed by Beijing Chaoxing Future Technology Co ltd filed Critical Beijing Chaoxing Future Technology Co ltd
Publication of CN116028062A publication Critical patent/CN116028062A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application provides a target code generation method, an NPU instruction display method and an NPU instruction display device. The method for generating the target code comprises the following steps: analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field, establishing a first type mapping relation between each instruction field and functions in an initial code according to a first preset order, receiving a first type target value corresponding to each instruction field input by a user, and writing the first type target value into the initial code based on the first type mapping relation and the field attributes of the preset types to obtain a target code. According to the method, the NPU instruction is subjected to abstract representation to obtain the target NPU instruction, the code for assembling and analyzing the instruction can be automatically generated through the method for generating the target code, the code for assembling and analyzing the instruction does not need to be manually developed, the code development and maintenance are convenient, and the workload is small.

Description

Target code generation method, NPU instruction display method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method for generating an object code, and a method and device for displaying an NPU instruction.
Background
The neural network processor instruction (Neural network Processing Unit, NPU for short) is code that performs a particular operation within the NPU chip. A plurality of instruction fields in an NPU instruction are used for respectively representing functions and corresponding parameters of the instruction, and positions and lengths of the instruction fields in the instruction and possibly owned fixed values can be different according to different instruction formats. The NPU instruction set is a collection of all instruction formats that can be supported by the NPU.
Regarding the generation mode of the NPU instruction, a matched instruction generation tool is mainly developed for each NPU instruction set at present, in the instruction generation tool, corresponding program codes are developed according to the format of each instruction and used for assembling instruction fields to generate specific NPU instruction codes, and the development and maintenance workload of the codes is large. In the early stage of instruction set design, the instruction set update iterates frequently, and the response speed of the corresponding instruction generating tool to the change of the instruction set is slow.
Therefore, the existing code for assembling instructions has the technical problems of inconvenient development and maintenance and large workload.
Disclosure of Invention
In order to solve the technical problems, the application provides a method for generating an object code, a method and a device for displaying an NPU instruction, and the specific scheme is as follows:
In a first aspect, an embodiment of the present application provides a method for generating an object code, where the method for generating an object code includes:
acquiring a target NPU instruction, target description data corresponding to the target NPU instruction and an initial code, wherein the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, the preset type comprises a field name, a field start bit and a bit number corresponding to the field, and the initial code comprises at least one callable function;
analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
establishing a first type mapping relation between each instruction field and the function in the initial code according to a first preset sequence;
and receiving a first type target value corresponding to each instruction field input by a user, and writing the first type target value into the initial code based on the first type mapping relation and the field attribute of the preset type to obtain a target code.
According to a specific embodiment disclosed in the present application, before the step of obtaining the target NPU instruction, the target description data corresponding to the target NPU instruction, and the initial code, the method for generating the target code further includes:
Receiving a target NPU instruction input by a user and initial description data corresponding to the target NPU instruction;
if the initial format corresponding to the initial description data is different from the preset format, converting the initial description data into target description data in the preset format.
According to a specific embodiment disclosed in the present application, the step of establishing a first type of mapping relationship between each instruction field and a function in the initial code according to a first preset order includes:
acquiring field names of all instruction fields according to a first order;
and for any instruction field, converting the field name of the instruction field into the function name in the initial code according to a preset conversion type to obtain a first type mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
In a second aspect, an embodiment of the present application provides a method for displaying an NPU instruction, where the method for displaying an NPU instruction includes:
acquiring a target NPU instruction and target description data corresponding to the target NPU instruction, wherein the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, and the preset type comprises a field start bit and a bit number corresponding to the field;
Analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
selecting a second type of display elements from a preset database according to user input, wherein the second type comprises characters, icons and colors, and each second type of display elements comprises an attribute type and an initial attribute value corresponding to the attribute type;
establishing a second type mapping relation between each instruction field and the display element according to a second preset sequence;
receiving a second type target value corresponding to each instruction field input by a user, and updating an initial attribute value of a display element corresponding to each instruction field to the second type target value based on the second type mapping relation to obtain a target NPU instruction of self-defined display;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the method for generating the target code according to any one of claims 1 to 2.
In a third aspect, an embodiment of the present application provides an apparatus for generating an object code, where the apparatus for generating an object code includes:
The system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a target NPU instruction, target description data corresponding to the target NPU instruction and initial codes corresponding to the target NPU instruction, the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, the preset type comprises a field name, a field start bit and a bit number corresponding to a field, and the initial codes comprise at least one callable function;
the analyzing module is used for analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
the mapping module is used for establishing a first type of mapping relation between each instruction field and the function in the initial code according to a first preset sequence;
and the writing module is used for receiving a first type target value corresponding to each instruction field input by a user, and writing the first type target value into the initial code based on the first type mapping relation and the field attribute of the preset type to obtain a target code.
According to a specific embodiment disclosed in the present application, the generating device of the object code further includes:
The receiving module is used for receiving a target NPU instruction input by a user and initial description data corresponding to the target NPU instruction;
and the conversion module is used for converting the initial description data into target description data in a preset format if the initial format corresponding to the initial description data is different from the preset format.
According to one embodiment disclosed in the present application, the mapping module is specifically configured to:
acquiring field names of all instruction fields according to a first order;
and for any instruction field, converting the field name of the instruction field into the function name in the initial code according to a preset conversion type to obtain a first type mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
In a fourth aspect, an embodiment of the present application provides a display device of an NPU instruction, where the display device of an NPU instruction includes:
the system comprises an acquisition module, a storage module and a control module, wherein the acquisition module is used for acquiring a target NPU instruction and target description data corresponding to the target NPU instruction, the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, and the preset type comprises a field start bit and a bit number corresponding to the field;
The analyzing module is used for analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
the selection module is used for selecting a second type of display elements from a preset database according to user input, wherein the second type comprises characters, icons and colors, and each second type of display elements comprises an attribute type and an initial attribute value corresponding to the attribute type;
the mapping module is used for establishing a second type mapping relation between each instruction field and the display element according to a second preset sequence;
the updating module is used for receiving a second type target value corresponding to each instruction field input by a user, updating an initial attribute value of a display element corresponding to each instruction field into the second type target value based on the second type mapping relation, and obtaining a target NPU instruction which is displayed in a self-defining mode;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the method for generating the target code according to any one of claims 1 to 2.
In a fifth aspect, an embodiment of the present application provides a computer device, where the computer device includes a processor and a memory, where the memory stores a computer program, where the computer program implements the method for generating the object code according to any one of the first aspect and the method for displaying the NPU instruction according to the second aspect when the computer program is executed on the processor.
In a fifth aspect, embodiments of the present application provide a computer readable storage medium storing a computer program that, when executed on a processor, implements the method for generating object code according to any one of the first aspect and the method for displaying NPU instructions according to the second aspect.
Compared with the prior art, the application has the following beneficial effects:
according to the target code generation method, the target NPU instruction is analyzed based on the target description data, at least one instruction field and a plurality of field attributes of preset types in each instruction field are obtained, a first type mapping relation between each instruction field and functions in an initial code is established according to a first preset order, first type target values corresponding to each instruction field and input by a user are received, and the first type target values are written into the initial code based on the first type mapping relation and the field attributes of the preset types, so that the target code is obtained. According to the method, the NPU instruction is subjected to abstract representation to obtain the target NPU instruction, the code for assembling and analyzing the NPU instruction can be automatically generated through the method for generating the target code, the code for assembling and analyzing the NPU instruction does not need to be manually developed, the code development and maintenance are convenient, and the workload is small.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments disclosed in the present application, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments disclosed in the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for generating an object code according to an embodiment of the present application;
fig. 2 is a schematic diagram of a data structure of an instruction and an instruction set related to a method for generating an object code according to an embodiment of the present application;
fig. 3 is a flowchart of a method for displaying an NPU instruction according to an embodiment of the present application;
FIG. 4 is a block diagram of an object code generating device according to an embodiment of the present application;
fig. 5 is a block diagram of a display device for NPU commands according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments.
The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present invention.
The terms "comprises," "comprising," "including," or any other variation thereof, are intended to cover a specific feature, number, step, operation, element, component, or combination of the foregoing, which may be used in various embodiments of the present invention, and are not intended to first exclude the presence of or increase the likelihood of one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing.
Furthermore, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and should not be construed as indicating or implying relative importance.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the invention belong. The terms (such as those defined in commonly used dictionaries) will be interpreted as having a meaning that is the same as the context of the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein in connection with the various embodiments of the invention.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The embodiments described below and features of the embodiments may be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a flowchart of a method for generating an object code according to an embodiment of the present application. As shown in fig. 1, the method for generating the object code mainly includes:
step S101, a target NPU instruction, target description data corresponding to the target NPU instruction, and an initial code are acquired, where the target NPU instruction includes at least one instruction field, each instruction field includes a plurality of field attributes of a preset type, the preset type includes a field name, a field start bit, and a number of bits corresponding to the field, and the initial code includes at least one callable function.
It should be noted that, the "target NPU instruction and the initial code corresponding to the target NPU instruction" refer to code that can be executed by the NPU as an instruction, and is generally data in binary format. While the target description data refers to "data describing the format of the NPU instruction," in other words, the description data is used to describe the NPU instruction, and is typically stored in a text file. These descriptive data cannot be executed by the NPU as instructions.
Illustrating the difference between the two:
in an NPU instruction, the value in the instruction field is deterministic. Such as a subtraction instruction, the instruction content contains explicit subtracted and subtracted values, or contains the location of these values in memory. For example, the subtraction instruction may be: 0b00011000000010000000000000000000;
in the description data of the NPU instruction, only what field is included in a certain instruction will be described, and the value of each instruction field is stored in what position in the content of one NPU instruction, without concern about the specific value of the instruction field. Also taking the subtraction instruction as an example, the NPU instruction description data indicates that there are two fields of the subtraction instruction, namely, the number of the subtracted fields and the number of the subtracted fields, where the values of the fields are located at the beginning of the bits of the subtraction instruction content, and the lengths of the fields are respectively the number of bits. For example, the target description data corresponding to the subtraction instruction may be:
Figure BDA0004051414210000061
Figure BDA0004051414210000071
The NPU instructions or NPU instruction sets used by the users are designed according to the requirements of the users or specific application scenes, and the formats of description data corresponding to the NPU instructions used by different users are different. Therefore, before generating object code from instructions, the format of description data of each instruction needs to be unified.
In specific implementation, before the step of obtaining the target NPU instruction, the target description data corresponding to the target NPU instruction, and the initial code, the method for generating the target code further includes:
receiving a target NPU instruction input by a user and initial description data corresponding to the target NPU instruction;
if the initial format corresponding to the initial description data is different from the preset format, converting the initial description data into target description data in the preset format.
Specifically, the process of converting the initial description data into the target description data in the preset format, that is, the abstract representation of the instruction, may use any existing structured file format for description and storage, such as XML, JSON, YAML format, or other self-defined file formats capable of expressing structured information in a certain rule. The data content for expressing the instruction set may be stored separately in a single file or may be part of the content of other files.
Referring to fig. 2, fig. 2 is a schematic data structure diagram of an instruction and an instruction set related to a method for generating an object code according to an embodiment of the present application. In a practical application scenario, a user typically provides an NPU instruction set, that is, a set of all instruction formats that can be supported by the NPU. Thus, not only will the default format of a single NPU instruction be described in detail below, but the overall data structure of the instruction set will also be described. The instruction format portion of the data structure may be understood as a desired preset format. In a logical association, the structure generally comprises a three-layer structure, wherein:
the first layer is the outermost layer of the abstract representation of the instruction set, and the data structure type adopted by the first layer should be capable of describing the attribute of an object, and is a common data type such as a structure body. The first layer is used to represent the instruction set itself. Wherein at least one data member should be included for describing a second layer in the abstract representation of the instruction set.
The second layer is used as a sub-level of the first layer, is used for representing the content part of the instruction set, is contained by the first layer on the logic association, and adopts a data structure type which can express clusters, and is a common data structure such as an array. The second layer is used to represent clusters in instruction format. Each element in the instruction format cluster is used to represent one instruction format, namely the target NPU instruction described above. The data type used should be capable of describing the attributes of an object, a common data type such as a structure, wherein at least some information describing an instruction format, such as instruction name, instruction length, etc., and a data member describing a third layer in the abstract representation of the instruction set should be contained in several data members.
The third layer is used as a sub-level of the second layer, and is used for representing the content part of the instruction, and is contained by the second layer on the logic association, wherein the data type adopted by the third layer is a data structure capable of expressing clusters, and is common data types such as an array. The third layer is used to represent clusters of instruction fields. Each element in the instruction field cluster is used to represent an instruction field, and the data type adopted by the instruction field cluster should be capable of describing the attribute of an object, and a common data structure such as a structural body. In its data members, a number of data members should be included for describing the start bit position of the instruction field, the number of bits occupied by the instruction field, etc. The instruction fields 1,2,..n shown in fig. 2 correspond to different instruction fields in the target NPU instruction described above, each instruction field comprising a plurality of field attributes of a preset type, the preset type comprising a field name, a field start bit, and a number of bits corresponding to the field.
Step S102, parsing the target NPU instruction based on the target description data, to obtain at least one instruction field and a plurality of field attributes of a preset type in each instruction field.
In the implementation, after the target NPU instruction is acquired, the data content of the instruction set described in the abstract representation of the instruction set can be read first, and the instruction format cluster can be resolved from the data content. Then, according to the actual use requirement or specific application scene of the user, an element can be randomly or according to the self-defined order from the instruction format cluster, and the instruction name and the instruction field cluster can be obtained from the element.
Step S103, a first type mapping relation between the instruction fields and the functions in the initial codes is established according to a first preset sequence.
The first preset sequence can be customized according to actual use requirements of users or specific application scenes.
In the implementation, for the whole NPU instruction set, the names of the initial codes for assembling the corresponding instructions can be pieced together by taking the instruction names as keywords so as to establish the mapping relation between the target NPU instruction and the initial codes, thereby being convenient for inquiring in the subsequent use process. In addition, in order to further improve convenience in the subsequent use process, the order of the instruction formats in the instruction format cluster can be used as index identification of the instruction formats. In actual use, the initial code may be understood as a class, code module, or other equivalent code organization unit.
For a single target NPU instruction, an element can be taken out from the instruction field cluster, and the field attributes of preset types such as the name of each instruction field, the initial bit position of the instruction field, the number of bits occupied by the instruction field and the like are obtained from the element. And then, establishing a first type mapping relation between each instruction field and the functions in the initial codes according to a first preset sequence. Specifically, the names of functions in other equivalent code organization units such as member methods for acquiring and setting the class of the instruction field contents, or code modules, may be patched with the instruction field names as keywords. The step of establishing a first type of mapping relationship between each instruction field and the function in the initial code according to a first preset sequence comprises the following steps:
Acquiring field names of all instruction fields according to a first order;
and for any instruction field, converting the field name of the instruction field into the function name in the initial code according to a preset conversion type to obtain a first type mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
For example, in a practical application scenario, the "conversion" process described above includes, but is not limited to:
op_code is used directly;
conversion of op_code to op code
Conversion of op_code to opCode
Conversion of op_code to op_code
Conversion of op_code to getOpCode
Also, to facilitate queries in subsequent use, the order in which the instruction fields appear in the instruction field clusters may be identified as an index to the instruction fields. In the member method or function, the initial bit position of the instruction field and the bit number of the instruction field are used as the basis for assembling the instruction field; or the initial bit position of the current instruction field and the initial bit position of the next instruction field are used as assembly basis of the current instruction field. For example, instruction "a+b=c" corresponds to 32 bits, the fixed upper 4 bits are removed, the first 7 bits of the remaining 28 bits may be defined as an address corresponding to an addend a, the second 7 bits may be defined as an address corresponding to an addend b, the third 7 bits may be defined as an address corresponding to a result c, the last 7 bits may be defined as a data type, and the like.
In particular implementations, the above steps are repeated for a particular NPU instruction or NPU instruction set until all instruction fields of the current target NPU instruction are traversed or each target NPU instruction in the current instruction set is traversed.
Step S104, receiving a first type target value corresponding to each instruction field input by a user, and writing the first type target value into the initial code based on the first type mapping relation and the field attribute of the preset type to obtain a target code.
It should be noted that, the foregoing target NPU instruction and the target description data corresponding to the target NPU instruction may be understood as a model or a formula that may be general, and in the subsequent use process, the interface of the class may be called to write a specific value by inputting a corresponding specific value, that is, "writing the first class target value into the initial code", so as to satisfy the use requirement of the user and obtain the target code in a specific application scenario.
Taking a subtraction instruction as an example, the overall flow of the above-mentioned object code generation method is as follows:
the most primitive input is an instruction set description document issued by the NPU chip designer, and part of the content can be:
subtraction instruction: instruction length 32 bits, instruction identification code 0x1. A reduced number position 21, length 7bit; a reduction position 14, length 7bit; result address location 0, length 14 bits; addition instruction: instruction length 32 bits, instruction identification code 0x2.
According to the method for generating the target code, the instructions in the instruction set are subjected to abstract modeling, so that the instruction set description document in the target format, namely the target description data, is obtained. The target description data is then used as input to a code generation tool, for example, described in a file format such as XML, JSON, YAML, and part of the content may be:
Figure BDA0004051414210000101
the automatically generated code may be:
class SubtractInstructionHelper{
...
value of the instruction field is/are set
void setMinuend(uint32_t);
void setSubtrahend(uint32_t);
void setResult(uint32_t);
uint32_t generation (); instructions for/generate NPU
volpparse (uint 32_t); instructions for/parse NPU
Value of the instruction field of the// fetch
uint32_t getInstructionId();
uint32_t getMinuend();
uint32_t getSubtrahend();
uint32_t getResult();
...
};
...
According to the target code generation method, structural modeling is carried out on the NPU instruction, so that the NPU instruction can be described and stored by using a structured data format, codes for assembling and analyzing the NPU instruction can be automatically generated from the instruction set description file by using a generalized tool, the NPU instruction is not limited by an NPU chip to which the NPU instruction belongs, the attribute and the number of the instruction are not limited, the attribute and the number of instruction fields in the instruction are not limited, the code development and maintenance are convenient, and the workload is small.
Corresponding to the above-mentioned method for generating the object code, referring to fig. 3, fig. 3 is a flow chart of a method for displaying an NPU instruction according to an embodiment of the present application. As shown in FIG. 3, the NPU instruction display method includes:
Step S301, obtaining a target NPU instruction and target description data corresponding to the target NPU instruction, where the target NPU instruction includes at least one instruction field, each instruction field includes a plurality of field attributes of a preset type, and the preset type includes a field start bit and a bit number corresponding to the field.
Step S302, parsing the target NPU instruction based on the target description data, to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field.
Step S303, selecting a second type of display elements from a preset database according to user input, wherein the second type comprises characters, icons and colors, and each second type of display elements comprises an attribute type and an initial attribute value corresponding to the attribute type.
Step S304, a second type mapping relation between each instruction field and the display element is established according to a second preset sequence.
Step S305, receiving a second type target value corresponding to each instruction field input by the user, and updating an initial attribute value of a display element corresponding to each instruction field to the second type target value based on the second type mapping relationship, so as to obtain a target NPU instruction for user-defined display.
The NPU instruction is structured and modeled through the method for generating the target code, so that the NPU instruction can be described and stored by using a structured data format, and a generalized tool can be designed to visually read an instruction set. The overall flow is similar to the method for generating the target code, and only the differences between the method for displaying the NPU instruction and the method for generating the target code described above will be described below.
The method of displaying NPU instructions is essentially a method of exposing an abstract representation of the aforementioned instruction set in various ways. It should be noted that if the instructions are described in text format such as JSON, XML, YAML, the instructions are readable, and can be displayed by the method described below or can be directly used for reading.
For a certain instruction set, the personalized presentation workflow is as follows:
1) Firstly, reading the data content of an instruction set described by the abstract representation mode of the instruction set, and analyzing the data content to obtain an instruction format cluster;
2) Taking out an element from the instruction format cluster, namely the target NPU instruction, and acquiring the attribute of the instruction such as the instruction name and the instruction field cluster from the element;
3) And then selecting or designing a second type of display elements such as custom text, icons, colors and the like for displaying the instruction format, and customizing typesetting sequence and position. Wherein each display element of the second type comprises an attribute type and an initial attribute value corresponding to the attribute type. For example, the current target NPU instruction substantially corresponds to a chart, and the base color of the chart can be changed by setting an attribute type and an initial attribute value corresponding to the attribute type;
4) And taking out an element from the instruction field cluster, and acquiring the attribute of the instruction field such as the name of the instruction field, the initial bit position of the instruction field, the number of bits occupied by the instruction field and the like.
5) Similarly, the display elements of the second type such as custom text, icons, colors and the like can be selected or designed for displaying the instruction fields, and the typesetting order and the position can be customized.
6) Repeating steps 4) through 5) until all instruction fields of the current target NPU instruction are traversed.
7) Repeating steps 2) through 6) until each target NPU instruction in the current instruction set is traversed.
According to the NPU instruction display method, the NPU instruction is subjected to structural modeling through the target code generation method, so that the NPU instruction can be described and stored by using a structured data format, document content of any format and a corresponding reading mode are realized, such as local reading or webpage reading, visual difference comparison reading among different versions of instruction formats and the like, and an instruction set can be displayed in various forms, such as diagrams, graphs, icons and the like, so that visual reading of the target NPU instruction or the instruction set is realized.
Corresponding to the above method embodiment, referring to fig. 4, the present invention further provides an object code generating apparatus 400, where the object code generating apparatus 400 includes:
an obtaining module 401, configured to obtain a target NPU instruction and an initial code corresponding to the target NPU instruction, where the target NPU instruction includes at least one instruction field, each instruction field includes a plurality of field attributes of a preset type, the preset type includes a field name, a field start bit, and a number of bits corresponding to a field, and the initial code includes at least one callable function;
the parsing module 402 is configured to parse the target NPU instruction to obtain at least one instruction field and a plurality of field attributes of a preset type in each instruction field;
a mapping module 403, configured to establish a first type of mapping relationship between each instruction field and a function in the initial code according to a first preset order;
the writing module 404 is configured to receive a first type target value corresponding to each instruction field input by a user, and write the first type target value into the initial code based on the first type mapping relationship and a field attribute of a preset type, so as to obtain a target code.
In a specific implementation, the device for generating the object code further includes:
the receiving module is used for receiving an initial NPU instruction input by a user;
and the conversion module is used for converting the initial NPU instruction into a target NPU instruction if the initial format of the initial NPU instruction is different from the preset format.
In specific implementation, the mapping module is specifically configured to:
acquiring field names of all instruction fields according to a first order;
and for any instruction field, converting the field name of the instruction field into the function name in the initial code according to a preset conversion type to obtain a first type mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
In correspondence to the above method embodiment, referring to fig. 5, the present invention further provides a display device 500 of NPU instructions, where the display device 500 of NPU instructions includes:
an obtaining module 501, configured to obtain a target NPU instruction, where the target NPU instruction includes at least one instruction field, each instruction field includes a plurality of field attributes of a preset type, and the preset type includes a field start bit and a bit number corresponding to the field;
The parsing module 502 is configured to parse the target NPU instruction to obtain at least one instruction field and a plurality of field attributes of a preset type in each instruction field;
a selection module 503, configured to select, according to a user input, a second type of display element from a preset database, where the second type includes a text, an icon, and a color, and each second type of display element includes an attribute type and an initial attribute value corresponding to the attribute type;
a mapping module 504, configured to establish a second type of mapping relationship between each instruction field and the display element according to a second preset order;
the updating module 505 is configured to receive a second type target value corresponding to each instruction field input by a user, update an initial attribute value of a display element corresponding to each instruction field to the second type target value based on the second type mapping relationship, and obtain a target NPU instruction for custom display.
In addition, a computer device is provided, the computer device comprises a processor and a memory, the memory stores a computer program, and the computer program realizes the generation method of the target code and the display method of the NPU instruction when being executed on the processor.
In addition, a computer readable storage medium is provided, in which a computer program is stored, which when executed on a processor implements a method of generating object code and a method of displaying NPU instructions.
The specific implementation process of the object code generating device, the NPU instruction display device, the computer device and the computer readable storage medium provided in the present application may refer to the specific implementation process of the object code generating method or the NPU instruction display provided in the foregoing embodiment, and will not be described in detail herein.
According to the target code generating device, the NPU instruction display device, the computer equipment and the computer readable storage medium, through structural modeling on the NPU instruction, the NPU instruction can be described and stored by using a structured data format, codes for assembling and analyzing the NPU instruction can be automatically generated from the instruction set description file by using a generalized tool, the NPU instruction is not limited by an NPU chip to which the NPU instruction belongs, the attribute and the number of the instruction are not limited, the attribute and the number of instruction fields in the instruction are not limited, the code development and maintenance are convenient, and the workload is small. And the method can realize document content of any format and corresponding reading modes, such as local reading or webpage reading, visual difference comparison reading among different versions of instruction formats and the like, and can display an instruction set in various forms, such as diagrams, graphs, icons and the like, so as to realize visual reading of target NPU instructions or instruction sets.
It should be noted that the above-mentioned computer readable medium disclosed in the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the above-mentioned two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Whereas in the present disclosure, a computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be embodied in the computer device; or may exist alone without being assembled into the computer device.
The computer readable medium carries one or more programs which, when executed by the computer device, cause the computer device to: acquiring at least two internet protocol addresses; sending a node evaluation request comprising the at least two internet protocol addresses to node evaluation equipment, wherein the node evaluation equipment selects an internet protocol address from the at least two internet protocol addresses and returns the internet protocol address; receiving an Internet protocol address returned by the node evaluation equipment; wherein the acquired internet protocol address indicates an edge node in the content distribution network.
Alternatively, the computer-readable medium carries one or more programs that, when executed by the computer device, cause the computer device to: receiving a node evaluation request comprising at least two internet protocol addresses; selecting an internet protocol address from the at least two internet protocol addresses; returning the selected internet protocol address; wherein the received internet protocol address indicates an edge node in the content distribution network.
Computer program code for carrying out operations disclosed herein may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments disclosed herein. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments disclosed in the present application may be implemented by means of software, or may be implemented by means of hardware. The name of the unit does not in any way constitute a limitation of the unit itself, for example the first acquisition unit may also be described as "unit acquiring at least two internet protocol addresses".
It should be understood that portions of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof.
The foregoing is merely specific embodiments disclosed herein, but the scope of the disclosure is not limited thereto, and any changes or substitutions that may be easily contemplated by those skilled in the art within the scope of the disclosure are intended to be encompassed within the scope of the disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims (10)

1. A method for generating an object code, the method comprising:
acquiring a target NPU instruction, target description data corresponding to the target NPU instruction and an initial code, wherein the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, the preset type comprises a field name, a field start bit and a bit number corresponding to the field, and the initial code comprises at least one callable function;
Analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
establishing a first type mapping relation between each instruction field and the function in the initial code according to a first preset sequence;
and receiving a first type target value corresponding to each instruction field input by a user, and writing the first type target value into the initial code based on the first type mapping relation and the field attribute of the preset type to obtain a target code.
2. The method of generating object code according to claim 1, wherein before the step of obtaining the object NPU instruction, the object description data corresponding to the object NPU instruction, and the initial code, the method of generating object code further comprises:
receiving a target NPU instruction input by a user and initial description data corresponding to the target NPU instruction;
if the initial format corresponding to the initial description data is different from the preset format, converting the initial description data into target description data in the preset format.
3. The method according to claim 1, wherein the step of establishing a first type of mapping relationship between each of the instruction fields and the functions in the initial code in a first predetermined order comprises:
Acquiring field names of all instruction fields according to a first order;
and for any instruction field, converting the field name of the instruction field into the function name in the initial code according to a preset conversion type to obtain a first type mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
4. The NPU instruction display method is characterized by comprising the following steps:
acquiring a target NPU instruction and target description data corresponding to the target NPU instruction, wherein the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, and the preset type comprises a field start bit and a bit number corresponding to the field;
analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
selecting a second type of display elements from a preset database according to user input, wherein the second type comprises characters, icons and colors, and each second type of display elements comprises an attribute type and an initial attribute value corresponding to the attribute type;
Establishing a second type mapping relation between each instruction field and the display element according to a second preset sequence;
receiving a second type target value corresponding to each instruction field input by a user, and updating an initial attribute value of a display element corresponding to each instruction field to the second type target value based on the second type mapping relation to obtain a target NPU instruction of self-defined display;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the method for generating the target code according to any one of claims 1 to 2.
5. An object code generating apparatus, characterized in that the object code generating apparatus includes:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a target NPU instruction, target description data corresponding to the target NPU instruction and initial codes corresponding to the target NPU instruction, the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, the preset type comprises a field name, a field start bit and a bit number corresponding to a field, and the initial codes comprise at least one callable function;
The analyzing module is used for analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
the mapping module is used for establishing a first type of mapping relation between each instruction field and the function in the initial code according to a first preset sequence;
and the writing module is used for receiving a first type target value corresponding to each instruction field input by a user, and writing the first type target value into the initial code based on the first type mapping relation and the field attribute of the preset type to obtain a target code.
6. The apparatus for generating an object code according to claim 5, wherein the apparatus for generating an object code further comprises:
the receiving module is used for receiving a target NPU instruction input by a user and initial description data corresponding to the target NPU instruction;
and the conversion module is used for converting the initial description data into target description data in a preset format if the initial format corresponding to the initial description data is different from the preset format.
7. The apparatus for generating an object code according to claim 5, wherein the mapping module is specifically configured to:
Acquiring field names of all instruction fields according to a first order;
and for any instruction field, converting the field name of the instruction field into the function name in the initial code according to a preset conversion type to obtain a first type mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
8. A display device for NPU instructions, wherein the display device for NPU instructions comprises:
the system comprises an acquisition module, a storage module and a control module, wherein the acquisition module is used for acquiring a target NPU instruction and target description data corresponding to the target NPU instruction, the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of a preset type, and the preset type comprises a field start bit and a bit number corresponding to the field;
the analyzing module is used for analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of field attributes of preset types in each instruction field;
the selection module is used for selecting a second type of display elements from a preset database according to user input, wherein the second type comprises characters, icons and colors, and each second type of display elements comprises an attribute type and an initial attribute value corresponding to the attribute type;
The mapping module is used for establishing a second type mapping relation between each instruction field and the display element according to a second preset sequence;
the updating module is used for receiving a second type target value corresponding to each instruction field input by a user, updating an initial attribute value of a display element corresponding to each instruction field into the second type target value based on the second type mapping relation, and obtaining a target NPU instruction which is displayed in a self-defining mode;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the method for generating the target code according to any one of claims 1 to 2.
9. A computer device, characterized in that it comprises a processor and a memory, the memory storing a computer program, which when executed on the processor implements the method of generating object code according to any of claims 1-3 and the method of displaying NPU instructions according to claim 4.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program, which when executed on a processor implements the method of generating object code according to any one of claims 1-3 and the method of displaying NPU instructions according to claim 4.
CN202310043431.5A 2022-10-25 2023-01-26 Target code generation method, NPU instruction display method and device Pending CN116028062A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211309524X 2022-10-25
CN202211309524.XA CN115629763A (en) 2022-10-25 2022-10-25 Target code generation method and NPU instruction display method and device

Publications (1)

Publication Number Publication Date
CN116028062A true CN116028062A (en) 2023-04-28

Family

ID=84906860

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202211309524.XA Pending CN115629763A (en) 2022-10-25 2022-10-25 Target code generation method and NPU instruction display method and device
CN202310043431.5A Pending CN116028062A (en) 2022-10-25 2023-01-26 Target code generation method, NPU instruction display method and device

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202211309524.XA Pending CN115629763A (en) 2022-10-25 2022-10-25 Target code generation method and NPU instruction display method and device

Country Status (1)

Country Link
CN (2) CN115629763A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117270838A (en) * 2023-11-22 2023-12-22 太平金融科技服务(上海)有限公司 Method, device, equipment and medium for generating universal formula script

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117270838A (en) * 2023-11-22 2023-12-22 太平金融科技服务(上海)有限公司 Method, device, equipment and medium for generating universal formula script
CN117270838B (en) * 2023-11-22 2024-02-13 太平金融科技服务(上海)有限公司 Method, device, equipment and medium for generating universal formula script

Also Published As

Publication number Publication date
CN115629763A (en) 2023-01-20

Similar Documents

Publication Publication Date Title
US10318628B2 (en) System and method for creation of templates
KR101307711B1 (en) A consistent method system and computer program for developing software asset based solutions
CN106598612B (en) Operation method and system for data table in database
US9411798B1 (en) Methods and apparatus for reusing report design components and templates
JP2016224923A (en) Method and system for automated generation of user form interface
CN113076096B (en) Desktop application program development method, device, equipment and storage medium
CN114035773A (en) Configuration-based low-code form development method, system and device
US20080244416A1 (en) Apparatus and method for creating and consuming custom visualization templates
CN110968601A (en) Data query processing method and device
US8701086B2 (en) Simplifying analysis of software code used in software systems
CA2686367A1 (en) Dynamic native editor code view facade
CN116028062A (en) Target code generation method, NPU instruction display method and device
KR101552914B1 (en) Web server application framework web application processing method using the framework and computer readable medium processing the method
CN113448562B (en) Automatic logic code generation method and device and electronic equipment
KR20070047675A (en) Method and apparatus for constructing representations of objects and entities
CN110308907B (en) Data conversion method and device, storage medium and electronic equipment
US20230004477A1 (en) Providing a pseudo language for manipulating complex variables of an orchestration flow
US7716653B2 (en) Configurable importers and resource writers for converting data into another format
US20150277723A1 (en) Exporting a component of a currently displayed user interface to a development system
CN113312025A (en) Component library generation method and device, storage medium and electronic equipment
JP2001273125A (en) Method and system for automatically generating source program, and program recording medium therefor
US9710582B1 (en) Delivering circuit designs for programmable integrated circuits
CN112130841B (en) SQL development method and device and terminal equipment
CN112988136B (en) User interface editing method and device
CN117453713A (en) SQL sentence generation method, device and storage medium for multi-type database

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination