Skip to content

Remove IterType::gatherscatter - #4131

Merged
naoyam merged 7 commits into
mainfrom
remove_itertype_gatherscatter
Apr 7, 2026
Merged

Remove IterType::gatherscatter#4131
naoyam merged 7 commits into
mainfrom
remove_itertype_gatherscatter

Conversation

@naoyam

@naoyam naoyam commented Mar 21, 2025

Copy link
Copy Markdown
Contributor

Just cleaning up an obsolete IterType. Nothing should depend on IterType::GatherScatter anymore.

@naoyam

naoyam commented Mar 21, 2025

Copy link
Copy Markdown
Contributor Author

!test --diff

@github-actions

Copy link
Copy Markdown

Description

  • Removed unnecessary IterType::GatherScatter usage

  • Simplified IterDomainBuilder in gather function


Changes walkthrough 📝

Relevant files
Enhancement
indexing.cpp
Simplify IterDomainBuilder usage                                                 

csrc/ops/indexing.cpp

  • Removed IterType::GatherScatter assignment in IterDomainBuilder
  • Simplified out_domain construction in gather function
  • +1/-7     

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🧪 No relevant tests
    ⚡ Recommended focus areas for review

    Performance Impact

    The change removes the specific IterType::GatherScatter setting for IterDomain. This might affect the performance of gather operations, especially if GatherScatter was used for optimization purposes.

    out_domain.push_back(IterDomainBuilder(idx_domain_ptr).build());

    @naoyam naoyam changed the title Don't use IterType::gatherscatter with gather [WIP] Don't use IterType::gatherscatter with gather Apr 4, 2025
    @naoyam

    naoyam commented Apr 7, 2026

    Copy link
    Copy Markdown
    Contributor Author

    !test --diff

    @naoyam naoyam changed the title [WIP] Don't use IterType::gatherscatter with gather [WIP] Remove IterType::gatherscatter Apr 7, 2026
    Naoya Maruyama added 2 commits April 7, 2026 10:57
    @naoyam

    naoyam commented Apr 7, 2026

    Copy link
    Copy Markdown
    Contributor Author

    !test --diff

    @naoyam naoyam changed the title [WIP] Remove IterType::gatherscatter Remove IterType::gatherscatter Apr 7, 2026
    @naoyam
    naoyam marked this pull request as ready for review April 7, 2026 18:36
    @greptile-apps

    greptile-apps Bot commented Apr 7, 2026

    Copy link
    Copy Markdown
    Contributor

    Greptile Summary

    This PR removes IterType::GatherScatter from the codebase, a special iter-type previously assigned to the output domains of gather and scatter operations. Gather/scatter outputs now use the regular IterType::Iteration, the contiguity logic that was guarded by the GatherScatter special-case is removed, and all related assertions and helper methods (isGatherScatter()) are cleaned up. The diff also bundles several unrelated hygiene improvements: std::ranges algorithms, std::uint8_t underlying types on several enums, named aggregate-initializer syntax, and minor data_type_to_aten consolidations.

    Confidence Score: 5/5

    Safe to merge — all GatherScatter references are consistently removed and no functional regressions are apparent.

    The removal is complete and internally consistent: the enum value, helper predicate, contiguity guards, merge logic, validation checks, and the corresponding test are all updated in lock-step. The data_type_to_aten fallback simplification is functionally identical (8-bit types without explicit switch cases still reach the else-Byte branch). No P0 or P1 issues found.

    No files require special attention.

    Important Files Changed

    Filename Overview
    csrc/type.h Removes IterType::GatherScatter from the enum and adds std::uint8_t underlying type to IterType and many other enums.
    csrc/type.cpp Removes iter_type2string case for GatherScatter; consolidates data_type_to_aten 8-bit fallback into the else branch (functionally identical); minor named-initializer and max_digits10 cleanups.
    csrc/ir/internal_base_nodes.h Removes the isGatherScatter() convenience predicate from IterDomain.
    csrc/ir/internal_base_nodes.cpp Removes special merge logic for GatherScatter+Broadcast and the GatherScatter branch in parallelize() for ParallelType::Group.
    csrc/ops/indexing.cpp gather() and scatter() output domains now use cloneWithoutRFactor() (Iteration type) instead of explicitly setting GatherScatter; no logic change beyond iter-type assignment.
    csrc/ops/utils.cpp Removes GatherScatter handling from promoteIterType and newOutputIterDomain; comment updated to match.
    csrc/contiguity.cpp Removes !GatherScatter guard in ContigIDs::build; also adopts std::ranges algorithms.
    csrc/id_model/contiguity.cpp Removes !GatherScatter guard in ContigIDGroups; also adopts std::ranges algorithms.
    csrc/device_lower/validation.cpp Narrows ParallelType::Group check to IterType::Iteration only; comment updated correctly.
    csrc/fusion_segmenter.cpp Removes the assertion that disjoint loop/logical is only allowed for scatter outputs with GatherScatter iter type, since that invariant no longer holds.
    csrc/runtime/fusion_executor_cache.h Adds cstdint include and fixes PrimDataType forward declaration to include std::uint8_t underlying type.
    csrc/runtime/fusion_kernel_runtime.h Same as fusion_executor_cache.h: adds cstdint and fixes PrimDataType forward declaration.
    tests/cpp/test_scatter.cpp Removes the GatherScatterIterType test that verified the (now-deleted) GatherScatter iter type was assigned to scatter output domains.

    Flowchart

    %%{init: {'theme': 'neutral'}}%%
    flowchart TD
        A["gather() / scatter() call"] --> B["Build output IterDomains"]
        
        B --> C_old["OLD: if IterType::Iteration\n→ set IterType::GatherScatter\nelse keep original"]
        B --> C_new["NEW: cloneWithoutRFactor()\n(keeps original IterType)"]
        
        C_old --> D_old["Output domain has\nIterType::GatherScatter"]
        C_new --> D_new["Output domain has\nIterType::Iteration"]
        
        D_old --> E_old["Contiguity check:\nskip GatherScatter domains\n(never contig)"]
        D_new --> E_new["Contiguity check:\nnormal rules apply\n(can be contig)"]
        
        D_old --> F_old["fusion_segmenter:\ndisjoint loop/logical\nrequires GatherScatter"]
        D_new --> F_new["fusion_segmenter:\ndisjoint loop/logical\nallowed (no type check)"]
        
        D_old --> G_old["ParallelType::Group:\nallowed on Iteration or GatherScatter"]
        D_new --> G_new["ParallelType::Group:\nallowed on Iteration only"]
    
        style C_old fill:#ffcccc
        style D_old fill:#ffcccc
        style E_old fill:#ffcccc
        style F_old fill:#ffcccc
        style G_old fill:#ffcccc
        style C_new fill:#ccffcc
        style D_new fill:#ccffcc
        style E_new fill:#ccffcc
        style F_new fill:#ccffcc
        style G_new fill:#ccffcc
    
    Loading

    Reviews (3): Last reviewed commit: "fix" | Re-trigger Greptile

    Comment thread csrc/device_lower/validation.cpp Outdated
    Naoya Maruyama and others added 2 commits April 7, 2026 13:08
    Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
    @naoyam

    naoyam commented Apr 7, 2026

    Copy link
    Copy Markdown
    Contributor Author

    !test --diff

    @naoyam

    naoyam commented Apr 7, 2026

    Copy link
    Copy Markdown
    Contributor Author

    !test --diff

    @naoyam
    naoyam requested a review from jjsjann123 April 7, 2026 21:01

    @jjsjann123 jjsjann123 left a comment

    Copy link
    Copy Markdown
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    blind stamp with full trust.

    @naoyam
    naoyam merged commit 29f5740 into main Apr 7, 2026
    55 of 57 checks passed
    @naoyam
    naoyam deleted the remove_itertype_gatherscatter branch April 7, 2026 23:30
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants