Medical image floating point expression precision optimization method based on conditional number analysis

By using condition number analysis and mixed precision optimization methods, a variety of mixed precision combination schemes are generated, which solves the robustness and performance problems of floating-point expressions in medical image processing and achieves synergistic optimization of accuracy and efficiency in noisy images.

CN121900718APending Publication Date: 2026-04-21HENAN JIAZE MEDICAL INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HENAN JIAZE MEDICAL INFORMATION TECHNOLOGY CO LTD
Filing Date
2025-12-03
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing hybrid precision optimization techniques suffer from configuration space explosion and insufficient robustness in medical image processing, especially when processing noisy medical images, making it difficult to achieve a balance between accuracy and performance.

Method used

By employing a condition number analysis-based approach, we perform expression transformation, numerical stability evaluation, mixed-precision code generation, and key input set verification to generate various mixed-precision combination schemes. Furthermore, through condition number filtering and dynamic precision allocation, we optimize the precision and performance of floating-point expressions.

Benefits of technology

It achieves precision optimization of floating-point expressions in medical image processing, improves computational performance and reduces errors, and is suitable for biomedical and AI-assisted diagnosis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121900718A_ABST
    Figure CN121900718A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of medical image processing, and discloses a medical image floating point expression precision optimization method based on conditional number analysis. Comprising the following steps: S1, inputting an original medical image floating point expression and carrying out equivalent transformation on the original medical image floating point expression; S2, evaluating and screening the expressions: rapidly evaluating the numerical stability of each candidate expression by adopting an approximate conditional number model, and screening out K candidate expressions as optimal expressions; s3, mixing precision generation: forming a plurality of mixing precision combination schemes according to the screened K optimal expressions, and then generating a plurality of mixing precision code variants according to the mixing precision combination schemes; and S4, hybrid precision configuration evaluation: selecting a scheme with optimal balance between numerical precision and calculation efficiency from various hybrid precision code variants. According to the method, the steps of expression transformation, numerical stability evaluation, mixed precision code generation and key input set verification are performed in sequence, so that the precision and performance collaborative optimization of the floating point expression is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical image processing technology, and specifically to a method for optimizing the precision of floating-point expressions in medical images based on condition number analysis. Background Technology

[0002] In biomedical and medical research applications, the precision of floating-point arithmetic directly affects the reliability of computational results and algorithm performance. For example, in medical image processing, CT image reconstruction may suffer from artifacts due to floating-point errors, thus affecting diagnostic accuracy. Double precision and single precision are two commonly used floating-point types. The former has high precision but high computational cost, while the latter is efficient but has limited precision. This difference in characteristics makes mixed-precision technology a key technology for balancing precision and performance, and it is widely used in fields such as numerical simulation, machine learning, and signal processing. For example, it accelerates genome analysis or protein folding simulation in biomedical big data processing. However, existing mixed-precision optimization techniques face challenges such as configuration space explosion and insufficient robustness. When a program contains multiple floating-point variables, the search space grows exponentially, and the optimized program may violate precision constraints due to reliance on random sampling or specific input validation, especially when processing noisy medical images or biological signals.

[0003] Existing technologies such as the Salsa framework optimize error boundaries through abstract interpretation and expression recombination, but are limited by algebraic equivalence constraints and transcendental function processing capabilities. Herbie utilizes mathematical rules to reconstruct single expressions, but struggles to adapt to multi-module interaction scenarios, such as multimodal data fusion in biomedicine. Regina and Arfa employ dynamic interval partitioning and clustering techniques to optimize error distribution, but may overlook complex control flows or introduce performance overhead. Furthermore, ADAPT quantifies variable sensitivity based on algorithmic differentiation, and RobustTuner improves robustness through condition number analysis, but both have limitations in applicability, such as non-differentiable functions or condition number dependencies. Although hybrid frameworks like AutoRNP and NPTaylor have constructed systematic repair systems, their universality in complex biomedical scenarios still needs improvement. For example, in neuromorphic chips or GPU-accelerated biomedical computing, hybrid precision can significantly reduce energy consumption but requires optimization for the noise characteristics of medical images. Therefore, a hybrid precision optimization method is urgently needed to improve the robustness and computational efficiency of floating-point expressions for medical images to support precision medicine and AI-assisted diagnosis. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a method for optimizing the precision of floating-point expressions in medical images based on condition number analysis. Through sequential steps of expression transformation, numerical stability evaluation, mixed-precision code generation, and key input set verification, the method achieves synergistic optimization of the precision and performance of floating-point expressions.

