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

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

Info

Publication number
CN115629763A
CN115629763A CN202211309524.XA CN202211309524A CN115629763A CN 115629763 A CN115629763 A CN 115629763A CN 202211309524 A CN202211309524 A CN 202211309524A CN 115629763 A CN115629763 A CN 115629763A
Authority
CN
China
Prior art keywords
instruction
target
field
npu
type
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
CN202211309524.XA
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
Priority to CN202211309524.XA priority Critical patent/CN115629763A/en
Publication of CN115629763A publication Critical patent/CN115629763A/en
Priority to CN202310043431.5A priority 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

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

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

Description

Target code generation method and NPU instruction display method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method for generating an object code, and a method and an apparatus for displaying an NPU instruction.
Background
A Neural Network Processing Unit (NPU) is a code for performing a specific operation in an NPU chip. An NPU instruction has several instruction fields for respectively indicating the function of the instruction and corresponding parameters, and the position, length and possibly fixed value of the instruction field in the instruction are different according to the instruction format. The NPU instruction set is a collection of all instruction formats that the NPU can support.
Regarding the generation mode of the NPU instruction, currently, a matched instruction generation tool is mainly developed for each NPU instruction set, in the instruction generation tool, corresponding program codes are developed according to the format of each instruction and used for assembling an instruction field to generate a specific NPU instruction code, and the development and maintenance workload of the code is large. In the early stage of instruction set design, instruction set update iteration is frequent, and the response speed of a corresponding instruction generation tool to the change of the instruction set is slow.
Therefore, the existing codes for splicing the instructions have the technical problems of inconvenient development and maintenance and large workload.
Disclosure of Invention
In order to solve the technical problem, the application provides a method for generating an object code, a method for displaying an NPU instruction and a device, 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:
the method comprises the steps of obtaining 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 field attributes of a plurality of preset types, the preset types comprise field names, field start bits and bits corresponding to the fields, 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 preset types of field attributes in each instruction field;
establishing a first type mapping relation between each instruction field and a 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 preset type field attribute to obtain a target code.
According to a specific embodiment disclosed in the present application, before the step of obtaining a target NPU instruction, target description data corresponding to the target NPU instruction, and an initial code, the method for generating a target code further includes:
receiving a target NPU instruction input by a user and initial description data corresponding to the target NPU instruction;
and 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 the instruction fields according to a first sequence;
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 of 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 preset types, and the preset types comprise field start bits and bit numbers corresponding to the fields;
analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of preset types of field attributes in each instruction field;
selecting second type display elements from a preset database according to user input, wherein the second type display elements comprise characters, icons and colors, and each second type display element comprises an attribute type and an initial attribute value corresponding to the attribute type;
establishing a second type of 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 the initial attribute value of the 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 with customized display;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the generation method of the target code in 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 device comprises an acquisition module, a processing module and a control module, wherein the acquisition module is used for acquiring a target NPU instruction, target description data corresponding to the target NPU instruction and an initial code corresponding to the target NPU instruction, the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of preset types of field attributes, the preset types comprise field names, field start bits and bits corresponding to fields, and the initial code comprises at least one callable function;
the analysis 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 preset types of field attributes in each instruction field;
the mapping module is used for establishing a first type of mapping relation between each instruction field and a function in the initial code according to a first preset sequence;
and the writing module is used for receiving a first type of target value corresponding to each instruction field input by a user, and writing the first type of target value into the initial code to obtain a target code based on the first type of mapping relation and the preset type of field attribute.
According to a specific embodiment disclosed in the present application, the apparatus for generating 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 a specific embodiment disclosed in the present application, the mapping module is specifically configured to:
acquiring field names of the instruction fields according to a first sequence;
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 of 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 apparatus of an NPU instruction, where the display apparatus of the NPU instruction includes:
the device comprises an acquisition module, a processing module and a processing 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 field attributes of a plurality of preset types, and the preset types comprise field start bits and bit numbers corresponding to the fields;
the analysis 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 preset types of field attributes in each instruction field;
the system comprises a selection module, a display module and a display module, wherein the selection module is used for selecting second types of display elements from a preset database according to user input, the second types comprise characters, icons and colors, and each second type of display element comprises an attribute type and an initial attribute value corresponding to the attribute type;
the mapping module is used for establishing a second type of 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 and input by a user, and updating the initial attribute value of the display element corresponding to each instruction field into the second type target value based on the second type mapping relation to obtain a target NPU instruction with customized display;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the generation method of the target code in any one of claims 1 to 2.
In a fifth aspect, the present application provides a computer device, which includes a processor and a memory, where the memory stores a computer program, and the computer program, when executed on the 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.
In a fifth aspect, the present embodiments provide a computer-readable storage medium, which stores a computer program, and when the computer program is executed on a processor, the computer program implements a method for generating object code according to any one of the first aspect and a method for displaying NPU instructions according to the second aspect.
Compared with the prior art, the method has the following beneficial effects:
the target code generation method includes analyzing a target NPU instruction based on target description data to obtain at least one instruction field and a plurality of preset types of field attributes in each instruction field, establishing a first type of mapping relation between each instruction field and a function in an initial code according to a first preset sequence, receiving a first type of target value corresponding to each instruction field and input by a user, and writing the first type of target value into the initial code based on the first type of mapping relation and the preset types of field attributes to obtain a target code. According to the method, the NPU instruction is abstractly expressed to obtain the target NPU instruction, the code for assembling and analyzing the NPU instruction can be automatically generated by the target code generating method, the code for assembling and analyzing the NPU instruction does not need to be manually developed, and the code is convenient to develop and maintain and small in workload.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments disclosed in the present application, the drawings required to be used in the embodiments will be briefly described below, it is obvious that the drawings in the following description are only some embodiments disclosed in the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart 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 object code according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a method for displaying an NPU instruction according to an embodiment of the present disclosure;
fig. 4 is a block diagram of an apparatus for generating object code according to an embodiment of the present application;
fig. 5 is a block diagram of a display device of an NPU instruction according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.
The components of 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 present invention, 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 derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Hereinafter, the terms "including", "having", and their derivatives, which may be used in various embodiments of the present invention, are only intended to indicate specific features, numbers, steps, operations, elements, components, or combinations of the foregoing, and should not be construed as first excluding the existence of, or adding to, 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 solely to distinguish one from another, and are not to 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 present invention belong. The terms (such as those defined in commonly used dictionaries) should be interpreted as having a meaning that is consistent with their contextual meaning in the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein in various embodiments of the present invention.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a schematic 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 obtained, wherein the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of field attributes of preset types, the preset types comprise field names, field start bits and bit numbers corresponding to the fields, and the initial code comprises 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 a code that can be executed by the NPU as an instruction, and is generally data in a binary format. The target description data refers to "data describing the format of the NPU instruction", in other words, these description data are used for describing the NPU instruction and are generally stored in a text file. These description data cannot be executed by the NPU as instructions.
The difference between the two is illustrated by way of example:
in the NPU instruction, the value in the instruction field is deterministic. For example, a subtraction instruction, contains explicit values of the subtree and the subtree within the instruction content, or contains the locations of these values in memory. For example, the subtraction instruction may be: 0b00011000000010000000000000000000;
the description data of the NPU instruction only describes what fields of a certain instruction, and the value of each instruction field is stored in what position of the content of one NPU instruction, and does not concern the specific value of the instruction field. Taking the subtraction instruction as an example, the NPU instruction description data indicates that there are two fields of the subtracted number and the subtracted number in the subtraction instruction, the values of these fields are located at the beginning of the several bits of the content of the subtraction instruction, and the lengths of the fields are bits respectively. For example, the target description data corresponding to the subtraction instruction may be:
Figure BDA0003906685530000061
Figure BDA0003906685530000071
the NPU instruction or the NPU instruction set used by the user is designed according to the requirements of the user or the specific application scenario, and the formats of the description data corresponding to the NPU instruction 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 acquiring a target NPU instruction, target description data corresponding to the target NPU instruction, and an 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;
and 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 be described and stored in any existing structured file format, such as XML, JSON, YAML format, or other customized file formats capable of expressing structured information in a certain rule. The data content used to express 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 diagram of data structures of instructions and instruction sets involved in a method for generating object code according to an embodiment of the present application. In a practical application scenario, a user usually provides an NPU instruction set, i.e. a set of all instruction formats that can be supported by an NPU. Therefore, not only the default format of a single NPU instruction, but also the overall data structure of the instruction set will be described in detail below. The instruction format portion of the data structure may be understood as a desired preset format. In the logical association relationship, the structure generally includes three layers, wherein:
the first layer is used as the outermost layer of the abstract representation of the instruction set, and the adopted data structure type can describe the attribute of an object, 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 level in the abstract representation of the instruction set.
The second layer is a sub-level of the first layer, and is used for representing the content part of the instruction set, and is contained by the first layer in logic association, and the adopted data structure type is a data structure capable of expressing clusters, such as an array. The second layer is used to represent clusters of instruction formats. Each element in the instruction format cluster is used to represent an instruction format, i.e., the target NPU instruction described above. The data type adopted by the method should be capable of describing the attribute of an object, the common data type is a structure body, wherein at least a plurality of data members are used for describing some information of an instruction format, such as instruction names, instruction lengths and the like, and one data member is used for describing a third layer in the abstract representation of the instruction set.
The third layer is a sub-level of the second layer, and is used for representing the content part of the instruction, and is included in the second layer in logical association, and the data type adopted by the third layer is a data structure capable of expressing a cluster, such as an array. The third layer is used to represent the clustering of instruction fields. Each element in the instruction field cluster is used for representing an instruction field, and the adopted data type of the instruction field cluster can describe the attribute of an object, and a common data structure such as a structural body. The data members should include a plurality of data members for describing the starting bit position of the instruction field, the number of bits occupied by the instruction field, and the like. The instruction fields 1, 2.. N shown in fig. 2 correspond to different instruction fields in the target NPU instruction described above, and each instruction field includes a plurality of field attributes of a predetermined type, where the predetermined type includes a field name, a field start bit, and a number of bits corresponding to the field.
Step S102, analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of preset types of field attributes in each instruction field.
In specific implementation, after a target NPU instruction is obtained, data content of the instruction set described by the abstract representation mode of the instruction set may be read first, and instruction format clusters may be analyzed from the data content. Then, according to the actual use requirement or specific application scene of the user, an element can be taken out from the instruction format cluster randomly or according to a self-defined sequence, and an instruction name and an instruction field cluster are obtained from the element.
Step S103, establishing a first type mapping relation between each instruction field and the function in the initial code according to a first preset sequence.
The first preset sequence can also be customized according to the actual use requirement of the user or a specific application scene.
In specific implementation, for the whole NPU instruction set, the instruction name can be used as a keyword to spell the name of the initial code used for assembling the corresponding instruction, so as to establish the mapping relationship between the target NPU instruction and the initial code, and facilitate the query in the subsequent use process. In addition, in order to further improve the convenience in the subsequent use process, the sequence of the instruction formats appearing in the instruction format cluster can be used as the index identification of the instruction formats. In actual use, the initial code may be understood as a class, module, or other equivalent organized unit of code.
For a single target NPU instruction, an element can be taken out from the instruction field cluster, and preset types of field attributes 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 of mapping relation between each instruction field and the function in the initial code according to a first preset sequence. In particular, the names of the functions in other equivalent code organization units, such as code modules, or member methods of classes for obtaining and setting the contents of instruction fields, may be pieced together with the instruction field names as keys. 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 the instruction fields according to a first sequence;
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 of mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
For example, in practical application scenarios, the above "conversion" process includes, but is not limited to:
op _ code is used directly;
conversion of op _ code to opcode
Conversion of op _ code to opCode
Conversion of OP _ CODE to OP _ CODE
Conversion of op _ code to getOpCode
Also, to facilitate subsequent queries during use, the order in which the instruction fields appear in the cluster of instruction fields can be used as an index identification for the instruction fields. In the member method or function, the initial bit position of the instruction field and the number of bits 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 the assembly basis of the current instruction field. For example, the instruction "a + b = c" corresponds to 32 bits, except for the fixed upper 4 bits, the first 7 bits of the remaining 28 bits may be defined as an address corresponding to the addend a, the second 7 bits may be defined as an address corresponding to the addend b, the third 7 bits may be defined as an address corresponding to the result c, the last 7 bits may be defined as the data type, and the like.
In specific implementation, for a certain NPU instruction or NPU instruction set, the above steps are repeated 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 class target value corresponding to each instruction field input by a user, and writing the first class target value into the initial code based on the first class mapping relation and a preset type field attribute to obtain a target code.
It should be noted that the target NPU instruction and the target description data corresponding to the target NPU instruction may be understood as a model or a formula that can be used universally, and in a subsequent use process, inputting a corresponding specific value may call a class interface to write the specific value, that is, "writing the first class target value into the initial code" may satisfy a user requirement, and obtain a target code in a specific application scenario.
Taking a subtraction instruction as an example, the overall flow of the method for generating the target code is as follows:
the most primitive input is an instruction set description document from the NPU chip designer, and part of the contents may be:
a subtraction instruction: instruction length 32bit, instruction identification code 0x1. A decremented position 21, length 7bit; a decrement position 14, length 7bit; the result address position is 0, and the length is 14 bits; addition instruction: instruction length 32bit, instruction identification code 0x2.
According to the method for generating the object code, the instructions in the instruction set are subjected to abstract modeling, and an instruction set description document in an object format, namely object description data, is obtained. Then, the target description data is used as an input of a code generation tool, and is described in a file format such as XML, JSON, YAML and the like, and part of the contents of the target description data can be:
Figure BDA0003906685530000101
the automatically generated code may be:
class SubtractInstructionHelper{
...
// setting the value of the instruction field
void setMinuend(uint32_t);
void setSubtrahend(uint32_t);
void setResult(uint32_t);
Agent 32_ t generate (); // generating NPU instruction
voidpase (uint 32_ t); // resolve NPU instruction
// get value of instruction field
uint32_t getInstructionId();
uint32_t getMinuend();
uint32_t getSubtrahend();
uint32_t getResult();
...
};
...
According to the target code generation method, the NPU instruction can be described and stored by using a structured data format through structured modeling of the NPU instruction, codes for assembling and analyzing the NPU instruction can be automatically generated from an instruction set description file by using a generalized tool, the method is not limited by an NPU chip to which the NPU instruction belongs, the method is not limited by the attribute and the number of the instruction, the method is not limited by the attribute and the number of instruction fields in the instruction, the code development and maintenance are convenient and fast, and the workload is small.
Corresponding to the method for generating the object code, referring to fig. 3, fig. 3 is a schematic flowchart of a method for displaying an NPU instruction according to an embodiment of the present application. As shown in fig. 3, the method for displaying the NPU instruction includes:
step S301, a target NPU instruction and target description data corresponding to the target NPU instruction are obtained, where the target NPU instruction includes at least one instruction field, each instruction field includes field attributes of multiple preset types, and the preset types include field start bits and bit numbers corresponding to the fields.
Step S302, analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of preset types of field attributes in each instruction field.
Step S303, selecting second type display elements from a preset database according to user input, wherein the second type display elements comprise characters, icons and colors, and each second type display element comprises an attribute type and an initial attribute value corresponding to the attribute type.
Step S304, establishing a second mapping relationship between each instruction field and the display element according to a second preset order.
Step S305, receiving a second type target value corresponding to each instruction field input by a user, and updating the initial attribute value of the 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 with customized display.
The NPU instruction is structurally modeled by the target code generation method, 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 process is similar to the target code generation method, and only the differences between the NPU instruction display method and the target code generation method are described below, and other specific implementation processes may refer to the specific implementation processes of the target code generation method provided in the above embodiments, and are not described in detail here.
The display method of the NPU instruction is essentially a method of displaying the abstract representation of the aforementioned instruction set in various ways. It should be noted that if the instructions described in the text format such as JSON, XML, YAML, etc. are used, they are readable, and can be displayed by the method described below or directly used for reading.
For a certain instruction set, the personalized display workflow is as follows:
1) Firstly, reading in the data content of the instruction set described by the abstract representation mode of the instruction set, and analyzing the instruction format cluster from the data content;
2) Taking out an element, namely the target NPU instruction, from the instruction format cluster, and obtaining the attribute of the instruction such as the instruction name and the instruction field cluster from the target NPU instruction;
3) And then selecting or designing a second type of display elements such as custom characters, icons, colors and the like for displaying the instruction format, and customizing the typesetting sequence and position. And 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 ground color of the chart and the like 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 instruction field name, the initial bit position of the instruction field, the number of bits occupied by the instruction field and other attributes of the instruction field.
5) Similarly, second types of display elements such as custom characters, icons, colors and the like can be selected or designed for displaying the instruction field, and the typesetting order and position can be customized.
6) And repeating the steps 4) -5) until all instruction fields of the current target NPU instruction are traversed.
7) And repeating the steps 2) to 6) until each target NPU instruction in the current instruction set is traversed.
According to the display method of the NPU instruction, structured modeling is carried out on the NPU instruction through the target code generation method, so that the NPU instruction can be described and stored by using a structured data format, document contents of any format and corresponding reading modes are realized, for example, local reading or webpage reading, visual difference comparison reading between instruction formats of different versions and the like are realized, an instruction set can be displayed into various forms, for example, charts, graphs, icons and the like, and visual reading of a target NPU instruction or an instruction set is realized.
Corresponding to the above method embodiment, referring to fig. 4, the present invention further provides an apparatus 400 for generating an object code, where the apparatus 400 for generating an object code 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 field attributes of multiple preset types, the preset types include a field name, a field start bit, and a bit number corresponding to a field, and the initial code includes at least one callable function;
an analyzing module 402, configured to analyze the target NPU instruction to obtain at least one instruction field and a plurality of preset types of field attributes 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;
a writing module 404, 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 preset type field attribute, so as to obtain a target code.
In specific implementation, the apparatus for generating 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 a preset format.
In specific implementation, the mapping module is specifically configured to:
acquiring field names of the instruction fields according to a first sequence;
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 of mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
Corresponding to the above method embodiment, referring to fig. 5, the present invention further provides a display apparatus 500 of an NPU instruction, where the display apparatus 500 of the NPU instruction 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 field attributes of multiple preset types, and each preset type includes a field start bit and a bit number corresponding to a field;
an analyzing module 502, configured to analyze the target NPU instruction to obtain at least one instruction field and a plurality of preset types of field attributes in each instruction field;
a selecting module 503, configured to select, according to user input, a second type of display element from a preset database, where the second type includes characters, icons, and colors, 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;
and the updating module 505 is configured to receive a second type target value corresponding to each instruction field, which is input by a user, and update the initial attribute value of the 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 with a user-defined 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 object code and the display method of the NPU instruction when executed on the processor.
Furthermore, a computer-readable storage medium is provided, in which a computer program is stored, which computer program, when executed on a processor, implements a method of generating object code and a method of displaying NPU instructions.
For specific implementation processes of the apparatus for generating an object code, the apparatus for displaying an NPU instruction, the computer device, and the computer-readable storage medium provided in the present application, reference may be made to the method for generating an object code or the specific implementation process for displaying an NPU instruction provided in the foregoing embodiments, which are not described in detail herein.
According to the target code generation device, the NPU instruction display device, the computer equipment and the computer readable storage medium, the NPU instruction can be described and stored by using a structured data format through structured modeling of the NPU instruction, the 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 generation device is not limited by an NPU chip to which the NPU instruction belongs, is not limited by the attributes and the number of the instructions, is not limited by the attributes and the number of instruction fields in the instruction, is convenient to develop and maintain, and has small workload. And the document content of any format and corresponding reading mode can be realized, such as local reading or webpage reading, visual difference comparison reading between instruction formats of different versions and the like, and the instruction set can also be displayed in various forms, such as charts, graphs, icons and the like, so that visual reading of the target NPU instruction or the instruction set is realized.
It should be noted that the 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 two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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. In contrast, in the present disclosure, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. 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 thereof. 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the computer device; or may exist separately and not be incorporated into the computer device.
The computer readable medium carries one or more programs which, when executed by the computing device, cause the computing 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 the internet protocol addresses from the at least two internet protocol addresses and returns the internet protocol addresses; receiving an internet protocol address returned by the node evaluation equipment; wherein the obtained internet protocol address indicates an edge node in the content distribution network.
Alternatively, the computer readable medium carries one or more programs which, when executed by the computing device, cause the computing 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 described in the embodiments disclosed in the present application may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first obtaining unit may also be described as a "unit obtaining 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 above description is only for the specific embodiments disclosed in the present application, but the scope of the present disclosure is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present disclosure should be covered within the scope of the present disclosure. Therefore, the protection scope disclosed in the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for generating an object code, the method comprising:
the method comprises the steps of obtaining 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 field attributes of a plurality of preset types, the preset types comprise field names, field start bits and bits corresponding to the fields, 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 preset types of field attributes in each instruction field;
establishing a first type mapping relation between each instruction field and a 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 preset type field attribute to obtain a target code.
2. The method of claim 1, wherein before the step of obtaining the target NPU instruction, the target NPU instruction corresponding to the target description data, and the initial code, the method further comprises:
receiving a target NPU instruction input by a user and initial description data corresponding to the target NPU instruction;
and 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 the first type of mapping relationship between each instruction field and the function in the initial code according to a first preset order comprises:
acquiring field names of the instruction fields according to a first sequence;
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 of mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
4. A method for displaying an NPU instruction 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 preset types, and the preset types comprise field start bits and bit numbers corresponding to the fields;
analyzing the target NPU instruction based on the target description data to obtain at least one instruction field and a plurality of preset types of field attributes in each instruction field;
selecting second type display elements from a preset database according to user input, wherein the second type display elements comprise characters, icons and colors, and each second type display element comprises an attribute type and an initial attribute value corresponding to the attribute type;
establishing a second type of 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, which is input by a user, updating the initial attribute value of the display element corresponding to each instruction field to the second type target value based on the second type mapping relation, and obtaining a target NPU instruction with custom display;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the generation method of the target code in any one of claims 1 to 2.
5. An apparatus for generating an object code, comprising:
the device comprises an acquisition module, a processing module and a control module, wherein the acquisition module is used for acquiring a target NPU instruction, target description data corresponding to the target NPU instruction and an initial code corresponding to the target NPU instruction, the target NPU instruction comprises at least one instruction field, each instruction field comprises a plurality of preset types of field attributes, the preset types comprise field names, field start bits and bits corresponding to fields, and the initial code comprises at least one callable function;
the analysis 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 preset types of field attributes 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 of target value corresponding to each instruction field input by a user, and writing the first type of target value into the initial code to obtain a target code based on the first type of mapping relation and the preset type of field attribute.
6. The apparatus for generating object code according to claim 5, further comprising:
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 object code according to claim 5, wherein the mapping module is specifically configured to:
acquiring field names of the instruction fields according to a first sequence;
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 of mapping relation corresponding to the field name and the function name, wherein the preset conversion type comprises copying, mapping and expanding.
8. An NPU command display device, comprising:
the device comprises an acquisition module, a processing module and a processing 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 field attributes of a plurality of preset types, and the preset types comprise field start bits and bit numbers corresponding to the fields;
the analysis 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 preset types of field attributes in each instruction field;
the system comprises a selection module, a display module and a display module, wherein the selection module is used for selecting second types of display elements from a preset database according to user input, the second types comprise characters, icons and colors, and each second type of display element comprises an attribute type and an initial attribute value corresponding to the attribute type;
the mapping module is used for establishing a second type of 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 and input by a user, and updating the initial attribute value of the display element corresponding to each instruction field into the second type target value based on the second type mapping relation to obtain a target NPU instruction with customized display;
the target NPU instruction and the target description data corresponding to the target NPU instruction are obtained according to the generation method of the target code in any one of claims 1 to 2.
9. A computer arrangement, characterized in that the computer arrangement comprises a processor and a memory, the memory storing a computer program which, when executed on the processor, implements a method of generating object code according to any one of claims 1-3 and a method of displaying NPU instructions according to claim 4.
10. A computer-readable storage medium, characterized in that it stores a computer program which, when executed on a processor, implements a method of generating object code as claimed in any one of claims 1 to 3 and a method of displaying NPU instructions as claimed in claim 4.
CN202211309524.XA 2022-10-25 2022-10-25 Target code generation method and NPU instruction display method and device Pending CN115629763A (en)

