Polyhedral Compiler Static Versioning for Dynamic Tensors

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing polyhedral compilation techniques struggle to effectively optimize loop-based programs with dynamic tensor sizes, as run-time tensor sizes are unknown at compilation time, limiting the mapper's ability to make informed mapping decisions.

Innovation Solution

The approach involves versioning the source code at compile-time by generating multiple versions of the internal representation (IR) with distinct contexts based on potential run-time parameter values, allowing the polyhedral compiler to explore tradeoffs between parallelization, data-locality, and data-layout transformation, and using affine approximation or artificial neural networks for linearization of non-linear constraints.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Manufacturing precision

If multiple versions of IR with distinct contexts are generated to explore tradeoffs between parallelization and data locality, then optimization quality improves, but device complexity increases

Engineering Contradiction:
Improveoptimization qualityVSAvoiddevice complexity
Core Design Contradiction:
Manufacturing precisionVSDevice complexity

Solution Approach 1:

The patent segments the compilation process by creating multiple versions of the internal representation (IR) with distinct contexts, where each version explores different optimization tradeoffs. This segmentation allows the system to evaluate parallelization versus data locality separately for each version, improving overall optimization quality while managing complexity through structured division of the compilation task.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces dynamic version selection at runtime based on actual parameter values. The wrapper function dynamically chooses which versioned IR to execute by evaluating runtime parameters against context constraints, allowing the system to adapt to different execution scenarios and achieve optimal performance without committing to a single static optimization strategy.

Inventive Principle:
Principle #15Dynamics

2Adaptability or versatility

If polyhedral compilation is performed at runtime for new parameter instances, then adaptability improves, but productivity decreases

Engineering Contradiction:
ImproveadaptabilityVSAvoidproductivity
Core Design Contradiction:
Adaptability or versatilityVSProductivity

Solution Approach 1:

The patent performs preliminary polyhedral compilation at compile time for multiple potential parameter values, creating versioned IRs in advance. This preliminary action stores pre-compiled versions that can be quickly selected at runtime based on actual parameter values, avoiding the need to perform full polyhedral compilation during runtime execution.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent creates multiple copies of the IR with different context constraints, where each copy represents a pre-compiled version for specific parameter ranges. At runtime, the system copies or selects the appropriate pre-compiled version based on actual parameters, avoiding repeated compilation work while maintaining adaptability to different parameter instances.

Inventive Principle:
Principle #26Copying

3Ease of manufacture

If non-linear constraints are linearized using affine approximation or neural networks, then ease of manufacture improves, but measurement precision decreases

Engineering Contradiction:
Improveease of manufactureVSAvoidmeasurement precision
Core Design Contradiction:
Ease of manufactureVSMeasurement precision

Solution Approach 1:

The patent transforms non-linear constraints into linear forms through parameter changes, using either affine approximation (changing the mathematical representation) or neural network-based linearization (changing how constraints are expressed). This transformation makes the constraints easier to process by polyhedral compilation tools while accepting a tradeoff in precision, allowing the system to handle complex runtime parameters more efficiently.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS11693636B2Static versioning in the polyhedral model
Publication Date: 2023.07.04 QUALCOMM INC
  • US11693636B2 patent drawing
  • US11693636B2 patent drawing
  • US11693636B2 patent drawing

AI summary

An approach is presented to enhancing the optimization process in a polyhedral compiler by introducing compile-time versioning, i.e., the production of several versions of optimized code under varying assumptions on its run-time parameters. We illustrate this process by enabling versioning in the polyhedral processor placement pass. We propose an efficient code generation method and validate that versioning can be useful in a polyhedral compiler by performing benchmarking on a small set of deep learning layers defined for dynamically-sized tensors.