Program Compilation for Variable Type Conflicts in Differentiation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing program compilation systems fail to handle variable operation type conflicts, leading to redundant code and poor running performance due to incorrect differentiation results.

Innovation Solution

Update the operation type of variables with conflicting types to ensure consistency, omitting differentiation where necessary, and apply the chain rule to combine derivative function expressions, thereby simplifying the compilation result.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If the existing compilation system performs differentiation on all variables in expressions, then complete differentiation results are obtained, but redundant code is generated and running performance deteriorates

Engineering Contradiction:
Improvedifferentiation completenessVSAvoidrunning performance
Core Design Contradiction:
Measurement precisionVSProductivity

Solution Approach 1:

The patent extracts and identifies variables with operation type conflicts from the program expressions. By detecting which variables are both input and output variables across different expressions, the system selectively excludes these specific variables from differentiation operations, removing only the necessary redundant parts while preserving complete differentiation for other variables.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent changes the operation type parameter of identified conflict variables from 'differential' to 'non-differential'. By modifying this parameter attribute, the compilation system adjusts the differentiation behavior for specific variables, preventing redundant code generation while maintaining differentiation completeness for variables that require it.

Inventive Principle:
Principle #35Parameter changes

2Reliability

If the compilation system processes variables with operation type conflicts as differential, then differentiation is performed, but redundant code is generated in the compiled program

Engineering Contradiction:
Improvedifferentiation correctnessVSAvoidcode redundancy
Core Design Contradiction:
ReliabilityVSLoss of substance

Solution Approach 1:

The patent performs preliminary analysis of variable operation types before the differentiation compilation process. By pre-identifying variables that have both input and output roles across expressions, the system prepares a list of variables to exclude from differentiation, preventing redundant code generation before it occurs during compilation.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent converts the potentially harmful operation type conflict (where a variable serves dual roles) into a benefit by using this conflict information to identify and exclude redundant differentiation operations. The conflict itself becomes the basis for optimizing the compiled program by removing unnecessary code.

Inventive Principle:
Principle #22Blessing in disguise (Convert harm into benefit)

3Measurement precision

If the compilation system performs differentiation on variables that are both input and output, then complete derivative expressions are generated, but debugging time increases

Engineering Contradiction:
Improvederivative expression completenessVSAvoiddebugging time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent extracts and removes variables with operation type conflicts from the differentiation process. By excluding these specific variables that would generate redundant derivative expressions, the system reduces the amount of code requiring debugging while preserving complete and correct differentiation for all other variables.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS12613682B2Program compilation method and apparatus
Publication Date: 2026.04.28 HUAWEI TECH CO LTD
  • US12613682B2 patent drawing
  • US12613682B2 patent drawing
  • US12613682B2 patent drawing

AI summary

A program compilation method and apparatus operate by: obtaining a first expression and a second expression of a program, where the first expression and the second expression generate a dependency relationship based on a first variable, and operation types of the first variable in the first expression and the second expression are different, and updating an operation type of the first variable; so that the first variable has no differential result or a result is zero after encountering a differential operation; separately processing the first expression and the second expression according to the updated operation type of the first variable, to obtain a corresponding derivative function expression; and; combining, based on a chain rule, derivative function expressions respectively corresponding to the first expression and the second expression, to obtain a compilation result of the program.