forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[inductor] Use int64_t as index type for all platfroms 4 (pytorch#133892
) It is parallel PR to pytorch#133819 , and it is append change for @jansel 's comments. 1. For `torch/_inductor/codegen/cpp_wrapper_cpu.py`, revert to origin code to append LL on MacOS and Windows: pytorch@bdc14ad 2. For `torch/_inductor/codegen/cpp_utils.py`, append LL on MacOS and Windows forlarge constants. And fix its UTs: pytorch@3a56b76 ------------------------------ Another solution for pytorch#133615, use `int64_t` as index type for all plartform. ### Development notes: The metioned PR( pytorch#133615) is fix the index type not match to parse_arg args types. As reviewed with @jansel , Jason think we need to unificate `INDEX_TYPE` for all platforms. Current code is make code cumbersome: ```python INDEX_TYPE = "int64_t" if _IS_WINDOWS else "long" ``` So, I have some attempts to unificate `INDEX_TYPE` as `long` or `int64_t`. For use `long` as index type: pytorch#133768 For use `int64_t` as index type: pytorch#133782 Since that, we still discussed which type we will select as final solution. ![image](https://github.com/user-attachments/assets/b23fa577-2d40-4bd6-b934-fb7994fe0bb0) `long` type is different define and size in different OSs and different compilers. So, @jansel make decision that, we need to select `int64_t` for all platforms. So, I would comtine my work based on pytorch#133782. As pytorch#133782 still has two issues: 1. std::min/std::max could not match function instances by arg types. It as fixed and validated in PR: pytorch#133812 4. Cuda TestMemoryPlanning::test_cpp_wrapper issue by wrong index type. It is fixing in this PR. So, we made final solution in this PR. ### Changes: **1. Use `int64_t` type as index type for all OSs: `Windows`, `Linux` and `MacOS`.** **2. Use static_cast<int64_t>(`constant`) to convert constant to `div_floor_integer` with args type(`int64_t`).** **3. Update `parse_arg` function signature to `int64_t`, which follow the index type.** **4. Append double L(`LL`) to constant on Windows and MacOS, because of their int64_t are are long long.** **5. Fix `std::min/std::max` type miss match by static_cast to `INDEX_TYPE`.** **6. Fix UTs, containts: cuda `TestMemoryPlanning::test_cpp_wrapper`, and `test_indexing.py`.** Pull Request resolved: pytorch#133892 Approved by: https://github.com/jansel
- Loading branch information
1 parent
3caf3ba
commit fbf3fc2
Showing
4 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters