Compilation methods, compilation devices, and processing architecture

By dividing the program into multiple groups and compiling it approximately or precisely according to error requirements, the problems of resource waste and large errors in the existing technology are solved, and flexible compilation and efficient execution are achieved.

CN116225448BActive Publication Date: 2026-07-31LYNXI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LYNXI TECH CO LTD
Filing Date
2023-01-16
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

In the existing technology, the compilation method of computer programs is too mechanical and cannot flexibly perform approximate compilation according to actual needs, resulting in waste of resources and large errors in processing results.

Method used

The initial program of the target task is divided into multiple program groups. Some groups are selected as target groups for approximate compilation. The allowable error is determined and approximate compilation is performed based on the error. The groups that are not approximately compiled are precisely compiled to form an executable program.

Benefits of technology

This reduced resource consumption, ensured the accuracy of processing results, and guaranteed the smooth execution of the target tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116225448B_ABST
    Figure CN116225448B_ABST
Patent Text Reader

Abstract

This disclosure provides a compilation method, compilation apparatus, and processing architecture, belonging to the field of computer technology. The method includes: dividing an initial program of a target task into multiple program groups; selecting at least some program groups as target groups for approximate compilation, and determining the allowable error for each target group; for each target group, performing approximate compilation based on the allowable error of the target group to obtain a corresponding approximate group; and, in the case of program groups that have not undergone approximate compilation, performing precise compilation on the program groups that have not undergone approximate compilation to obtain a corresponding precise group; wherein the obtained approximate group and precise group constitute the executable program of the target task. According to embodiments of this disclosure, it is possible to flexibly perform approximate compilation on all or part of the initial program of the target task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a compilation method, compilation apparatus, and processing architecture. Background Technology

[0002] In related technologies, computers primarily execute programs using precise calculations, meaning the hardware follows the steps specified by the top-level program exactly and outputs deterministic results. However, task processing often allows for a certain margin of error and may not require completely precise results. Considering that higher precision in calculations comes at a higher cost, approximate calculations can be used, appropriately sacrificing computational precision or employing deterministic methods to conserve processing resources. Summary of the Invention

[0003] This disclosure provides a compilation method and compilation apparatus, processing architecture, electronic device, and computer-readable storage medium.

[0004] In a first aspect, this disclosure provides a compilation method, which includes: dividing an initial program of a target task into multiple program groups; selecting at least some of the program groups as target groups for approximate compilation, and determining the allowable error for each target group; performing approximate compilation on each target group according to the allowable error of the target group to obtain a corresponding approximate group; and, in the case of program groups that have not been approximate compiled, performing precise compilation on the program groups that have not been approximate compiled to obtain a corresponding precise group; wherein the obtained approximate group and the precise group constitute the executable program of the target task.

[0005] Secondly, this disclosure provides a compilation apparatus, comprising: a partitioning module for dividing an initial program of a target task into multiple program groups; a determining module for selecting at least a portion of the program groups as target groups for approximate compilation and determining the allowable error for each target group; an approximate compilation module for performing approximate compilation on each target group according to the allowable error of the target group to obtain a corresponding approximate group; and a precise compilation module for performing precise compilation on the program groups that have not been approximate compiled, in the case where there are program groups that have not been approximate compiled, to obtain a corresponding precise group; wherein the obtained approximate group and the precise group constitute the executable program of the target task.

[0006] Thirdly, this disclosure provides a processing architecture, which includes: a compilation unit and at least one processing unit; wherein the compilation unit is used to execute the compilation method as described in any one of the embodiments of this disclosure; and the at least one processing unit is used to execute an executable program of a target task sent by the compilation unit to obtain the execution result of the target task.

[0007] Fourthly, this disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the above-described compilation method.

[0008] Fifthly, this disclosure provides an electronic device comprising: a plurality of processing cores; and an on-chip network configured to interact with data between the plurality of processing cores and external data; wherein one or more of the processing cores store one or more instructions, and the one or more instructions are executed by the one or more processing cores to enable the one or more processing cores to perform the above-described compilation method.

[0009] Sixthly, this disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-described compilation method when executed by a processing core.

[0010] The embodiments provided in this disclosure first divide the initial program of the target task into multiple program groups, thereby dividing the compilation object into multiple program groups, reducing the size of a single compilation object, facilitating the selection of the compilation method for each program according to requirements, and improving the flexibility of compilation. Second, at least some program groups are selected as target groups for approximate compilation, and the allowable error of each target group is determined, thereby clarifying which program groups should be compiled using which method, and clarifying the allowable error that the target groups performing approximate compilation should follow, providing constraints for approximate compilation. For each target group, approximate compilation is performed on the target group according to the allowable error of the target group to obtain the corresponding approximate group. On the one hand, approximate compilation of the program is achieved, reducing the overhead of various resources, and on the other hand, the accuracy of the processing results is taken into account, avoiding large errors in the processing results due to approximate compilation. In the case of program groups that have not been approximate compiled, the program groups that have not been approximate compiled are precisely compiled to obtain the corresponding precise group. The obtained approximate group and precise group constitute the executable program of the target task, thereby obtaining the complete executable program of the target task and ensuring the smooth execution of the target task.

[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0012] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the embodiments of the present disclosure to explain the disclosure and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the detailed description of exemplary embodiments with reference to the accompanying drawings, in which:

[0013] Figure 1 A flowchart of a compilation method provided in this disclosure embodiment;

[0014] Figure 2 This is a schematic diagram of the compilation of a loop body provided in an embodiment of the present disclosure;

[0015] Figure 3 This is a compilation diagram of multiple loop bodies provided in an embodiment of the present disclosure;

[0016] Figure 4 A schematic diagram of a search path provided in an embodiment of this disclosure;

[0017] Figure 5 A schematic diagram illustrating an approximate compilation of a data interaction relationship provided for an embodiment of this disclosure;

[0018] Figure 6 A schematic diagram illustrating an approximate compilation of a data interaction relationship provided for an embodiment of this disclosure;

[0019] Figure 7 A schematic diagram illustrating an approximate compilation of a data interaction relationship provided for an embodiment of this disclosure;

[0020] Figure 8 This is a schematic diagram illustrating the working process of a compilation method provided in an embodiment of this disclosure;