[0005] To achieve the above objectives, the present invention adopts the following technical solution: a method for optimizing the precision of floating-point expressions in medical images based on condition number analysis, comprising the following steps: S1. Input the original floating-point expression of the medical image and transform it equivalently: For the original floating-point expression of the medical image, generate multiple mathematically equivalent candidate expressions with different numerical properties to reduce the accumulation of errors in intermediate results; the methods for generating candidate expressions include algebraic structure transformation and polynomial structure transformation. S2. Expression Evaluation and Screening: The numerical stability of each candidate expression is quickly evaluated using an approximate condition number model, and K candidate expressions are selected as the preferred expressions. S3. Mixed Precision Generation: For the selected K preferred expressions, multiple mixed precision combination schemes are formed, and then multiple mixed precision code variants are generated from the mixed precision combination schemes. S4. Mixed Precision Configuration Evaluation: Select the scheme that best balances numerical precision and computational efficiency from a variety of mixed precision code variants.

[0006] Further, the specific steps of S1 are as follows: S11, parse the original medical image floating-point expression into an AST; S12, classify and process variables or constants, function calls, and operator nodes; S13, reconstruct the calculation path of the expression through factorization, formula substitution, and term reordering to complete the algebraic structure transformation; S14, decompose the addition expression into independent sub-terms, merge like terms, and reduce coefficients to optimize the numerical stability of the expression, complete the polynomial structure transformation, and finally perform hash deduplication.

[0007] Furthermore, S2 specifically includes the following steps: S21, constructing an approximate condition number model based on the difference method; S22, performing perturbation input testing on each candidate expression to obtain the corresponding approximate condition number; S23, sorting the candidate expressions in ascending order according to the numerical value of the approximate condition number, and selecting the top K candidate expressions with low condition numbers and low sensitivity as the preferred expressions.

[0008] Furthermore, S3 specifically includes the following steps: S31, generate a corresponding AST for each preferred expression, assign a unique number to each operator node through post-order traversal, generate an operation order list, and ensure that child nodes are processed before parent nodes; S32, node precision configuration: set an upper limit on the number of high-precision nodes, select several nodes from them to be set to double precision (the selection method is: based on the operation sequence, gradually increase the number of high-precision nodes n from 1 to the set threshold from the candidate nodes to generate all C(m,n) combinations, where m is the total number of candidate nodes), and keep the rest single precision, forming multiple mixed precision combination schemes and recording them in the form of bitmasks; S33, generate a precision mapping table based on the bitmasks, mark the corresponding nodes in the AST as high precision or low precision; recursively traverse the AST, set the variable type according to the mapping table and insert type conversion instructions to implement the mixed precision calculation logic.

[0009] Furthermore, S4 specifically includes the following steps: S41, identifying key input sets that are prone to triggering high errors through random and stratified sampling, the key input sets including medical image samples with high contrast or dense noise; S42, substituting the key input sets into each mixed-precision code variant, calculating the output error and comparing it with a high-precision benchmark, and statistically analyzing the proportion of samples that meet the error threshold to evaluate numerical stability; S43, combining the sample pass rate and average execution time, sorting and filtering according to a weighted scoring model, and selecting the mixed-precision code variant that achieves the optimal balance between numerical accuracy and computational efficiency.

[0010] Furthermore, in S11, the classification processing of AST nodes specifically includes: for function call nodes, recursively applying transformations to parameters and generating equivalent forms using trigonometric identities in the rule base; and for operator nodes, recursively processing their subexpressions, applying the distributive law to multiplication operations to expand the addition structure, merging like terms in addition operations, and performing operation order transformations.

[0011] Furthermore, in S2, the specific implementation algorithm of the approximate condition number model is as follows: 1. Calculate the value b of the candidate expression f(a) at input point a; 2. Obtain the system constant ε, which represents the machine precision of floating-point calculation; 3. Calculate the perturbation value h based on the system constant ε and input point a. The system constant ε is obtained by calling a floating-point constant acquisition function, which returns the machine precision value of the current computing environment; 4. The perturbation value h is used to calculate the perturbed expression value f. plus , where f plus = f(a + h); The calculation of the perturbation value h ensures that the perturbation is not too small when the input point a is zero, thus guaranteeing the validity of the numerical derivative; 5. Calculate the perturbation value f. plus The difference δ between the value b and the value f , where δf =f plus –b; 6. Based on the difference δ f The approximate derivative is calculated using the perturbation value h, where the approximate derivative = δ f / h; 7. Determine if value b is zero: If b = 0, return infinity when δf ≠ 0, otherwise return 0.0; If b ≠ 0, calculate and return the approximate condition number, which is |(approximate derivative × a) / b|; The approximate condition number is used to evaluate the numerical stability of the expression f(a) at the input point a, where a larger approximate condition value indicates a worse numerical stability.

