[API compatibility]Fix trunc mode in divide op when input x is integer#74903
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
1f5e3e9 to
9a84701
Compare
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (77.77%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #74903 +/- ##
==========================================
Coverage ? 77.77%
==========================================
Files ? 1
Lines ? 9
Branches ? 0
==========================================
Hits ? 7
Misses ? 2
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| tmp = _C_ops.divide(x, y) | ||
| res = _C_ops.trunc(tmp, out=out) | ||
|
|
||
| if x.dtype in ( |
There was a problem hiding this comment.
rounding_mode=None:int提升到float
rounding_mode=floor:int不提升,仍为int
rounding_mode=trunc:int不提升,仍为int
floor下会有这个问题吗
There was a problem hiding this comment.
floor没有这个问题,NeedTypePromotion里边专门针对divide的int的输入做了转换,trunc这里复用了divide需要转换, floor_divide是单独的kernel实现。
There was a problem hiding this comment.
rounding_mode=None:int提升到float rounding_mode=floor:int不提升,仍为int rounding_mode=trunc:int不提升,仍为int
floor下会有这个问题吗
所以这里相当于 误提升到了float,然后又降回int,做了两个不必要操作。
后面可以看下直接新增一个 trunc_divide kernel成本大不大,不大的话可以做下,性能会好不少。
不是很紧急先合入这一版了。
| tmp = _C_ops.divide(x, y) | ||
| res = _C_ops.trunc(tmp, out=out) | ||
|
|
||
| if x.dtype in ( |
There was a problem hiding this comment.
rounding_mode=None:int提升到float rounding_mode=floor:int不提升,仍为int rounding_mode=trunc:int不提升,仍为int
floor下会有这个问题吗
所以这里相当于 误提升到了float,然后又降回int,做了两个不必要操作。
后面可以看下直接新增一个 trunc_divide kernel成本大不大,不大的话可以做下,性能会好不少。
不是很紧急先合入这一版了。
PR Category
User Experience
PR Types
New features
Description
当 rounding_mode 为 trunc 时,_C_ops.divide 在输入 x 和 y 均为 int 类型的情况下,会将类型提升为 float32,实际 trunc 应保持 int 类型,其输出结果也应维持 int 类型。
注:
pcard-67164