[0021] Figure 9 A schematic diagram illustrating the working process of determining the allowable error provided in this embodiment of the disclosure;

[0022] Figure 10 This is a schematic diagram illustrating the working process of a compilation method provided in an embodiment of this disclosure;

[0023] Figure 11 A block diagram of a compilation apparatus provided in an embodiment of this disclosure;

[0024] Figure 12 A block diagram of a processing architecture provided in an embodiment of this disclosure;

[0025] Figure 13 A block diagram of an electronic device provided in an embodiment of this disclosure;

[0026] Figure 14 This is a block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation

[0027] To enable those skilled in the art to better understand the technical solutions of this disclosure, exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments of this disclosure to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0028] Where there is no conflict, the various embodiments of this disclosure and the features thereof in the embodiments may be combined with each other.

[0029] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.

[0030] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. As used herein, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the stated feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded. Words such as “connected” or “linked” are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.

[0031] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined herein.

[0032] In related technologies, approximate computation can be achieved through approximate compilation. Approximate compilation involves converting the top-level precise logic program into an approximate program for hardware execution during the program deployment process. The approximate program and the precise program are approximately equivalent, but their implementation methods may differ.

[0033] For example, approximate compilation can be achieved through embedding and transformation methods. Embedding refers to embedding program A into another organizational form B to obtain an approximate program. For example, embedding a piece of computer program code into a cluster of neurons. Transformation refers to performing some transformations on program A to obtain program A'. Common transformation methods include removing certain computational nodes and simplifying computational logic.

[0034] However, the above-mentioned approximate compilation method processes computer program code in a relatively mechanical way, and cannot flexibly implement approximate compilation according to actual needs.

[0035] According to the compilation method of this disclosure, firstly, the initial program of the target task is divided into multiple program groups, thereby dividing the compilation object into multiple program groups, reducing the size of a single compilation object, facilitating the selection of the compilation method for each program according to requirements, and improving the flexibility of compilation; secondly, at least some program groups are selected as target groups for approximate compilation, and the allowable error of each target group is determined, thereby clarifying which program groups to perform which compilation method, and clarifying the allowable error that the target group performing approximate compilation must follow, providing constraints for approximate compilation; for each target group, approximate compilation is performed on the target group according to the allowable error of the target group to obtain the corresponding approximate group. On the one hand, approximate compilation of the program is realized, reducing the overhead of various resources (e.g., processing resources, communication resources, storage resources, etc.), and on the other hand, the accuracy of the processing results is taken into account, avoiding large errors in the processing results due to approximate compilation; in the case of program groups that have not been approximate compiled, precise compilation is performed on the program groups that have not been approximate compiled to obtain the corresponding precise group. The obtained approximate group and precise group constitute the executable program of the target task, thereby obtaining the complete executable program of the target task and ensuring the smooth execution of the target task.

[0036] The compilation method according to embodiments of this disclosure can be executed by electronic devices such as terminal devices or servers. The terminal device can be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. The method can be implemented by a processor calling computer-readable program instructions stored in memory. The server can be a standalone physical server, a server cluster consisting of multiple servers, or a cloud server capable of cloud computing.

[0037] The first aspect of this disclosure provides a compilation method.

[0038] Figure 1A flowchart illustrating a compilation method provided in an embodiment of this disclosure. (Refer to...) Figure 1 The compilation method includes:

[0039] In step S11, the initial program of the target task is divided into multiple program groups.

[0040] In step S12, at least a portion of the program groups are selected as target groups for approximate compilation, and the allowable error for each target group is determined.

[0041] In step S13, for each target group, the target group is approximated based on the allowable error of the target group to obtain the corresponding approximation group.

[0042] In step S14, if there are program groups that have not been approximated, the program groups that have not been approximated are precisely compiled to obtain the corresponding precise groups; wherein, the obtained approximation groups and precise groups constitute the executable program of the target task.

[0043] In this embodiment of the disclosure, when compiling for a target task, the initial program of the target task is first divided into multiple program groups to determine individual compilation objects. Secondly, some or all of these program groups are selected as target groups for approximate compilation, and the tolerance error for each target group is determined. Approximate compilation of the target groups is then performed based on this tolerance error. Next, for each target group, compilation is performed according to the tolerance error of that target group to obtain the corresponding approximate group. This achieves approximate compilation of the program groups, thereby reducing processing resource overhead, and ensures that the approximate group meets the tolerance error requirements, resulting in higher accuracy of the processing results obtained based on the approximate group. Finally, if there are program groups that have not undergone approximate compilation, these program groups are precisely compiled to obtain the corresponding precise group. The approximate group and the precise group together form the complete executable program corresponding to the target task, allowing the processing unit to obtain the execution result of the target task by executing this executable program.

[0044] In some alternative implementations, the target task is the task to be executed, such as any one of video processing tasks, image processing tasks, etc., and this disclosure does not limit this.

[0045] In some alternative implementations, the initial program for the target task is the source program for the target task, which includes program segments written in a high-level language or assembly language. Typically, the source program cannot be executed directly on a computer and needs to be compiled to obtain an executable program (e.g., binary code) that the computer can recognize.

[0046] In some alternative implementations, the initial program for the target task is a program written in a corresponding language based on the processing logic of the target task, which may include multiple statements.

[0047] In some alternative implementations, to take into account the flexibility of approximate compilation, the initial program for the target task can be divided into multiple program groups, each of which includes one or more statements.

[0048] In some optional implementations, step S11 includes: dividing the initial program into multiple program groups according to preset grouping requirements. The preset grouping requirements include at least one of the following: functional independence requirements, data influence range requirements, precision independent control requirements, processing kernel mapping requirements, program loop depth requirements, and task processing requirements.

[0049] For example, the functional independence requirement is used to indicate that multiple statements with relatively independent functions are divided into a program group. Therefore, in the multiple program groups obtained based on the functional independence requirement, the multiple statements in each group can implement a relatively independent function.

[0050] For example, the data scope requirement is used to group multiple statements within the scope of influence of certain data into a program group. For instance, if a parameter is a local parameter, then based on the data scope requirement, multiple statements within the local scope of influence of that parameter are grouped into a program group.