[0012] Furthermore, the specific implementation algorithm for node-level precision configuration in S32 is as follows: Input the selected preferred expression, output mixed precision code variants; 1. Generate by traversing according to the operation sequence opOrder; 2. Initialize the number of high-precision nodes n=1, generating C(m,1) configuration schemes; 3. Gradually increase n, generating C(m,n) combinations until a threshold is reached; the predefined threshold is determined based on at least one of the total number of combined configuration schemes, the value of n, or the computational resource budget; 4. For mixed precision combination schemes that meet the threshold, map them to a precision allocation rule; the steps of mapping mixed precision configuration schemes to precision allocation rules include: representing each scheme as a one-bit mask, where each bit in the mask corresponds to a specific operation node in the operation sequence and represents the precision type it is assigned; 5. According to the precision allocation rules, the abstract syntax tree of the expression is recursively traversed, and the corresponding precision type is assigned to the operation nodes. Based on the abstract syntax tree with completed precision allocation, the final mixed precision code variant is generated. The steps of recursively traversing the abstract syntax tree (AST) and assigning precision types to the operation nodes according to the precision allocation rules are completed by a depth-first search algorithm.

[0013] Furthermore, the layered sampling in S41 adopts a method based on the characteristics of floating-point exponent bits, specifically including the following steps: 1. Divide the input interval into 2 1 / 2 1. Divide the step size into multiple sub-intervals; 2. Randomly sample 30 valid points in each sub-interval as test samples to ensure coverage of sensitive areas of floating-point number distribution; The high-precision benchmark in S42 is generated by 128-bit high-precision calculation provided by the MPFR library. The output error of all mixed precision combination schemes is compared with the 128-bit high-precision benchmark to quantify the numerical precision.

[0014] The beneficial effects of this invention are: 1. A set of candidate expressions is generated through algebraic equivalent transformations, numerical stability is evaluated using an approximate condition number model, node-level mixed precision configuration is implemented, and the key input set is located based on condition number to verify the scheme, thereby achieving precision optimization of floating-point expressions for medical images.

[0015] 2. This invention was evaluated on 10 expressions in the FPBench standard test set. These general mathematical expressions are similar to polynomial filtering and transcendental function calculations in medical image processing. Compared with the original double-precision expressions, the floating-point expressions for medical images optimized using this scheme showed improved performance in all test cases, and the accuracy loss was small in most test cases, verifying the effectiveness of the method.

[0016] 3. This invention achieves synergistic optimization of accuracy and efficiency through condition number-guided candidate screening and dynamic precision allocation, providing a method for precision optimization in biomedicine. Attached Figure Description

[0017] Figure 1 This is a schematic flowchart of the method of the present invention; Figure 2 This is a flowchart of the equivalent transformation of the present invention; Figure 3 Example diagram of mixed precision code generation for this invention; Figure 4 This is a flowchart of the mixed accuracy configuration evaluation process of the present invention. Detailed Implementation

[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings and specific examples. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] The directional terms mentioned in this invention, such as "up", "down", "front", "back", "left", "right", "inner", "outer", "side", "top" and "bottom", are only for reference to the orientation of the accompanying drawings. The directional terms used are for the purpose of explaining and understanding this invention and are not absolute limitations on the actual use.

[0020] Example: like Figures 1-4 As shown, a method for optimizing the precision of floating-point expressions in medical images based on condition number analysis includes the following steps: S1. Expression Equivalence Transformation: For the original floating-point expressions of medical images, considering the tendency of rounding errors in floating-point calculations to propagate and amplify with the operational structure, algebraic structure transformation and polynomial structure conversion are employed to generate multiple sets of mathematically equivalent but potentially different candidate expressions. Algebraic structure transformation includes factorization, formula substitution, and term reordering to reconstruct the computational path of the expression and reduce error accumulation in intermediate results. Polynomial structure conversion involves decomposing the addition expression into independent sub-terms, merging like terms, and reducing coefficients to optimize the numerical stability of the expression. While preserving the mathematical equivalence of the expressions, multiple candidate expressions are obtained through systematic transformation for subsequent expression selection, thereby improving the overall computational accuracy and stability of medical image processing.

