[PHI] Preliminary fix for elementwise broadcast int32 shape overflow #72584
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
PR Category
Operator Mechanism
PR Types
Bug fixes
Description
修复了部分带有 broadcast 的 elementwise 操作中,shape inference使用 int32 导致大Tensor内出现溢出的问题,目前有如下几个算子得到了修复:
bitwise_leftshift&bitwise_rightshiftequalfminhypotlogical_ormasked_fillfunctional.normalizefunctional.pairwise_distanceargsort目前暂未测试,预计也可以完成修复,但现有设备显存不够,无法进行大Tensor测试。此外,目前的fix只进行了最简单且与API正确性扫描结果相关的修正,实际发现库中还有很多使用int进行shape推导的地方。
示例
这里只给出几个例子,均是原来不正确,现在正确的单测:
bitwise_left_shift:fmin:masked_fill:性能分析
目前的改动都还没有到GPU kernel内部使用 int64 进行计算,故经过nsys profiling测试,没有发现显著性能差异。
Pcard-89620