[0051] For example, precision-independent control requirements are used to group multiple statements that require individual control over approximate precision into a single program group. For instance, multiple program groups are created based on precision-independent control requirements, with multiple statements in each group corresponding to the same or similar approximate precision.

[0052] For example, the processing core mapping requirement is used to divide the target group into multiple program groups based on the mapping relationship between the target task and the various processing cores in the many-core system. For example, statements mapped to the same processing core are grouped into one program group, or statements corresponding to multiple processing cores that are close to each other are grouped into one program group.

[0053] In one possible implementation, the processing cores in the many-core system to which the target task is mapped are physical-level processing cores. That is, the target task first needs to be mapped based on processing cores in the physical-level many-core system. Then, based on the mapping results of the target task in the processing cores, the initial program is divided into multiple program groups. This method of program grouping allows target tasks mapped to different processing cores to be grouped into a single program group, facilitating approximate compilation and execution by the corresponding mapped physical core.

[0054] The aforementioned technical solution of first mapping and then partitioning the program based on the mapping result is essentially a "hardware-software combined" approach. For example, after mapping the target task to a physical processing core, when partitioning the initial program corresponding to the target task according to the mapping result, programs corresponding to the same processing core can be grouped together for approximate or exact compilation. After compilation, the processing core can then execute the program. This approach prevents the same processing core from executing both the exact and approximate programs simultaneously.

[0055] For example, in the case where a processing core maps to a program group, the program group should uniformly adopt an approximate compilation method or an exact compilation method so that the processing core only executes the approximate program or only executes the exact program.

[0056] For example, in the case of a processing core mapping multiple program groups, the multiple program groups should adopt the same compilation method as much as possible. That is, the multiple program groups should all adopt an approximate compilation method or an exact compilation method to ensure that the current processing core only executes the approximate program or only executes the exact program.

[0057] For example, in the case where multiple processing cores map a program group, the multiple processing cores should process the program group in the same way to avoid some processing cores performing approximate compilation of the program group while the remaining processing cores perform exact compilation of the program group.

[0058] It should be noted that the above mapping between the processing kernel and the program group is only an example. In other mapping cases, the compilation method of the program group can still be determined based on the principle that the processing kernel only executes the approximate program or only executes the exact program.

[0059] For example, the requirement for the number of loop levels refers to dividing the initial program according to the number of loop levels, so that loops with more loop levels are grouped into different groups. This is because during the approximation process, if the part to be approximated contains multiple loops, the approximation error may accumulate with each loop, resulting in a large error. Therefore, multiple loops with more loop levels are divided into different program groups as much as possible, so that a program group contains fewer loops with more loop levels.

[0060] For example, task processing requirements refer to dividing the initial program into multiple program groups based on the actual needs of task processing. For instance, programmers may divide the initial program into multiple program groups based on any one or more of the following: task processing logic, experience, statistical data, simulation data, etc.

[0061] It should be noted that in the process of dividing the initial program of a target task, one or more of the above-mentioned preset grouping requirements can be used for division, and this disclosure embodiment does not impose any restrictions on this. For example, functional independence requirements can be used to group a portion of the initial program, and program loop depth requirements can be used to group the remaining portion of the initial program.

[0062] It should also be noted that the above division of program groups is only an example. In practical applications, the division can also be based on the processing resources, storage resources, storage locations, etc. required by the program. This disclosure does not limit this.

[0063] In some optional implementations, after obtaining multiple program groups, in step S12, at least a portion of the program groups can be selected as target groups for approximate compilation, and the allowable error for each target group needs to be determined. Selecting at least a portion of the program groups as target groups includes two cases: the first case is selecting a portion of the program groups as target groups, leaving some program groups remaining, which are then processed using an exact compilation method; the second case is selecting all program groups as target groups, thus eliminating any program groups requiring exact compilation.

[0064] It should be noted that in the process of dividing and determining target groups, it is often difficult to directly determine the allowable error for each target group. Considering that a computer service is often deployed in a specific scenario, and the service's quality requirements are also determined by that scenario, the allowable error can be iteratively updated and ultimately determined based on feedback from the environment in a test or real-world setting.

[0065] In some optional implementations, the service recipient can provide a rating by interacting with the environment. The tolerance error is then updated based on the rating, ultimately resulting in a scientifically reasonable tolerance error. The rating can be a specific evaluation score, or it can be simplified to two cases: meeting the standard or not meeting the standard. This disclosure does not impose any limitations on this approach.

[0066] In some optional implementations, determining the allowable error for each target group includes: initializing the allowable error for each target group; running the approximate service corresponding to each target group based on the allowable error; evaluating each approximate service to obtain evaluation information for each approximate service; and iteratively updating the allowable error for each approximate service based on the evaluation information until a preset stopping condition is met, thus obtaining the final allowable error for each target group. The stopping condition may be that the number of iterations is greater than or equal to a preset iteration threshold, or that the allowable error meets the expected allowable error, etc., and this disclosure does not limit this.

[0067] In some optional implementations, some target groups may include at least one loop body, which includes at least one set of loop hierarchy statements and at least one set of execution statements. Correspondingly, based on the allowable error of the target group, the target group is approximated to obtain a corresponding approximation group, including: selecting at least one set of loop hierarchy statements and / or at least one set of execution statements from the loop body as target statements, approximating the target statements based on the allowable error of the target group, and precisely compiling the remaining statements in the target group to obtain the corresponding approximation group.

[0068] In other words, for the loop body in the target group, you can choose to approximate the compilation of one or more loop level statements and compile the remaining statements exactly, or approximate the compilation of one or more execution statements and compile the remaining statements exactly, or approximate the compilation of both loop level statements and execution statements and compile the remaining statements exactly.

[0069] It should be noted that, due to the different target tasks and programming implementation methods, in some implementation methods, the target groups determined by the initial program based on the target task may include one or more loop bodies in some target groups, while the remaining target groups may not contain loop bodies. In other implementation methods, all target groups may not contain loop bodies. This disclosure does not impose any restrictions on this.

[0070] Furthermore, for cases where the initial program for the target task includes one or more loops, the program groups can be divided in conjunction with requirements such as the number of loop levels, so as to alleviate the accumulation of errors caused by loop level iterations during subsequent approximate compilation.