[0021] Equivalence transformation of floating-point expressions is a classic precision optimization method. Its core lies in reorganizing or simplifying expressions using algebraic rules and mathematical identities, thereby improving computational efficiency, reducing numerical errors, or optimizing performance. The method first parses the expression into an abstract syntax tree (AST), and then generates a set of equivalent expressions through node classification and transformation.

[0022] like Figure 2 As shown, AST nodes are divided into three categories: variables / constants, function calls, and operators. Variable or constant nodes are directly added to the result set to avoid redundant recursion. Function call nodes extract the function name and parameters, recursively apply transformations to the parameters, and generate equivalent forms using a rule base (such as trigonometric identities). Operator nodes parse operators and subexpressions, and after recursive processing, for multiplication, the distributive law is applied to expand the addition structure; for other operators, the structure is retained and recursively processed. The results are deduplicated using a hash table.

[0023] In step S1, the specific algorithm for the equivalent transformation of the expression is as follows: Function: Performs equivalent transformation operations based on the input expression; Input: AST node expr; Output: A set of equivalent expressions, E; 1. t = expr.type() 2. If t in ["Number","Variable"]: / / Handling of variable and constant nodes 3. return { expr} 4. If t == "Function": / / Function call node processing 5. E = Equivalent Transformation(arg1) 6. For arg in expr.getArgs()[1:]: E += equivalent transformation(arg) 7. E += Identity substitution (expr) 8. If t == "Operator": / / Operator node processing 9. E = Equivalent Transformation (child1) 10. For child in expr.getChildren()[1:]: E += equivalent transformation(child) 11. If expr.op == "×": E += distribute_expr 12. If expr.op == "+": E += combines like terms (expr) 13. E += operation order change (expr) 14. Return hash deduplication(E) S2, Expression Evaluation and Filtering: For the candidate expression set, considering the potential accuracy degradation due to the high sensitivity of expressions to input perturbations in practical computation, an approximate condition number model is employed to rapidly evaluate the numerical stability of each candidate expression. The approximate condition number model, based on the finite difference method, approximates the condition number of an expression under local input perturbations, measuring the responsiveness of the expression's result to input changes and thus reflecting its numerical stability. During the evaluation process, each candidate expression is first tested with perturbation inputs to obtain its corresponding approximate condition number. Then, the candidate expressions are sorted in ascending order according to their condition number values, and the top K expressions with low condition numbers and low sensitivity are selected as the preferred expressions.

[0024] Equivalent transformations of floating-point expressions for medical images generate a large number of mathematical variants. Implementing all mixed-precision versions one by one would result in a surge in the number of solutions, leading to significant resource and time overhead. Therefore, it is necessary to quickly evaluate and select candidate expressions with potential advantages after the transformation to reduce the cost of subsequent optimization.

[0025] The condition number, as an indicator of the numerical stability of an expression, effectively reflects its sensitivity to input perturbations and is suitable as a screening criterion. However, its accurate calculation relies on high-precision arithmetic, which incurs significant overhead. To balance efficiency and reliability, this invention introduces a fast condition number estimation method based on difference approximation.

[0026] For unary expressions f(x) Its condition number is defined as follows: This reflects the amplification rate of the input relative error to the output relative error. When analytical differentiation is not feasible, it can be approximated using the finite difference method: taking a small step size. (ϵ represents machine precision), using the difference quotient To approximate the derivative f'(x) Finally, the approximate condition number is obtained. In the core calculation terms of condition numbers It can be seen that when the derivative f'(x) The larger the condition number, the larger the condition number. Conversely, the smaller the condition number, the more likely it is to be the potential optimal solution.

