Apparatus and method for generating and compiling decision tree software code
By optimizing the generation and compilation of the decision tree software code based on statistical data on the data processing device, the problem of code execution time optimization in the prior art is solved, and the prediction performance of the decision tree is significantly improved.
Patent Information
- Application Number
- CN202280099594.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-02
- Publication Date
- 2025-04-08
AI Technical Summary
In the prior art, when generating and compiling software code that implements decision trees, it is difficult to effectively optimize the code execution time, resulting in poor prediction performance.
The data processing device generates software code based on the training data set, executes the code to predict the result of the decision tree, and optimizes the code based on the statistical data of the prediction data set, dynamically generates highly optimized code and compiles it on the fly.
Improved prediction performance of decision trees, improve access locality and cache efficiency through dynamic code generation and instant compilation, reduce errors in code size and condition selectivity, optimize Boolean conditions, and thus reduce branch prediction error punishment.
Smart Images

Figure CN119790377A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to code generation and compilation. More specifically, the present invention relates to an apparatus and method for generating and compiling software code implementing a decision tree. Background Art
[0002] A decision tree (DT) is a popular predictive model used in statistics, data mining, and machine learning. A decision tree is usually a final result from the observation of an item (represented as the branches of the decision tree) to the target value of the item (represented as the leaves of the decision tree). Decision trees can also be used to represent Boolean expressions, where the internal nodes represent Boolean conditions and the leaves represent the results, such as true or false, yes or no. For this reason, decision trees are used as the underlying structure by many very popular machine learning enhancement algorithms (such as XGBoost, Random Forest, AdaBoost, etc.). Decision trees can be used for classification and regression tasks. Summary of the invention
[0003] It is an object of the present invention to provide improved apparatus and methods for generating and compiling software code implementing a decision tree.
[0004] The above and other objects are achieved by the subject matter claimed in the independent claims. Other implementations are apparent from the dependent claims, the description and the drawings.
[0005] According to a first aspect, a data processing apparatus is provided. The data processing apparatus, which may be implemented as a server, may include processing circuitry, such as one or more processors for performing the following operations.
[0006] The data processing device is used to generate software code based on a first data set (also referred to herein as a training data set), wherein the software code includes multiple conditions, such as conditional statements and / or conditional expressions for implementing a decision tree.
[0007] In addition, the data processing device is used to execute the software code to determine (i.e., predict) the corresponding result of the decision tree of the first subset of the second data set (also referred to herein as the prediction data set). In order to execute the software code, the data processing device can be used to compile the source code version of the software code into the machine code version of the software code.
[0008] The first data set may include a data tuple including data for evaluating the condition. The first data set may be read from a memory of the data processing device and / or may be received by a communication device of the data processing device from another server (particularly a cloud server). The first data set may be stored, for example, in a repository file, a database, or a storage object.
[0009] The data processing device is also used to collect statistical data based on a second subset of the second data set (i.e., the predicted data set). As used herein, collecting statistical data based on the second subset of the second data set (i.e., the predicted data set) may include determining (i.e., predicting) a corresponding result of a decision tree for the second subset of the second data set and / or collecting statistical data about corresponding results of multiple conditions (e.g., conditional statements and / or conditional expressions used to implement the decision tree).
[0010] Furthermore, the data processing apparatus is configured to modify (i.e. optimize) the software code based on the collected statistical data by one or more of a plurality of code modification operations to reduce the execution time of the compiled and modified software code. The code modification operation may, for example, comprise rearranging portions of the software code based on the collected statistical data, in particular based on execution likelihoods or execution probabilities derived from the statistical data and associated with a data processing step of rearranging portions of the software code.
[0011] Advantageously, the processing device allows improving the prediction performance of decision trees, in particular by dynamically generating highly optimized code and just-in-time (JIT) compilation thereof. This improves access locality and cache efficiency, eliminates interpretation overhead and dynamic scheduling, reduces code size and thus improves CPU cache efficiency, reduces conditional selectivity errors and optimizes Boolean conditions, thereby reducing the so-called branch misprediction penalty (which can be considered a loss function).
[0012] In another possible implementation, the data processing device is also used to compile the source code version of the software code into a machine code version of the software code, and execute the machine code version of the software code to determine (i.e., predict) the corresponding results of the decision tree of the first subset of the second data set (i.e., the predicted data set).
[0013] In another possible implementation, the data processing device is configured to execute software code using at least one first thread and collect statistical data using at least one second thread, and the data processing device is configured to execute the at least one first thread and the at least one second thread substantially in parallel.
[0014] In another possible implementation, the data processing device is configured to perform the following operations: execute the software code; collect statistical data; and modify the software code based on the collected statistical data, as a continuous process until all data of the second data set is processed.
[0015] In another possible implementation, in order to collect statistical data, the data processing device is used to collect statistical data on the corresponding results of each of the multiple conditions of the software code that implements the decision tree.
[0016] In another possible implementation, at least one of the multiple conditions of the software code that implements the decision tree includes at least two Boolean conditions connected by an AND operator, wherein, in order to modify the software code based on statistical data, one or more of the multiple code modification operations include reordering the at least two Boolean conditions.
[0017] In another possible implementation, at least one of the multiple conditions of the software code that implements the decision tree is nested in at least another condition of the multiple conditions, wherein, in order to modify the software code based on statistical data, one or more of the multiple code modification operations include reordering at least one of the multiple conditions and at least another condition of the software code that implements the decision tree, so that the at least another condition is nested in at least one of the multiple conditions of the software code that implements the decision tree.
[0018] In another possible implementation, the data processing device is also used to compile a source code version of the software code into a machine code version of the software code, wherein at least one of the multiple conditions of the software code that implements the decision tree includes at least two Boolean conditions connected by a first type of AND operator (e.g., a bitwise AND operator &), and the first type of AND operator produces a non-branching portion of the machine code version of the software code in the machine code version of the software code, and wherein, in order to modify the software code based on statistical data, one or more of the multiple code modification operations includes replacing the first type of AND operator with a second type of AND operator (e.g., a logical AND operator &&), and the second type of AND operator produces a branching portion of the machine code version of the software code in the machine code version of the software code.
[0019] In another possible implementation, the data processing device is also used to compile a source code version of the software code into a machine code version of the software code, wherein at least one of the multiple conditions includes at least two Boolean conditions connected by a second type of AND operator (e.g., a logical AND operator &&), and the second type of AND operator generates a branch portion of the machine code version of the software code in the machine code version of the software code, and wherein, in order to modify the software code based on statistical data, one or more of the multiple code modification operations include replacing the second type of AND operator with a first type of AND operator (e.g., a bitwise AND operator &), and the first type of AND operator generates a non-branch portion of the machine code version of the software code in the machine code version of the software code.
[0020] In another possible implementation, in order to modify (e.g., optimize) software code based on collected statistical data by one or more code modification operations in a plurality of code modification operations, a data processing device is configured to determine one or more code modification operations in a plurality of code modification operations based on the statistical data using a loss function, wherein the loss function is configured to minimize the execution time of software code implementing a decision tree. The loss function may include a branch prediction error penalty for a branch of the decision tree.
[0021] According to a second aspect, a computer-implemented data processing method is provided. The data processing method according to the second aspect comprises the following steps:
[0022] Generating software code based on a first data set (e.g., a training data set), wherein the software code includes a plurality of conditions for implementing a decision tree;
[0023] executing the software code to determine (i.e., predict) a corresponding outcome of the decision tree for a first subset of a second data set (e.g., a prediction data set);
[0024] collecting statistics based on a second subset of a second data set (e.g., a predicted data set);
[0025] The software code is modified based on the collected statistical data through one or more code modification operations of the plurality of code modification operations to reduce execution time of the compiled and modified software code.
[0026] The method according to the second aspect of the present invention can be performed by the data processing device according to the first aspect of the present invention. Therefore, the further features of the method according to the second aspect of the present invention are directly derived from the functions of the data processing device according to the first aspect of the present invention and its different implementation modes described above and below.
[0027] According to a third aspect, there is provided a computer program product comprising a computer readable storage medium for storing program code, which, when executed by a computer or a processor, causes the computer or the processor to perform the method according to the second aspect.
[0028] One or more embodiments will be described in detail in the drawings and the following description. Other features, objects, and advantages will be apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the accompanying drawings:
[0030] Figure 1 Schematically illustrates a data processing device according to an embodiment;
[0031] Figure 2An exemplary decision tree is schematically shown;
[0032] Figure 3a The operation performed by the data processing apparatus according to the embodiment is shown;
[0033] Figure 3b shows the parallelization operation performed by the data processing apparatus according to the embodiment;
[0034] Figure 4 A flowchart showing the steps of an algorithm executed by a data processing device according to an embodiment;
[0035] Figure 5a and Figure 5b exemplarily showing different versions of software codes processed by a data processing device according to an embodiment;
[0036] Figure 6 a graph showing an exemplary prediction error penalty curve;
[0037] Figure 7 A flow chart of a data processing method according to an embodiment is shown.
[0038] In the following, identical reference signs refer to identical or at least functionally equivalent features. DETAILED DESCRIPTION
[0039] In the following description, reference is made to the accompanying drawings that form a part of the present invention, which illustrate specific aspects of embodiments of the present invention or specific aspects of embodiments of the present invention that can be used by way of illustration. It is understood that embodiments of the present invention can be used in other aspects and include structural or logical changes not shown in the accompanying drawings. Therefore, the following detailed description is not intended to be limiting, and the scope of the present invention is defined by the appended claims.
[0040] For example, it should be understood that the disclosure related to the described method is also applicable to the corresponding device or system for performing the method, and vice versa. For example, if one or more specific method steps are described, the corresponding device may include one or more units, such as functional units for performing the one or more method steps described (e.g., a unit that performs one or more steps; or multiple units, each unit performing one or more of the multiple steps), even if such one or more units are not explicitly described or shown in the drawings. In addition, for example, if a specific device is described based on one or more units (e.g., functional units), the corresponding method may include a step for performing the function of one or more units (e.g., a step that performs the function of one or more units; or multiple steps, each step performing the function of one or more units in the multiple units), even if such one or more steps are not explicitly described or shown in the drawings. Further, it is understood that, unless otherwise explicitly stated, the features of the various exemplary embodiments and / or aspects described herein may be combined with each other.
[0041] Figure 1 The data processing device 100 according to the embodiment is schematically shown. Figure 1 As shown, the data processing device 100 may include a processing circuit 110 and a communication interface 120, such as a wired and / or wireless communication interface 120. The processing circuit 110 may be implemented in hardware and / or software, and may include a digital circuit, or both an analog circuit and a digital circuit. The digital circuit may include components such as an application-specific integrated circuit (ASIC), a field-programmable array (FPGA), a digital signal processor (DSP), or a general-purpose processor. The data processing device 100 may also include a memory 130, which is used to store executable program code. When the executable program code is executed by the processing circuit 110, the data processing device 100 performs the functions and methods described herein.
[0042] like Figure 1 As further shown and described in more detail below, the data processing device 100 is used to generate software code 170 based on a first data set (also referred to as a training data set) 140 and a second data set (also referred to as a prediction data set) 150 as input, and the first data set 140 and the second data set 150 are, for example, received by the communication interface 120 and / or stored in the memory 130, for example, when the software code 170 is executed, implements the decision tree 160.
[0043] Before describing different embodiments of the data processing apparatus 100 in more detail, some technical background and terminology will be introduced below using one or more of the following abbreviations and concepts:
[0044] D-Cache CPU data cache
[0045] DT Decision Tree
[0046] I-Cache CPU instruction cache
[0047] Just in Time
[0048] RDBMS Relational Database Management System
[0049] SQL Structured Query Language.
[0050] JIT code generation refers to Just-in-time code generation, which means the code is generated immediately.
[0051] JIT compilation refers to just-in-time compilation, which means compiling the code immediately, that is, converting the code written in a high-level programming language into machine code.
[0052] Boolean conditions refer to atomic Boolean conditions. That is, conditions evaluate to true or false and can be connected by logical AND, OR operators, thus forming Boolean expressions. Boolean conditions can also be referred to by the term predicate. An example of a Boolean condition is weather = "sunny". An example of a Boolean expression is weather = "sunny" AND temperature < 30 OR city = "Berlin".
[0053] Selectivity refers to the probability that a Boolean predicate evaluates to true.
[0054] A query plan refers to the series of steps that an RDBMS uses to obtain the results of a given query. Users can write queries in a declarative (non-procedural) query language such as SQL.
[0055] A branch misprediction penalty is when a modern CPU tries to predict the path of a conditional statement based on previous results. However, if the wrong path is predicted, the entire CPU pipeline must be flushed. This can result in a lot of wasted CPU cycles.
[0056] The training dataset refers to the data used to train the algorithm (i.e., to build the decision tree).
[0057] The prediction dataset is the data used to make predictions.
[0058] A decision tree (DT) is a tree structure consisting of (Boolean) conditions (i.e. internal nodes) that can branch into more conditions. The leaf nodes of a decision tree represent the results.
[0059] Decision trees (DTs) may be associated with predictive models, such as those used in statistics, data mining, and machine learning. Decision trees are often used to go from observations about an item represented in the branches of the decision tree to a final result about a target value for that item. The latter is represented in the leaves of the decision tree.
[0060] Decision trees can also be used to represent Boolean expressions, where the internal nodes represent Boolean conditions and the leaves represent the results, such as true or false, yes or no.
[0061] exist Figure 2 , an exemplary decision tree 10 is schematically shown, which, by way of example, may be used to decide whether a person should play soccer based on weather conditions. As shown in the exemplary decision tree 10, internal nodes 11a to 11c together with their corresponding branches 13a to 13f may represent conditions, while leaf nodes 15a and 15b, 17a and 17b may represent results (also referred to herein as outcomes). Figure 2 As shown, the first results 15a and 15b can be, for example, "yes", and the second results 17a and 17b can be, for example, "no". Decision trees are very popular and are used in many fields, such as banking, operations research, autonomous driving, etc. In addition, Boolean expressions in queries (such as SQL) can also be expressed as decision tree structures. Therefore, the optimization of decision trees can also be generally used for the optimization of Boolean expressions in database systems. For this reason, many very popular machine learning enhancement algorithms (such as XGBoost, Random Forest, AdaBoost, etc.) use decision trees as the underlying structure. Decision trees can be used for classification and regression tasks.
[0062] Figure 3a 1 shows the operations performed by the data processing apparatus 100 according to an embodiment. As will be described in more detail below, the operations include generating software code 170 based on a first data set 140 (e.g., a training data set 140). The software code 170 includes a plurality of conditions (e.g., conditional statements or conditional expressions) for implementing a decision tree 160. The operations also include executing the compiled machine software code 170 to determine (i.e., predict) the corresponding results of the decision tree 160 of a first subset 307 of a second data set 150 (i.e., a prediction data set 150), collecting statistical data based on a second subset 309 of the second data set 150, and modifying (i.e., optimizing) the software code 170 based on the collected statistical data through one or more code modification operations in a plurality of code modification operations to reduce the execution time of the compiled and modified software code 170. The second data set 150 may include at least another subset 311, which may be used to collect further statistical data after collecting statistical data based on the second subset 309.
[0063] Therefore, according to the embodiments disclosed herein, the data processing device 100 can be used for dynamic JIT code generation and compilation of decision tree programs. The data processing device 100, in particular the processing circuit 110, can be used to implement a code generator that generates a software code 170, which includes a tight loop for evaluating the decision tree 160 (i.e., evaluating a Boolean expression). In this way, code locality is improved, resulting in better CPU cache behavior. In addition, due to code compilation, dynamic scheduling is eliminated and the compilation overhead is very small (negligible). In addition, the data processing device 100 allows dynamic JIT generation and compilation of optimized code for predicting / evaluating data that has not yet been seen. This may involve building the decision tree 160 only once. In contrast, conventional methods typically generate static prediction models based only on the training data set 140, wherein the prediction data set 150 (data that has not yet been seen) does not play any role, so that suboptimal code is generated without major optimization.
[0064] The data processing apparatus 100 supports dynamically pre-scanning a prediction data set 150 in order to minimize errors on the generated code. As further described below, parallel tasks can pre-read data in order to collect selectivity of Boolean conditions of the code in order to reduce branch prediction error penalties (also known as loss functions) on the generated software code 170. Typically, branch prediction errors result in costly CPU pipeline stalls. For example, in Intel's Skylake architecture, the cost is 16.5 cycles, while on AMD's Zen1, the cost is about 19 cycles. The optimizer is good at predicting branches that are almost always taken or never taken. However, from Figure 6 As can be seen from the figure, the branch prediction error penalty of the randomly (e.g., 50% probability) selected branch is the highest. As further described below, the data processing device 100 according to the embodiment is used to optimize the branch prediction error penalty by reordering the conditions of the software code 170 implementing the decision tree 160 and selectively using branches (further indicated by "&&") and non-branch (further indicated by "&") connections according to their Boolean conditions.
[0065] Figure 3b FIG. 1 shows the parallel operation performed by the data processing apparatus 100 according to the embodiment. Figure 3b , the first step 313a to the fifth step 313e implemented by the data processing device 100 are schematically shown, some of which can be called by the data processing device 100 in parallel and / or repeatedly, as described below.
[0066] According to an embodiment, in a first step 313 a , the data processing apparatus 100 , in particular the processing circuit 110 , may read a first data set 140 , ie, a training data set 140 .
[0067] In the second step 313 b , the data processing device 100 may construct a decision tree 160 based on the first data set 140 read in the first step 313 a .
[0068] In the third step 313 c , the data processing apparatus 100 may JIT generate and compile the software code 170 of the decision tree 160 constructed in the second step 313 b .
[0069] In a fourth step 313d, the data processing apparatus 100 may use the initial JIT-compiled software code 170 from the third step 313c to predict a first subset 307 of the second data set 150 (ie the predicted data set 150).
[0070] In the fifth step 313e of the task parallel implementation, the data processing device 100 can pre-read (i.e., pre-scan) the prediction data set (i.e., the second subset 309 of the second data set 150) and collect Boolean condition statistics (i.e., statistical data), optimize the Boolean conditions of the software code 170 based on the newly collected statistical data, and call the third step 313c to JIT generate (regenerate) and compile (recompile) the newly optimized software code 170.
[0071] The fourth step 313d may continue predicting until the group of blocks pre-read in the fifth step 313e is reached, i.e., the second subset 309 of the second data set 150, and then switch the prediction to using the new JIT-compiled software code 170 resulting from the fifth step 313e. At this point, the fifth step 313e may be called again in parallel to pre-read a new group of blocks, i.e., to read at least another subset 311. This process may be repeated until the entire predicted data set 150 has been evaluated.
[0072] According to yet another embodiment involving massively parallel prediction, in a first step 313 a , the data processing apparatus 100 , in particular the processing circuit 110 , may read a first data set 140 , ie, a training data set 140 .
[0073] In the second step 313 b , the data processing device 100 may construct a decision tree 160 based on the first data set 140 read in the first step 313 a .
[0074] In the third step 313 c , the data processing apparatus 100 may JIT generate and compile the software code 170 of the decision tree 160 constructed in the second step 313 b .
[0075] In a fourth step 313d, the data processing apparatus 100 may use the initial JIT-compiled software code 170 from the third step 313c to predict a first subset 307 of the second data set 150 (ie the predicted data set 150).
[0076] In a fifth step 313 e , the data processing apparatus 100 may divide the prediction data set 150 (ie, the second data set 150 ) into groups of blocks of equal size, ie, subsets 307 to 311 .
[0077] In the sixth step ( Figure 3b In the embodiment (not shown in FIG), for each block group (i.e., subsets 307 to 311), the thread (parallel task) can pre-read its assigned block group (i.e., subsets 307 to 311) and collect Boolean condition statistics (i.e., statistical data). In addition, the data processing device 100 can optimize the Boolean conditions of the software code 170 based on the newly collected statistical data, and call the third step 313c to JIT generate (regenerate) and compile (recompile) the newly optimized software code 170.
[0078] In the seventh step ( Figure 3b In the example of FIG. 1 , when a thread has finished collecting statistics, it can re-read its assigned block group (i.e., subset 307 to 311) and use the new JIT-compiled software code 170 in step 6 for prediction. As will be appreciated, the prediction code in step 6 is compiled for the specific block group (i.e., subset 307 to 311) for which the thread performs prediction, so the thread always uses optimized JIT-compiled code for prediction.
[0079] Figure 4 A flowchart showing steps performed by the data processing apparatus 100 according to an embodiment.
[0080] In step 401, a user may initiate a training task, thereby reading a training dataset, i.e., a first dataset 140, from a repository storing the training dataset 140. The training dataset 140 may be read from any medium or repository that supports read operations, such as the memory 130. Some examples of such repositories are files stored on a disk, a database system, a storage object in the cloud, and the like.
[0081] In step 403, once the training data set 140 is read, the data processing device 100 may construct a decision tree 160. In the world of machine learning, the construction of the decision tree 160 corresponds to the training phase.
[0082] Once the decision tree 160 has been constructed, the data processing device 100 may trigger step 405, wherein the code 170 of the constructed decision tree 160 (as done in step 403) may be JIT generated as nested if / else expressions and compiled into machine code. At this stage, a complete decision tree program 170 is provided that can be used for prediction.
[0083] In step 407, once the code generation and compilation in step 405 are completed, the prediction phase begins. That is, the data processing device 100 can read the data to be predicted, one data block group at a time, i.e., one continuous block or a subset 307 to 311 of the second data set 150, and use the compiled code 170 to perform prediction on the data block group (i.e., the subset 307 to 311).
[0084] Similar to the first data set 140 for training, the second data set 150 for prediction may be stored in any medium, such as the memory 130, which supports read operations, such as a file, a database system, a storage object in the cloud, etc. If the storage repository including the prediction data set 150 (i.e., the data in which the algorithm is called to make predictions) does not include more than a single block group (i.e., the subset 307 to 311), the data processing device 100 may predict the data in the subset 307 to 311 and terminate, as shown in steps 409 and 417.
[0085] In step 411 , if the predicted data set 150 is larger than a single data block group (ie, subsets 307 to 311 ), the data processing device 100 may generate parallel tasks, such as threads, to pre-read the next subset 307 to 311 of data when executing step 407 .
[0086] This is Figure 3a 4 , wherein the first subset 307 corresponds to the current block group being read and predicted by the data processing device 100. As will be appreciated, the decision tree 160 has been compiled in step 407, so predictions can be made based on the compiled software code 170. The second subset 309 corresponds to the data block group being read in parallel.
[0087] In step 413 , selectivity (ie, statistics) of the Boolean conditions in the decision tree 160 may be collected from the pre-read block group (ie, the second subset 309 ).
[0088] In step 415, once statistics such as selectivity are collected, the algorithm may optimize the Boolean expressions of the software code 170 based on the newly collected selectivity (i.e., statistics). That is, the data processing apparatus 100 may perform modifications to the software code 170, such as optimizing the Boolean conditions of the software code 170 to reduce branch misprediction penalties (e.g., Figure 6), and / or reorder and connect the Boolean conditions using branching AND (&&) and non-branching AND (&) operations according to the corresponding selectivity of the Boolean conditions. After the optimization is completed, the data processing device 100 can re-trigger step 405 so that the JIT generates and compiles new optimized software code 170, so that when the prediction stage moves to the new data block group (i.e., the second subset 309), it will perform the prediction operation on the optimized software code 170.
[0089] Figure 5a An exemplary first version 507a of the software code 170 generated based on the first data set 140 and a second modified (i.e., optimized) version 509a of the software code 170 generated based on statistical data collected through one or more of the plurality of code modification operations are shown. Figure 5a As shown, the code modification operation may include changing the Boolean condition from a branching AND (&&) to a non-branching AND (&), which may optimize the compiled machine code of the software code 170 , ie, reduce the execution time of the compiled machine code of the software code 170 .
[0090] Figure 5b Another exemplary first version 507b of the software code 170 generated based on the first data set 140 and another second modified (i.e., optimized) version 509b of the software code 170 generated based on statistical data collected through one or more of the plurality of code modification operations are shown. Figure 5b As shown, at least one of the multiple conditions of another first version 507b is nested in at least another of the multiple conditions. Therefore, in order to modify the software code 170 based on the statistical data, one or more of the multiple code modification operations may also include reordering at least one of the multiple conditions and at least another condition of the software code 170 that implements the decision tree 160, as exemplarily shown by comparing another second version 509b with another first version 507b of the software code 170. Therefore, the "unlikely" code can be kept away from the "likely" code, thereby reducing the processing time of the software code 170.
[0091] Figure 6 A graph of a prediction error penalty curve 600 is shown. The curve 600 relates the likelihood of a Boolean expression to an expected branch prediction error penalty (also referred to as a loss function). By rearranging or reformulating the Boolean expression of the software code 170, i.e., modifying the software code 170 based on the collected statistical data, the data processing apparatus 100 can optimize away the branch prediction error penalty, i.e., optimize the software code 170 using a Boolean expression with a higher prediction importance and a lower expected prediction error penalty.
[0092] Figure 7 A flow chart of a computer-implemented data processing method 700 according to an embodiment is shown.
[0093] The data processing method 700 comprises step 701 of generating a software code 170 based on a first data set 140 (eg, a training data set 140 ), wherein the software code 170 comprises a plurality of conditions for implementing a decision tree 160 .
[0094] The data processing method 700 further comprises step 703 of executing the compiled software code 170 to determine (ie predict) a corresponding result of the decision tree 160 for the first subset 307 of the second data set 150 (ie the predicted data set 150 ).
[0095] The data processing method 700 further comprises step 705 of collecting statistical data based on the second subset 309 of the second data set 150 .
[0096] The data processing method 700 further includes step 707 of modifying the software code 170 based on the collected statistical data through one or more code modification operations among a plurality of code modification operations to reduce the execution time of the compiled and modified software code 170 .
[0097] Since the data processing method 700 can be implemented by the data processing device 100 , other features of the data processing method 700 are directly derived from the functionality of the data processing device 100 and its different embodiments described above and below.
[0098] Those skilled in the art will understand that the "boxes" ("units") of the various figures (methods and devices) represent or describe the functions of an embodiment of the present invention (and not necessarily a single "unit" in hardware or software), thereby equivalently describing the functions or features of the device embodiments and the method embodiments (unit = step).
[0099] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the embodiments of the described devices are merely exemplary. For example, the unit division is only a logical function division, which can be another division in the actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not performed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be implemented by using some interfaces. The indirect coupling or communication connection between devices or units can be implemented by electronic, mechanical or other forms.
[0100] The units described as discrete components may or may not be physically separate, and the components shown as units may or may not be physical units, may be located in one location, or may be distributed over multiple network units. Some or all of the units may be selected based on actual needs to achieve the purpose of the solution of the embodiment.
[0101] Furthermore, the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
Claims
1. A data processing device (100), characterized in that: Used to perform the following operations: Generating software code (170) based on the first data set (140), wherein the software code (170) includes a plurality of conditions for implementing the decision tree (160); executing the software code (170) to determine a result of the decision tree (160) for a first subset (307) of a second data set (150); collecting statistics based on a second subset (309) of the second data set (150); The software code is modified based on the collected statistical data through one or more code modification operations of a plurality of code modification operations (170).
2. The data processing device (100) according to claim 1, characterized in that: The data processing device (100) is also used to compile the software code (170) into a machine code version of the software code (170) and execute the machine code version of the software code (170) to determine the result of the decision tree (160) for the first subset (307) of the second data set (150).
3. The data processing device (100) according to claim 1 or 2, characterized in that: The data processing device (100) is used to execute the software code (170) using at least one first thread and collect the statistical data using at least one second thread, and the data processing device (100) is used to execute the at least one first thread and the at least one second thread substantially in parallel.
4. The data processing device (100) according to any one of the preceding claims, characterized in that The data processing device (100) is used to perform the following operations: execute the software code (170); collect the statistical data; and modify the software code (170) based on the collected statistical data as a continuous process.
5. The data processing device (100) according to any one of the preceding claims, characterized in that In order to collect the statistical data, the data processing device (100) is used to collect statistics on the corresponding results of each of the plurality of conditions of the software code (170) implementing the decision tree (160).
6. The data processing device (100) according to any one of the preceding claims, characterized in that At least one of the plurality of conditions comprises at least two Boolean conditions connected by an AND operator, and in order to modify the software code (170) based on the statistical data, one or more of the plurality of code modification operations comprises reordering the at least two Boolean conditions.
7. The data processing device (100) according to any one of the preceding claims, characterized in that At least one of the multiple conditions is nested in at least one other condition of the multiple conditions, and in order to modify the software code (170) based on the statistical data, one or more of the multiple code modification operations include reordering the at least one condition and the at least one other condition of the multiple conditions of the software code (170) that implements the decision tree (160).
8. The data processing device (100) according to any one of the preceding claims, characterized in that The data processing device (100) is also used to compile the software code (170) into a machine code version of the software code (170), at least one of the multiple conditions includes at least two Boolean conditions connected by a first type of AND operator, and the first type of AND operator generates a branch part of the machine code version of the software code (170) in the machine code version of the software code (170), wherein, in order to modify the software code (170) based on the statistical data, one or more of the multiple code modification operations include replacing the first type of AND operator with a second type of AND operator, and the second type of AND operator generates a non-branch part of the machine code version of the software code (170) in the machine code version of the software code (170).
9. The data processing device (100) according to any one of the preceding claims, characterized in that The data processing device (100) is also used to compile the software code (170) into a machine code version of the software code (170), at least one of the multiple conditions includes at least two Boolean conditions connected by a second type of AND operator, and the second type of AND operator generates a non-branching part of the machine code version of the software code (170) in the machine code version of the software code (170), wherein, in order to modify the software code (170) based on the statistical data, one or more of the multiple code modification operations include replacing the second type of AND operator with a first type of AND operator, and the first type of AND operator generates a branching part of the machine code version of the software code (170) in the machine code version of the software code (170).
10. The data processing device (100) according to any one of the preceding claims, characterized in that In order to modify the software code (170) based on the collected statistical data by one or more of the multiple code modification operations, the data processing device (100) is used to determine the one or more of the multiple code modification operations based on the statistical data using a loss function, wherein the loss function is used to minimize the execution time of the software code (170) that implements the decision tree (160).
11. A data processing method (700), characterized in that: The data processing method (700) comprises: Generating (701) software code (170) based on the first data set (140), wherein the software code (170) includes a plurality of conditions for implementing a decision tree (160); executing (703) the software code (170) to determine a result of the decision tree (160) for a first subset (307) of a second data set (150); collecting (705) statistical data based on a second subset (309) of the second data set (150); The software code (170) is modified (707) based on the collected statistical data through one or more code modification operations of a plurality of code modification operations.
12. A computer program product comprising a computer-readable storage medium, characterized in that The computer-readable storage medium is used to store program codes. When the program codes are executed by a computer or a processor, the program codes enable the computer or the processor to perform the method according to claim 11.