[0071] Figure 2 This is a schematic diagram illustrating the compilation of a loop body according to an embodiment of this disclosure. (Refer to...) Figure 2 The loop body consists of three sets of loop level statements and one set of execution statements. The first loop level, for loop1, corresponds to the outermost loop level; the second loop level, for loop2, corresponds to the middle loop level; and the third loop level, for loop3, corresponds to the innermost loop level. The execution statement is do sth.

[0072] like Figure 2As shown, all statements in the loop body can be used as target statements, thus performing approximate compilation on all statements; alternatively, the second loop level statements, the third loop level statements, and the executed statement can be used as target statements, performing approximate compilation on the target statements and performing exact compilation on the remaining first loop level statements; alternatively, the third loop level statements and the executed statement can be used as target statements, performing approximate compilation on the target statements and performing exact compilation on the remaining first and second loop level statements; alternatively, the executed statement can be used as the target statement, performing approximate compilation on the target statement and performing exact compilation on the remaining three sets of loop level statements.

[0073] In summary, approximate compilation of a target group refers to approximating at least some statements within the target group, not necessarily all statements in the target group. In other words, there must be at least one statement in the target group that uses approximate compilation, while there may also be some statements that use exact compilation.

[0074] It's important to note that approximating the loops for a smaller number of loop levels while retaining the original loop control logic for larger loop levels reduces the difficulty and complexity of the approximation process. However, this approach causes the error from approximating the loop levels to accumulate across the loop levels that retain the original loop control logic, resulting in a larger error. Approximating the loops for a larger number of loop levels (or all loop levels) ensures that this error meets the preset requirements, thus preventing the accumulation of this error in loops with fewer loop levels (or no loops). However, this approach may be more difficult and complex.

[0075] by Figure 2 For example, if only the third loop level statement is approximated and compiled, assuming the error is δ, this error δ will accumulate with the loops of the second and first loop levels, resulting in an actual error much greater than δ. However, since the number of loop levels in the approximation is small, the approximation process is relatively simple. If the first loop level statement, the second loop level statement, and the first loop level statement are all approximated and compiled, assuming the error is ε, this error ε is a relatively fixed error and will not accumulate with the loop. However, since the number of loop levels in the approximation is large, the approximation process is more complex.

[0076] In some alternative implementations, when the target group includes multiple loop bodies, the shared and independent statements among these loop bodies can be identified first, then the target statements can be selected and approximately compiled, while the remaining statements can be precisely compiled.

[0077] Shared statements are loop level statements and execution statements that are the same between loop bodies, while independent statements are loop level statements and execution statements that are different between loop bodies.

[0078] For example, based on the allowable error of the target group, the target group is approximated to obtain a corresponding approximation group. This includes: determining the shared and independent statements between loop bodies; selecting at least a portion of the statements from the shared and / or independent statements as target statements; approximating the target statements based on the allowable error of the target group; and precisely compiling the remaining statements to obtain the corresponding approximation group. The shared statements may include loop-level statements, executable statements, or both; similarly, the independent statements may include loop-level statements, executable statements, or both.

[0079] The selection of the target statement is still based on the trade-off between the cost of approximation and the accumulation of error. If there are more loop levels to approximate, more approximation costs are required; conversely, if there are fewer loop levels to approximate, it means that the error caused by approximation will accumulate with each loop iteration, resulting in a larger error.

[0080] The following is combined Figure 3 The method of approximate compilation for multiple loop bodies in the embodiments of this disclosure will be described in detail.

[0081] Figure 3 This is a schematic diagram illustrating the compilation of multiple loop bodies provided in an embodiment of this disclosure. (Refer to...) Figure 3 The program group consists of loop body 1 and loop body 2. Loop body 1 consists of three sets of loop level statements and one set of execution statements: the outermost loop level statement `for loop1`, the middle loop level statement `for loop2`, the innermost loop level statement `for loop3`, and the execution statement `do sth.(a)`. Loop body 2 consists of three sets of loop level statements and one set of execution statements: the outermost loop level statement `for loop1`, the middle loop level statement `for loop2`, the innermost loop level statement `for loop4`, and the execution statement `do sth.(b)`. Therefore, the loop level statements `for loop1` and `for loop2` are shared statements between the two loop bodies, the loop level statement `for loop3` and the execution statement `do sth.(a)` are independent statements of loop body 1, and the loop level statement `for loop4` and the execution statement `do sth.(b)` are independent statements of loop body 2.

[0082] like Figure 3As shown, for loop body 1 and loop body 2, at least some statements can be selected as target statements from shared statements and / or independent statements. For example, statements other than the shared statement `for loop1` are selected as target statements; statements other than the shared statements `for loop1` and `for loop2` are selected as target statements; the independent statements `for loop4` and `do sth.(b)` of loop body 2 are selected as target statements; the independent statements `for loop3` and `do sth.(a)` of loop body 1 are selected as target statements; the shared statement `for loop1` and the independent statements `for loop4` and `do sth.(b)` of loop body 2 are selected as target statements; and the shared statement `for loop1` is selected as the target statement. After determining the target statements, the target statements can be approximated based on the allowable error of the target group, and the remaining statements can be precisely compiled to obtain the corresponding approximation group.

[0083] It should be noted that, Figure 3 The present disclosure merely illustrates several ways to combine target statements and does not limit the scope of the embodiments described herein.

[0084] It should also be noted that the above-mentioned shared and independent statements between loop bodies can be executed for multiple loop bodies in the same program group or for multiple loop bodies in different program groups. This disclosure does not limit this.

[0085] In some optional implementations, in step S13, the target group is approximated and compiled according to the allowable error of the target group to obtain the corresponding approximation group. This includes: obtaining the error cost association information of the preset approximator, which is used to characterize the relationship between the cost and error corresponding to the approximator with different approximation parameters. The approximator includes a neural network approximator or a lookup table approximator; determining the target error based on the error cost association information and the allowable error of the target group according to the preset search strategy; determining the approximator corresponding to the target error and the approximation parameters of the approximator; and approximating and compiling the target group according to the approximator based on the approximation parameters to obtain the corresponding approximation group.