[0027] The approximate condition number model aims to evaluate the numerical sensitivity (condition number) of an expression at a given input point. Its specific implementation algorithm is as follows: Function: Evaluate the numerical sensitivity of the input expression at input point a. Input: Input point a, expression f Output: Approximate conditional numerical value 1. b← f (a) 2. GetFloatConstants() / / Get system constants 3. 4. f plus ← f (a + h) / / Perturbation calculation 5. δ f ← f plus - b 6. derivative ← δ f / h / / Approximate derivative calculation 7. If b = 0: / / Zero value handling 8. Return infinity if δ f ≠ 0 else 0.0 9. Return | (derivative × a) / b | / / Approximate condition number S3, Mixed Precision Generation: For the selected K expressions, an Abstract Syntax Tree (AST) is generated for each expression. A unique number is assigned to each operator node through post-order traversal, generating an operation order list to ensure that child nodes are processed before their parent nodes. Based on this, an upper limit is set on the number of high-precision nodes. Several nodes are selected from this limit to be set to double precision, while the rest remain single precision, forming multiple precision combination schemes. Each scheme is recorded in bitmask form. A precision mapping table is generated based on the mask, marking the corresponding nodes in the AST as high or low precision. During the code generation phase, the AST is recursively traversed, and variable type and insertion type conversion instructions are set according to the mapping table to ensure semantic consistency while implementing mixed-precision calculation logic.​

[0028] Node numbering assigns a unique sequential number to each node in the Abstract Syntax Tree (AST) to clarify the order of computation. This provides the foundation for subsequent precision analysis and code generation. The numbering clearly tracks the computation process of each node, ensuring that the generated code correctly reflects the computational logic of the expression.

[0029] Node numbering is handled using a post-order traversal of the AST. The characteristic of post-order traversal is that child nodes are processed recursively first, followed by the current node. This traversal method ensures that the child node's number is always less than the parent node's number, thus conforming to the order of expression evaluation.

[0030] The specific algorithm for node number allocation is as follows: Function: Assign a number to the currently input AST node. Input: AST node expr, global count order, operation sequence opOrder 1. Recursively set the number (expr, order, opOrder) 2.type = expr.type() 3. if type in ["Number", "Variable"] / / Leaf node processing 4. expr.setOrder(order) 5. order = order + 1 6.else 7. For each child in expr.getChildren(): 8. Recursively set the number (expr, order, opOrder) 9. For each arg in expr.getArgs() 10. Recursively set the number (arg, order, opOrder) 11. expr.setOrder(order) 12. opOrder.append(order) 13. order = order + 1 Precision type settings, through a systematic selection of key nodes in the operation sequence and assignment of high-precision or low-precision data types, aim to explore the mixed-precision optimization space while ensuring numerical stability. Its mathematical essence is a combinatorial optimization problem under constraints.

[0031] Given an operation sequence of length m, the method initializes the number of high-precision nodes n=1, generating C(m,1) single-node high-precision configuration schemes, and gradually increases n to generate C(m,n) combinations until a preset threshold is reached or all nodes are covered. To avoid combination explosion, the number of combinations is estimated before each round of generation; if it exceeds the threshold, the process jumps to the next round, balancing computational feasibility and coverage.

[0032] This invention generates bitmasks and combinations for high-precision node counts that meet a threshold. The bitmask length is the same as the operation sequence, with 1 representing high precision and 0 representing low precision. For example, when m=5 and n=2, the initial bitmask is [1, 1, 0, 0, 0], and all permutations are generated, iterating through possible combinations. For each permutation generated, the operation node is extracted based on the position of 1. Subsequently, all nodes are set to low precision by default, and the nodes in the combinations are updated to high precision, forming a precision mapping table that records the allocation scheme.

[0033] The specific algorithm for node-level precision configuration is as follows: Function: Generates mixed-precision code variants based on the operation sequence opOrder. Input: The filtered expression Output: Mixed precision code 1. Generate by iterating through the operation sequence opOrder; 2. Initialize the number of high-precision nodes n=1, and generate C(m,1) configuration schemes; 3. Gradually increase n to generate C(m,n) combinations until the threshold is reached; 4. For configurations that meet the threshold, generate bitmasks and arrangements, and assign precision; 5. Recursively traverse the AST and allocate generated code according to the precision.

[0034] S4. Evaluation of Mixed Precision Configuration: For the multiple mixed-precision candidate schemes generated through optimization, a condition number-based floating-point error detection method is used to obtain the key input set. Random and stratified sampling is then used to identify input samples prone to triggering high errors. During the scheme evaluation phase, the key inputs are sequentially substituted into each candidate scheme, the output error is calculated and compared with a high-precision benchmark, and the proportion of samples meeting the error threshold is statistically analyzed to assess its numerical stability. Finally, combining the pass rate and average execution time, a weighted scoring model is used for ranking and filtering to select the mixed-precision scheme that achieves the optimal balance between numerical accuracy and computational efficiency.

