Variable-Shape Tensor Processing With Dynamic Work Plans
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing machine learning (ML) methods struggle with inefficiencies when processing tensors of variable shapes, as traditional approaches either require inefficient recompilation for each shape or cumbersome padding, preventing effective application of graph-level optimizations.
Innovation Solution
A modifiable work plan is generated that supports a range of tensor shapes, allowing real-time modification based on actual tensor dimensions, enabling efficient processing of variable-shape tensors using computational engines.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If traditional approaches are used to process tensors of variable shapes, then each shape requires separate handling, but this leads to inefficient recompilation for each shape
Solution Approach 1:
The work plan is designed to support multiple tensor shapes universally through range specifications. Instead of creating separate work plans for each shape, a single work plan can handle ranges of shapes by defining minimum and maximum dimensions, allowing the same computational graph to process tensors of varying sizes without recompilation.
Solution Approach 2:
The system dynamically determines the actual tensor shape at runtime and selects or generates an appropriate work plan based on the input dimensions. This dynamic adaptation allows the system to handle variable shapes efficiently by matching the computational plan to the actual data dimensions without requiring pre-compilation for every possible shape.
2Adaptability or versatility
If traditional approaches are used to process tensors of variable shapes, then each shape requires separate handling, but this leads to cumbersome padding operations
Solution Approach 1:
The system changes the parameter representation from fixed shapes to shape ranges with minimum and maximum bounds. This allows the work plan to specify computational operations that adapt to the actual tensor dimensions within the range, eliminating the need for padding operations and associated computational overhead.
3Manufacturing precision
If recompilation is performed for each tensor shape, then shape-specific optimization is achieved, but this increases processing time
Solution Approach 1:
The system performs preliminary preparation by defining work plans with shape ranges and placeholder dimensions before runtime execution. This preliminary structuring allows the computational graph to be prepared once for a range of shapes, avoiding the need for repeated recompilation while maintaining shape-specific optimization capabilities through runtime parameter substitution.
4Productivity
If fixed work plans are used for tensor processing, then execution efficiency is improved, but this reduces flexibility for variable shapes
Solution Approach 1:
The work plan is segmented into fixed computational operations and variable parameters representing tensor dimensions. This segmentation allows the computational graph structure to remain fixed for efficiency while the dimensional parameters can vary to accommodate different tensor shapes, combining the benefits of both fixed and flexible approaches.
Data Source
AI summary
An apparatus includes a memory and one or more processors. The memory is configured to store tensors for Machine Learning (ML) processing. The one or more processors are configured to receive a work plan associated with a subgraph of a ML graph of a ML model, the work plan supports processing of tensors having respective shapes in a selected range of shapes. A shape of a tensor specifies respective sizes of dimensions of that tensor. The one or more processors are further configured to receive from the memory an input tensor having an actual shape, to modify the work plan based on the actual shape to produce a modified work plan for processing the input tensor in accordance with the subgraph, and to process the input tensor in accordance with the subgraph by submitting the modified work plan for execution by one or more of the processors.