[0086] For example, for a neural network approximator, different approximation parameters correspond to different costs, and different costs correspond to different errors. Therefore, an error-cost correlation curve can be pre-plotted. The horizontal axis of this curve represents the cost, and the vertical axis represents the error. Through each point on the curve, the error value and approximation parameters corresponding to that cost can be obtained. The approximation parameters include the network layer, number of nodes, and weight values ​​of the neural network.

[0087] Similarly, for lookup table approximators, error cost correlation curves can be pre-plotted, with approximation parameters including storage space occupied and storage location.

[0088] Taking neural network approximators as an example, a neural network is continuously trained on the inputs and outputs of the program to be approximated (i.e., the target group) using a neural network approximator to obtain a neural network that is approximately equivalent to the original program. The higher the cost of the approximator (related to the size of the neural network, generally, the larger the neural network, the higher the cost), the higher the approximation accuracy tends to be. Typically, search strategies are needed to find an approximator that satisfies the acceptable error while minimizing the cost, achieving a balance between cost and approximation accuracy.

[0089] In some optional implementations, the search strategy includes linear search, binary search, etc. Correspondingly, based on the error cost correlation curve, the approximator and its approximation parameters that meet the allowable error of the target group can be determined, and then approximate compilation can be performed based on the approximation parameters and approximator.

[0090] It should be noted that the above search strategies are merely illustrative examples, and the embodiments disclosed herein do not impose any limitations on them.

[0091] The following is combined Figure 4 The search path shown is used to elaborate on the method of determining approximators based on the search strategy.

[0092] Figure 4 This is a schematic diagram of a search path provided in an embodiment of this disclosure. (Refer to...) Figure 4In a coordinate system consisting of the x-axis corresponding to the cost and the y-axis corresponding to the error, an error-cost correlation curve is plotted, showing the position of the allowable error in the coordinate system (corresponding to a dashed line). First, a search point 1 is determined. By comparing the error corresponding to search point 1 with the allowable error, it is found that the error corresponding to search point 1 is greater than the allowable error. Therefore, a search point 2 with a smaller error is determined. By comparing the error corresponding to search point 2 with the allowable error, it is found that the error corresponding to search point 2 is less than the allowable error. Therefore, an arrow connecting search point 1 and search point 2, pointing towards search point 2, is drawn, representing the first search path. The intersection of the center point of this search path and the error-cost correlation curve is taken as search point 3. By comparing the error corresponding to search point 3 with the allowable error, it is found that the error corresponding to search point 3 is less than the allowable error. Therefore... Draw an arrow connecting search point 2 and search point 3, pointing towards search point 3, to represent the second search path. Take the intersection of the center point of this search path and the error cost correlation curve as search point 4, and repeat the above process until search point 6 is determined. Compare the error corresponding to search point 6 with the allowable error. It can be seen that the error corresponding to search point 6 is close to the allowable error. Therefore, the error corresponding to search point 6 is determined as the target error, and the approximator and its approximation parameters corresponding to the target error are determined. Then, based on the approximator, the corresponding target group is approximated by the corresponding approximation parameters to obtain the corresponding approximation program as the approximation group.

[0093] In some alternative implementations, when there are program groups that have not been approximated, a precise compilation method is used to process these program groups to obtain the corresponding precise compilation groups. The approximation groups and precise compilation groups obtained above constitute the complete executable program for the target task, which is then executed by the computer / processing core or other processing units to obtain the execution result of the target task.

[0094] It should be noted that in some optional implementations, there may be some target groups that cannot obtain approximate groups that meet the tolerance error, or the cost of meeting the tolerance error is too high (for example, for neural network approximators, the training time required to meet the tolerance error requirement is too long). Therefore, in this case, the initial program can be regrouped to obtain multiple new program groups, or the program groups corresponding to these approximate groups can be precisely compiled.

[0095] It should also be noted that in many-core mapping, an approximate group is often mapped to a processing core or a core group consisting of similar processing cores, and data transmission between approximate groups is usually converted into routing transmission between processing cores. Therefore, in order to save routing resources, in some optional implementations, based on the aforementioned approximate compilation, further approximate processing can be performed on the data transmission between approximate groups and / or exact groups.

[0096] In some optional implementations, after step S14, the method further includes: determining the data interaction relationship between the approximate group and / or the exact group; and approximating the data interaction relationship. By approximating the data interaction relationship, the amount of data transmission can be reduced, thereby further reducing the consumption of processing resources, communication resources, and other resources.

[0097] In some alternative implementations, the data interaction relationships can be approximated based on data compression and / or pruning methods.

[0098] Figure 5 This is a schematic diagram illustrating an approximate compilation of a data interaction relationship provided for an embodiment of this disclosure. (Refer to...) Figure 5 Between two approximate and / or exact groups that have a data interaction relationship, the data interaction relationship can be approximated by data compression and / or pruning.

[0099] like Figure 5 As shown, approximate compilation of data interaction relationships can occur between two approximate groups, between two exact groups, or between an approximate group and an exact group. This disclosure does not limit this.

[0100] For example, the data compression method is implemented by adding an encoding unit at the output end of the approximate or precise group corresponding to the data sender, and by adding a decoding unit at the input end of the approximate or precise group corresponding to the data receiver. The encoding unit performs compression encoding, and the decoding unit decodes the compressed data. Furthermore, after being encoded by the encoding unit, the data size is reduced, thereby reducing the amount of data transmitted and minimizing the overhead of communication and storage resources.

[0101] For example, the pruning method is implemented by discarding the transmission of a portion of the output data from the approximate group or the exact group corresponding to the data sender to the data receiver. In other words, multiple data transmission paths between the approximate group and / or the exact group are pruned, retaining only a portion of the data transmission paths.

[0102] It should be noted that approximating the data interaction relationships will further reduce the overall execution accuracy of the target task. In this case, the neural network can be further trained to approximate the target group's program, thus ensuring that its accuracy still meets the allowable error. If training still fails to meet the allowable error, or if the training cost is too high, a different neural network approximator with different approximation parameters (at a relatively higher cost) can be selected and retrained to improve the approximation accuracy to meet the allowable error. Alternatively, a lookup table approximator with different approximation parameters can be selected and re-applied to improve the approximation accuracy to meet the allowable error.