[0035] The specific implementation algorithm for mixed precision configuration evaluation is as follows: Function: Select the optimal mixed precision scheme Input: Candidate Mixed Precision Configuration Output: Optimal mixed precision scheme 1. Obtain the high-error input set X based on condition number analysis; 2. For each configuration Y, calculate the error of the samples in X; 3. Count the number of samples that pass the threshold u; 4. Sort by the number of passing samples in descending order; 5. If multiple configurations pass all samples, sort them in ascending order of execution time; 6. Select the optimal configuration. Experimental Results and Analysis: 1. Experimental conditions and preparation The experimental environment configuration is shown in Table 1. The core algorithm is implemented in C++ / C and relies on MPFR (128-bit) for high-precision computation support. Ten commonly used single-parameter arithmetic expressions from the FPBench standard test set were selected as test cases. The selection of the FPBench standard test set is based on its recognized authority in the field of floating-point computation optimization. These expressions simulate core operations in medical image processing (such as polynomial calculations in Fourier transform or iterative reconstruction algorithms), ensuring the repeatability and generality of the experimental results. The experiment uses IEEE-754 standard double-precision floating-point data as input and output to evaluate the effectiveness of the method.

[0036] Table 1 Experimental Environment The experimental environment configuration is shown in Table 1. The core algorithm is implemented in C++ / C and relies on MPFR (128-bit) for high-precision computation support. Ten commonly used single-parameter arithmetic expressions from the FPBench standard test set were selected as test cases, and IEEE-754 standard double-precision floating-point data were used as input and output to evaluate the effectiveness of the method.

[0037] The distribution of floating-point numbers on the real number axis is non-uniform. Directly using equal-interval sampling in the real number sense often leads to a severe imbalance in the coverage of samples in the floating-point space, thus affecting the representativeness of the test results. Therefore, the experiment uses segmented sampling based on the exponent characteristics of floating-point numbers: the input interval is divided into 2... 1 / 2 The step size is divided, and 30 valid points are randomly sampled in each sub-interval. This strategy ensures a balanced distribution of sampling points in the floating-point space and improves the representativeness of the parameters, thereby effectively avoiding test bias and improving the credibility of the results and the reliability of subsequent performance evaluation, especially in biomedical noisy data.

[0038] In terms of accuracy evaluation of test results, the experiment uses relative error as the main error calculation indicator to reflect the degree of deviation between the actual calculation result and the precise value. For performance evaluation, the actual execution time of test cases is recorded in seconds to measure computational efficiency under different implementations or configurations.

