Tensor Stride Update for Binary Operations
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing data processing technologies face difficulties in performing binary operations between tensors with different dimensions without increasing the complexity of hardware design, as most data processing chips cannot support such operations.
Innovation Solution
A method and apparatus that determine the dimension difference between two tensors, update the stride in the different dimension to a predetermined value, and read a to-be-operated data block from a buffer module for padding processing, enabling binary operations between tensors with different dimensions without requiring hardware support for broadcasting.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If hardware supports broadcasting to perform binary operations on tensors with different dimensions, then the operation capability is improved, but the hardware design complexity increases
Solution Approach 1:
The patent replaces hardware-level broadcasting support with a software-based stride update mechanism. Instead of modifying hardware to support broadcasting operations, the system updates stride parameters in software to achieve the same effect of performing binary operations on tensors with different dimensions, thereby avoiding increased hardware design complexity.
Solution Approach 2:
The patent changes the stride parameter of the first tensor to enable binary operations with tensors of different dimensions. By dynamically adjusting the stride parameter, the system can correctly access and operate on corresponding elements of tensors with different shapes without requiring hardware broadcasting support, thus maintaining simple hardware design while improving operation capability.
2Measurement precision
If stride is updated to perform padding processing, then the reading position accuracy is improved, but the data processing complexity increases
Solution Approach 1:
The patent performs stride update and padding processing in advance before the actual binary operation. By pre-calculating the correct stride values and preparing the data blocks with appropriate padding, the system ensures accurate reading positions during operation without adding complexity to the core computation process. The complexity is shifted to the preparation phase rather than the execution phase.
Data Source
AI summary
Embodiments of the present disclosure disclose a method and apparatus for calculating tensor data based on a computer, a medium, and a device. The method includes: determining, from a second tensor, a dimension different from a dimension of a first tensor based on dimensions of the first tensor and dimensions of the second tensor; updating stride in the different dimension to a predetermined value; reading a to-be-operated data block of the second tensor from a buffer module based on updated stride with the predetermined value in each dimension of the second tensor, where the to-be-operated data block is a data block for which padding processing is performed; and performing binary operation on the first tensor based on the to-be-operated data block of the second tensor. According to the present disclosure, broadcasting may be conveniently achieved without difficulty of hardware design being increased.