[0103] Figure 6 This is a schematic diagram illustrating an approximate compilation of a data interaction relationship provided for an embodiment of this disclosure. (Refer to...) Figure 6 An encoding unit is added to the output of approximation group 1 to compress and encode the data to be output, and then the compressed and encoded data is transmitted to approximation group 2. Conversely, a decoding unit is added to the input of approximation group 2 to decode the data transmitted from approximation group 1, thereby decompressing the input data and obtaining the decompressed input data. In this data interaction process, the transmitted data is compressed and encoded, thus effectively reducing the amount of data transmitted.

[0104] It should be noted that if approximation group 1 and approximation group 2 are approximation groups obtained based on neural network approximators, one or more network layers with compression coding function can be added as coding units after the neural network corresponding to approximation group 1. Similarly, one or more network layers with compression decoding function can be added as decoding units before the neural network corresponding to approximation group 2.

[0105] Figure 7 This is a schematic diagram illustrating an approximate compilation of data interaction relationships provided in an embodiment of the present disclosure, wherein... Figure 7 (a) shows the data interaction relationship between approximation group 1 and approximation group 2 without pruning. Figure 7 (b) illustrates a schematic diagram of the approximate compilation of the data interaction relationship between approximation group 1 and approximation group 2 based on pruning. (Refer to...) Figure 7 (a) Without pruning, there are nine data transmission paths between approximation group 1 and approximation group 2, resulting in complex data interaction and requiring significant communication, storage, and processing resources. Figure 7 In (b), this data interaction relationship is pruned, retaining only four data transmission paths, which reduces the consumption of communication resources, storage resources and processing resources, and can improve resource utilization.

[0106] The following is combined Figures 8-10 The compilation method of the embodiments of this disclosure will be described in detail.

[0107] Figure 8 This is a schematic diagram illustrating the working process of a compilation method provided in an embodiment of this disclosure. (Refer to...) Figure 8 First, the initial program for the target task is obtained, which includes multiple nodes. Each node corresponds to a relatively independent functional unit, which can consist of one or more statements. After obtaining the initial program, it is divided into three program groups, g1, g2, and g3, according to preset grouping requirements. These three program groups are selected as the target groups for approximate compilation. In other words, g1, g2, and g3 are all target groups.

[0108] Further, the allowable error for each target group is determined, where the allowable error for target group g1 is e1, the allowable error for target group g2 is e2, and the allowable error for target group g3 is e3. Then, for each target group, when it contains multiple loop bodies, the shared and independent statements among these loop bodies are determined, and at least a portion of the statements from the shared and / or independent statements are selected as target statements. For example... Figure 8 As shown, it is assumed that there are multiple loop bodies in target group g1 and target group g3, and the relationship of shared statements between loop bodies within the group is represented by the arrows in the figure.

[0109] Furthermore, for target group g1, target group g2 and target group g3, approximate compilation is performed according to their respective allowable errors to obtain approximate group g1' corresponding to target group g1, approximate group g2' corresponding to target group g2, and approximate group g3' corresponding to target group g3.

[0110] Furthermore, compression processing is applied to the data interaction relationship between target group g1' and target group g2'. This involves adding an encoding unit at the output of approximation group g1' to compress and encode the output data of target group g1', and adding a decoding unit at the input of approximation group g2' to compress and decode the input data of target group g1'. Additionally, pruning processing is applied to the data interaction relationship between target group g2' and target group g3'. Before pruning, there should be 8 data transmission paths between target groups g2' and g3'; after pruning, three data transmission paths are deleted, leaving only five data transmission paths. Through the above compression and pruning processing, the approximation groups are transformed from g1', g2', and g3' into... Figure 8 The g1”, g2”, and g3” shown are used to obtain the executable program for the target task.

[0111] The following is through Figure 9 ,right Figure 8 The process of determining the allowable error for each target group will be explained in detail.

[0112] Figure 9 This is a schematic diagram illustrating a working process for determining the allowable error, provided as an embodiment of this disclosure. (Refer to...) Figure 9First, the initial program for the target task is obtained and divided into multiple program groups, all of which are designated as target groups (i.e., target groups include g1, g2, and g3). Then, the tolerance errors for target groups g1, g2, and g3 are initialized respectively. Initialization can be achieved by randomly assigning an error value; however, this initial tolerance error is usually inaccurate and requires subsequent evaluation and iterative updates to obtain a more accurate and reasonable tolerance error. Further, based on the initialized tolerance errors, the approximate services corresponding to each target group are run, and the service recipients evaluate each approximate service to obtain a service score S. The service score S includes the approximate service score s1 for target group g1, the approximate service score s2 for target group g2, and the approximate service score s3 for target group g3.

[0113] Furthermore, the influence of each target group on the execution result of the target task is determined, resulting in the influence proportion factor r1 for target group g1, r2 for target group g2, and r3 for target group g3. Here, r1, r2, and r3 are all real numbers greater than zero and less than 1, and r1 + r2 + r3 = 1. In some optional implementations, each program group is represented using a computational graph. In this case, after obtaining the scores of the target groups, the influence proportion factor of each target group can be determined through backpropagation.

[0114] Furthermore, the tolerance error for each target group is updated based on its score and influence factor. For example... Figure 9 As shown, the allowable error of target group g1 is updated from e1 to e1±r1×s1, the allowable error of target group g2 is updated from e2 to e2±r2×s2, and the allowable error of target group g3 is updated from e3 to e3±r3×s3. When the service score is greater than the benchmark value, it indicates that the service quality of the approximate service is high, therefore the allowable error can be further increased; hence, "±" is taken as "+". Conversely, when the service score is less than the benchmark value, it indicates that the service quality of the approximate service is low, therefore the allowable error needs to be further reduced; hence, "±" is taken as "-". The benchmark value can be a benchmark value for the whole, in which case the allowable error of each target group is uniformly increased or decreased; or the benchmark value can be a benchmark value for each approximate service, in which case the allowable error of each target group is individually increased or decreased based on the comparison result of its own service score with the benchmark value.

[0115] After completing this update, determine whether the preset stopping condition is met. If it is determined that the stopping condition is not met, repeat the above process until the stopping condition is met. Then, take the tolerance error of each target group at this time as the final tolerance error.