[0039] 2. Analysis of Experimental Results The experiment will determine the optimal mixed precision scheme (denoted as ). v 1 ) and the original double-precision expression (denoted as v double A comparison was made, and the MPFR high-precision expression (denoted as ) was introduced. ( ) is used as a reference benchmark. In the experiment, the accuracy threshold is set to 'a', and when the sampling points satisfy... ,in v test It can be v 1 or v double The accuracy test pass rate is defined as the percentage of sampling points that meet the accuracy test conditions out of all sampling points.

[0040] To avoid the influence of insufficient precision of the original double-precision expression on the results, the experiment uses the relative precision improvement ratio as an indicator, as shown in equation (1). A ratio greater than 1 indicates that the mixed precision scheme has better precision, and the larger the value, the more significant the improvement. At the same time, the performance speedup ratio (execution time ratio) is calculated. A ratio less than 1 indicates better performance, and the smaller the value, the more obvious the speedup.

[0041] Equation (1) Table 2 presents the experimental comparison results: columns 2-5 show the accuracy improvement ratio under different thresholds, and the last column shows the performance speedup ratio. The results indicate that the hybrid accuracy scheme... v 1 In most test cases, the expected accuracy-performance tradeoff was achieved: a moderate loss of accuracy for performance gains. The performance ratio was generally below 1, while the accuracy ratio was mostly below 1 when the threshold was strict, gradually approaching or even exceeding 1 as the threshold was relaxed.

[0042] Table 2 Experimental Results For some benchmarks, the mixed-precision variant exhibits minimal precision loss compared to the original expression. For instance, in the benchmark exp1x, its mixed-precision variant achieves a lower precision loss at a threshold of 1×10⁻⁶. -10 The accuracy of the expression at that time was even better than the original expression, with a ratio as high as 154.4%, which gradually decreased as the threshold was relaxed. Analysis shows that the original expression... xNumerical instability exists when the value is close to 0, resulting in a low pass rate in accuracy tests (at a threshold of 1×10). -10 At that time, the pass rate was only 35.3%. However, by performing equivalent transformations on the original expression, such as interval analysis and matching rule base operations, a variant based on Taylor expansion was generated. Taylor expansion effectively avoids the problems of the original expression in the case of polynomial approximation. x The numerical instability near 0 results in the mixed precision variant outperforming the original double precision implementation in the interval [-1,1].

[0043] However, not all mixed-precision variants suffer from minimal precision loss. Taking the benchmark NMSEproblem333 as an example, its mixed-precision variant exhibits significant precision loss, which increases progressively with threshold relaxation. Analysis reveals that the original expression contains multiple fractional operations, which amplify errors when the denominator approaches zero. Although mixed-precision variants reduce the number of steps through algebraic simplification, these simplification operations remain sensitive to low threshold conditions under mixed-precision conditions. Only when the threshold is relaxed to a certain extent does the advantage of algebraic simplification gradually become apparent, thus improving the precision performance of the mixed-precision variants.

[0044] The last column in Table 2 shows the performance improvement of the mixed-precision scheme compared to the original double-precision expression. When the ratio is less than 1, it indicates that the mixed-precision variant has achieved a performance improvement, and the lower the ratio, the more significant the performance improvement. However, the effect of mixed-precision optimization varies depending on the structure and computational characteristics of the benchmark expression, and not all benchmarks will show a significant performance improvement under mixed-precision optimization.

[0045] Taking the benchmark NMSEproblem333 as an example, the performance improvement is significant. Analysis revealed that the original expression contained multiple operations, requiring multiple memory accesses and calculations. The mixed-precision variant simplifies operation nodes and improves cache utilization through algebraic merging, which is the main reason for the performance improvement, enabling real-time processing in biomedical edge devices.

[0046] However, for other benchmarks, the performance improvement from hybrid precision optimization is relatively limited. Analysis revealed that most of these benchmark expressions are already in their simplified forms, making further computational compression difficult and thus limiting the potential for performance gains. Furthermore, the optimization process requires a trade-off between precision loss and performance improvement to ensure optimal overall performance in practical medical applications.

[0047] Furthermore, the conversion between low and high precision during mixed-precision optimization requires inserting additional conversion code. This not only increases code complexity but also, to some extent, increases time costs. For some simple or polynomial expressions, the time overhead of inserting conversion code may even exceed the performance improvement brought by mixed-precision optimization, resulting in no significant improvement in overall performance.

[0048] This invention generates a set of mathematically equivalent candidate expressions, uses condition number analysis to quickly screen the expression with the best numerical stability, implements node-level mixed precision configuration, and achieves precision optimization of floating-point expressions through a key input set verification scheme. Experimental results verify the effectiveness of the method.

[0049] The above is only used to illustrate the technical solution of the present invention and not to limit it. Any other modifications or equivalent substitutions made by those skilled in the art to the technical solution of the present invention, as long as they do not depart from the spirit and scope of the technical solution of the present invention, should be covered within the scope of the claims of the present invention.

Claims

1. A method for optimizing the precision of floating-point expressions in medical images based on condition number analysis, characterized in that: Includes the following steps: S1. Input the original floating-point expression of the medical image and transform it equivalently: For the original floating-point expression of the medical image, generate multiple mathematically equivalent candidate expressions with different numerical properties to reduce the accumulation of errors in intermediate results; the method for generating the candidate expressions includes algebraic structure transformation and polynomial structure transformation. S2. Expression Evaluation and Screening: The numerical stability of each candidate expression is quickly evaluated using an approximate condition number model, and K candidate expressions are selected as the preferred expressions. S3. Mixed Precision Generation: For the selected K preferred expressions, multiple mixed precision combination schemes are formed, and then multiple mixed precision code variants are generated from the mixed precision combination schemes. S4. Mixed Precision Configuration Evaluation: Select the scheme that best balances numerical precision and computational efficiency from a variety of mixed precision code variants.

2. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 1, characterized in that: The specific steps of S1 are as follows: S11, parse the original medical image floating-point expression into an AST; S12, classify and process variables or constants, function calls, and operator nodes; S13, reconstruct the calculation path of the expression through factorization, formula substitution, and term reordering to complete the algebraic structure transformation; S14, decompose the addition expression into independent sub-terms, merge like terms, and reduce coefficients to optimize the numerical stability of the expression, complete the polynomial structure transformation, and finally perform hash deduplication.

3. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 1, characterized in that: S2 specifically includes the following steps: S21, constructing an approximate condition number model based on the difference method; S22, performing perturbation input testing on each candidate expression to obtain the corresponding approximate condition number; S23, sorting the candidate expressions in ascending order according to the numerical value of the approximate condition number, and selecting the top K candidate expressions with low condition numbers and low sensitivity as preferred expressions.

4. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 1, characterized in that: S3 specifically includes the following steps: S31. Generate a corresponding AST for each preferred expression, assign a unique number to each operator node through post-order traversal, generate an operation order list, and ensure that child nodes are processed before parent nodes; S32. Node precision configuration: Set an upper limit on the number of high-precision nodes, select some nodes from them to set them as double precision, and keep the rest as single precision, forming multiple mixed precision combination schemes and recording them in the form of bitmasks; The double precision selection method is: based on the operation sequence, gradually increase the number of high-precision nodes n from 1 to the set threshold from the candidate nodes to generate all C(m,n) combinations, where m is the total number of candidate nodes; S33. Generate a precision mapping table according to the bitmask, and mark the corresponding nodes in the AST as high precision or low precision; recursively traverse the AST, set the variable type according to the mapping table and insert type conversion instructions to realize the mixed precision calculation logic.

5. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 1, characterized in that: S4 specifically includes the following steps: S41, identifying key input sets that are prone to triggering high errors through random and stratified sampling, the key input sets including medical image samples with high contrast or dense noise; S42, substituting the key input sets into each mixed precision code variant, calculating the output error and comparing it with a high precision benchmark, and statistically analyzing the proportion of samples that meet the error threshold to evaluate numerical stability; S43, combining the sample pass rate and average execution time, sorting and filtering according to a weighted scoring model, and selecting the mixed precision code variant that achieves the optimal balance between numerical accuracy and computational efficiency.

6. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 2, characterized in that: In S11, the classification processing of AST nodes specifically includes: for function call nodes, recursively applying transformations to parameters and generating equivalent forms using trigonometric identities in the rule base; and for operator nodes, recursively processing their subexpressions, applying the distributive law to multiplication operations to expand the addition structure, merging like terms in addition operations, and performing operation order transformations.

7. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 3, characterized in that: In S2, the specific implementation algorithm of the approximate condition number model is as follows:

1. Calculate the value b of the candidate expression f(a) at the input point a; 2. Obtain the system constant ε, which represents the machine precision of floating-point calculation; 3. Calculate the disturbance value h based on the system constant ε and the input point a. ; 4. Calculate the perturbation value f using the perturbation value h. plus , where f plus = f(a + h); 5. Calculate the expression value f after the perturbation. plus The difference δ between the value b and the value b f , where δ f =f plus –b; 6. Based on the difference δ f The approximate derivative is calculated using the disturbance value h, where the approximate derivative = δ f / h; 7. Determine if the value b is zero: If b = 0, return infinity when δf ≠ 0, otherwise return 0.0; if b ≠ 0, calculate and return the approximate condition number, which is |(approximate derivative × a) / b|.

8. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 4, characterized in that: The specific implementation algorithm for node-level precision configuration in S32 is as follows: Input the selected preferred expression and output a mixed precision code variant; 1. Generate by traversing according to the operation sequence opOrder; 2. Initialize the number of high-precision nodes n=1 and generate C(m,1) configuration schemes; 3. Gradually increase n to generate C(m,n) combinations until a threshold is reached; 4. For the mixed precision combination scheme that meets the threshold, map it to a precision allocation rule; 5. According to the precision allocation rules, recursively traverse the abstract syntax tree of the expression and assign the corresponding precision type to the operation nodes therein; Based on the abstract syntax tree with precision assignments already completed, the final mixed-precision code variant is generated.

9. The method for optimizing the precision of floating-point expressions in medical images based on condition number analysis according to claim 5, characterized in that: The layered sampling in S41 adopts a method based on the characteristics of floating-point exponent bits, specifically including the following steps:

1. Divide the input interval into 2 1 / 2 1. Divide the step size into multiple sub-intervals; 2. Randomly sample 30 valid points in each sub-interval as test samples to ensure coverage of sensitive areas of floating-point number distribution; The high-precision benchmark in S42 is generated by 128-bit high-precision calculation provided by the MPFR library. The output error of all mixed precision combination schemes is compared with the 128-bit high-precision benchmark to quantify the numerical precision.