Priority Applications (2)

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

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
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
CN115629763A true CN115629763A (en) 2023-01-20

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 After (1)

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

Country Status (1)

Country Link
CN (2) CN115629763A (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN116028062A (en) 2023-04-28

Similar Documents

Publication Publication Date Title
US10318628B2 (en) System and method for creation of templates
CN106598612B (en) Operation method and system for data table in database
US20070222783A1 (en) Declarative definition enabling graphical designer reuse
WO2021217911A1 (en) Method and apparatus for constructing service website project, and computer device and storage medium
JP2016224923A (en) Method and system for automated generation of user form interface
CN110968601A (en) Data query processing method and device
US9817811B2 (en) Web server system, dictionary system, dictionary call method, screen control display method, and demonstration application generation method
US20080244416A1 (en) Apparatus and method for creating and consuming custom visualization templates
KR20130139724A (en) A computing system, a method for controlling thereof, and a computer-readable recording medium having a computer program for controlling thereof
KR101552914B1 (en) Web server application framework web application processing method using the framework and computer readable medium processing the method
CA2686367A1 (en) Dynamic native editor code view facade
CN115629763A (en) Target code generation method and NPU instruction display method and device
KR20070047675A (en) Method and apparatus for constructing representations of objects and entities
CN110308907B (en) Data conversion method and device, storage medium and electronic equipment
CN112181419A (en) Interface generation method and device and storage medium
US11977473B2 (en) Providing a pseudo language for manipulating complex variables of an orchestration flow
CN116048609A (en) Configuration file updating method, device, computer equipment and storage medium
CN115543428A (en) Simulated data generation method and device based on strategy template
CN112130841B (en) SQL development method and device and terminal equipment
CN116204554B (en) Data processing method, system, electronic device and storage medium
US20240037325A1 (en) Ability to add non-direct ancestor columns in child spreadsheets
US10102122B2 (en) Personal computing device for editing mainframe data
CN117453713A (en) SQL sentence generation method, device and storage medium for multi-type database
CN117312619A (en) Character string processing method, device, computer equipment and storage medium
CN114328965A (en) Knowledge graph updating method and device and computer equipment

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
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20230120

WD01 Invention patent application deemed withdrawn after publication