[0116] Figure 10 This is a schematic diagram illustrating the working process of a compilation method provided in an embodiment of this disclosure. (Refer to...) Figure 10 The compilation method includes:

[0117] Step S1001: Divide the initial program of the target task into multiple program groups.

[0118] Step S1002: Select at least a portion of the program groups as target groups for approximate compilation, and determine the permissible error for each target group.

[0119] Step S1003: For each target group, perform approximate compilation on the target group according to the allowable error of the target group to obtain the corresponding approximate group.

[0120] After obtaining the approximate group, if there is a program group that has not been approximated, then proceed to step S1004; otherwise, proceed to step S1005.

[0121] Step S1004: In the case of program groups that have not been approximated, perform exact compilation on the program groups that have not been approximated to obtain the corresponding exact groups.

[0122] Based on this, the compilation data for all program groups was obtained, and the process ended.

[0123] Step S1005: Determine whether each approximation group meets the corresponding tolerance error requirements.

[0124] If at least one approximation group fails to meet the tolerance error, proceed to step S1006 or step S1006'; otherwise, end the process.

[0125] Step S1006: Perform precise coding on the program group corresponding to the approximation group that cannot meet the tolerance error.

[0126] After accurately compiling the program groups corresponding to the approximate groups that cannot meet the tolerance error, the compilation data of all program groups is obtained, and the process ends.

[0127] Step S1006': Regroup the initial program to obtain multiple new program groups.

[0128] It should be noted that after step S1006' is executed, the process jumps to step S1002, selects a new target group from multiple new program groups, and executes the subsequent steps in sequence.

[0129] It is understood that the various method embodiments mentioned above in this disclosure can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this disclosure will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.

[0130] A second aspect of this disclosure provides a compilation apparatus.

[0131] Figure 11 A block diagram of a compilation apparatus provided according to an embodiment of this disclosure. (Refer to...) Figure 11 The compiler 1100 includes:

[0132] The partitioning module 1101 is used to divide the initial program of the target task into multiple program groups.

[0133] The determination module 1102 is used to select at least a portion of the program groups as target groups for approximate compilation and to determine the permissible error for each target group.

[0134] The approximate compilation module 1103 is used to perform approximate compilation on each target group according to the allowable error of the target group, so as to obtain the corresponding approximate group.

[0135] The precise compilation module 1104 is used to perform precise compilation on the program group that has not been approximated when such program group exists, to obtain the corresponding precise compilation group. The obtained approximation group and precise compilation group constitute the executable program of the target task.

[0136] The embodiments provided in this disclosure firstly divide the initial program of the target task into multiple program groups by a partitioning module, thereby dividing the compilation object into multiple program groups, reducing the size of a single compilation object, facilitating the selection of the compilation method for each program according to requirements, and improving the flexibility of compilation; secondly, a determining module selects at least some program groups as target groups for approximate compilation and determines the allowable error for each target group, thereby clarifying which program groups should be compiled using which method and specifying the allowable error that the target groups performing approximate compilation must follow, providing constraints for approximate compilation; for each target group, the approximate compilation module, according to the target... The allowable error of the target group is considered. The target group is approximated and compiled to obtain the corresponding approximate group. On the one hand, this approximate compilation of the program reduces the overhead of various resources (such as processing resources, communication resources, storage resources, etc.). On the other hand, it also takes into account the accuracy of the processing results and avoids large errors in the processing results due to approximate compilation. In the case of program groups that have not been approximated and compiled, the accurate compilation module is used to accurately compile the program groups that have not been approximated and compiled to obtain the corresponding accurate group. The obtained approximate group and accurate group constitute the executable program of the target task, thus obtaining the complete executable program of the target task and ensuring the smooth execution of the target task.

[0137] A third aspect of the present disclosure provides a processing architecture.

[0138] Figure 12 This is a block diagram of a processing architecture provided in an embodiment of this disclosure. (Refer to...) Figure 12 The processing architecture 1200 includes a compilation unit 1210 and at least one processing unit 1220.

[0139] The compilation unit 1210 is used to execute the compilation method of any one of the embodiments of this disclosure; at least one processing unit is used to execute the executable program of the target task sent by the compilation unit 1210 to obtain the execution result of the target task.

[0140] In some alternative implementations, the processing unit can be a processing core in a single-core processing system or one or more processing cores in a many-core system, and the embodiments disclosed herein do not limit this.

[0141] It should be noted that the compilation unit and the processing unit can adopt a streaming data processing method. That is, once the compilation unit obtains a partial executable program, it can send this part of the executable program to the processing unit for execution. At the same time, the compilation unit compiles the uncompiled program groups. Based on this method, the processing unit can synchronously execute the already compiled executable program without waiting for the compilation unit to complete all the compilation work of the initial program, thereby further improving the task processing efficiency.

[0142] According to embodiments of this disclosure, in the processing architecture, the compilation unit supports approximate compilation of part or all of the initial program of the target task, thereby improving the flexibility of compilation and ensuring that the error of the approximation group meets the allowable error requirements, avoiding excessive program distortion due to approximate compilation, which would fail to meet the task processing requirements; the processing unit can receive the executable program compiled by the compilation unit and obtain the execution result of the target task by executing the executable program. In this process, since at least part of the executable program is approximated, the number of various resources consumed by executing the executable program is reduced, thereby improving the resource utilization of the processing unit.

[0143] In addition, this disclosure also provides electronic devices and computer-readable storage media, all of which can be used to implement any of the compilation methods provided in this disclosure. The corresponding technical solutions and descriptions are described in the corresponding records in the method section and will not be repeated here.

[0144] Figure 13 This is a block diagram of an electronic device provided in an embodiment of the present disclosure.

[0145] Reference Figure 13 This disclosure provides an electronic device comprising: at least one processor 1301; at least one memory 1302; and one or more I / O interfaces 1303 connected between the processor 1301 and the memory 1302; wherein the memory 1302 stores one or more computer programs executable by the at least one processor 1301, the one or more computer programs being executed by the at least one processor 1301 to enable the at least one processor 1301 to execute the above-described compilation method, or to execute an executable program obtained by the compilation method.

[0146] Figure 14 This is a block diagram of an electronic device provided in an embodiment of the present disclosure.

[0147] Reference Figure 14 This disclosure provides an electronic device that includes multiple processing cores 1401 and an on-chip network 1402. The multiple processing cores 1401 are all connected to the on-chip network 1402, and the on-chip network 1402 is used to exchange data between the multiple processing cores and external data.

[0148] One or more processing cores 1401 store one or more instructions, which are executed by one or more processing cores 1401 to enable one or more processing cores 1401 to execute the above-described compilation method or to execute the executable program obtained by the compilation method.

[0149] In some embodiments, the electronic device may be a neuromorphic chip. Since neuromorphic chips can employ vectorized computation and require external memory, such as Double Data Rate (DDR) synchronous dynamic random access memory, to load parameters such as weights of the neural network model, the batch processing method used in this embodiment offers higher computational efficiency.

[0150] This disclosure also provides a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor / processor core, implements the above-described compilation method, or executes an executable program obtained by the compilation method. The computer-readable storage medium may be volatile or non-volatile.

[0151] This disclosure also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code. When the computer-readable code is run in a processor of an electronic device, the processor in the electronic device executes the above-described compilation method, or executes an executable program obtained by the compilation method.

[0152] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer storage media (or non-transitory media) and communication media (or transient media).

[0153] As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technologies, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable program instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0154] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0155] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.

[0156] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0157] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0158] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0159] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0160] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0161] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in connection with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.

Claims

1. A method of compiling, characterized by, include: The initial program for the target task is divided into multiple program groups; Select at least a portion of the program groups as target groups for approximate compilation, and determine the permissible error for each target group; For each target group, an approximate compilation is performed on the target group according to the allowable error of the target group to obtain the corresponding approximate group; In the case of a program group that has not been approximated, the program group that has not been approximated is precisely compiled to obtain the corresponding precise group; The obtained approximate set and the precise set constitute the executable program of the target task; The initial program for the target task is divided into multiple program groups, including: According to the preset grouping requirements, the initial program is divided into multiple program groups; The preset grouping requirements include at least one of the following: functional independence requirements, data influence range requirements, precision independent control requirements, processing kernel mapping requirements, program loop layer requirements, and task processing requirements. The processing core mapping requirement is used to divide the target group into multiple program groups based on the mapping relationship between the target task and each processing core in the many-core system; The step of approximating the target group based on the allowable error of the target group to obtain a corresponding approximation group includes: Obtain the error cost association information of the preset approximator, which is used to characterize the relationship between the cost and error corresponding to approximators with different approximation parameters; Based on the error cost correlation information and the allowable error of the target group, the target error is determined according to a preset search strategy; Determine the approximator corresponding to the target error and the approximation parameters of the approximator; Based on the approximation parameters, the target group is approximated and compiled based on the approximator to obtain the corresponding approximation group.

2. The method of claim 1, wherein, The target group in the part includes at least one loop body, the loop body including at least one set of loop hierarchy statements and at least one set of execution statements; The step of approximating the target group based on the allowable error of the target group to obtain a corresponding approximation group includes: Select at least one set of loop level statements and / or at least one set of execution statements from the loop body as target statements, and perform approximate compilation on the target statements according to the allowable error of the target group, and perform exact compilation on the remaining statements in the target group to obtain the corresponding approximate group.

3. The method of claim 2, wherein, The target group includes multiple loop bodies; The step of approximating the target group based on the allowable error of the target group to obtain a corresponding approximation group includes: Determine the shared and independent statements between the loop bodies. The shared statements are the same loop level statements and execution statements between the loop bodies, and the independent statements are different loop level statements and execution statements between the loop bodies. At least a portion of the statements are selected from the shared statements and / or the independent statements as the target statements. The target statements are then approximated and compiled according to the allowable error of the target group. The remaining statements are then precisely compiled to obtain the corresponding approximation group.

4. The method of claim 1, wherein, The compilation method further includes: Determine the data interaction relationships between approximate groups and / or exact groups; The data interaction relationship is approximated and compiled.

5. The method of claim 4, wherein, The approximate compilation of the data interaction relationship includes: The data interaction relationship is approximated based on data compression and / or pruning methods.

6. The method of claim 5, wherein, The data compression method is achieved by adding an encoding unit at the output end of the approximate group or precise group corresponding to the data sender, and by adding a decoding unit at the input end of the approximate group or precise group corresponding to the data receiver. The pruning method is achieved by abandoning the transmission of a portion of the output data of the approximate or exact group corresponding to the data sender to the data receiver.

7. The method of claim 1, wherein, After selecting at least a portion of the program groups as target groups for approximate compilation and determining the permissible error for each target group, the method further includes: If an approximate group that satisfies the tolerance cannot be obtained, the initial program is regrouped to obtain multiple new program groups, or the program groups corresponding to the approximate groups are precisely compiled.

8. The method of claim 1, wherein, Determining the permissible error for each of the target groups includes: Initialize the tolerance error for each target group; Based on the tolerance error, run the approximate service corresponding to each target group; Each of the approximate services is evaluated to obtain evaluation information for each of the approximate services; Based on the evaluation information, the tolerance error of each approximate service is iteratively updated until a preset stopping condition is met, thus obtaining the final tolerance error of each target group.

9. A compiling apparatus characterized by comprising: For implementing the method as described in any one of claims 1-8, comprising: The partitioning module is used to divide the initial program of the target task into multiple program groups; A determination module is used to select at least a portion of the program groups as target groups for approximate compilation, and to determine the permissible error for each of the target groups; An approximate compilation module is used to perform approximate compilation on each target group according to the allowable error of the target group to obtain the corresponding approximate group; The exact compilation module is used to perform exact compilation on program groups that have not been approximated, in the case of existing program groups, to obtain the corresponding exact compilation. The obtained approximate set and the precise set constitute the executable program for the target task.

10. A processing architecture characterized by, include: A compilation unit and at least one processing unit; The compilation unit is used to execute the compilation method as described in any one of claims 1-8; The at least one processing unit is used to execute the executable program of the target task sent by the compilation unit, and obtain the execution result of the target task.

11. An electronic device, comprising: include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the compilation method as described in any one of claims 1-8.

12. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by a processor, implements the compilation method as described in any one of claims 1-8.