Skip to content

[KernelGen][Nvidia] Add dsplit operator with view implementation - #5426

Open
ShawnsYing wants to merge 1 commit into
flagos-ai:masterfrom
ShawnsYing:pr/dsplit
Open

[KernelGen][Nvidia] Add dsplit operator with view implementation#5426
ShawnsYing wants to merge 1 commit into
flagos-ai:masterfrom
ShawnsYing:pr/dsplit

Conversation

@ShawnsYing

Copy link
Copy Markdown
Contributor

Summary

This PR adds the dsplit operator with view implementation that performs zero-copy depth-wise splitting along dimension 2.

The implementation delegates to existing torch.split and torch.tensor_split functions following the established pattern for view operators.

Operators registered in conf/operators.yaml:

  • dsplit (marks: dsplit)

Testing

Tested on H20 GPU:

  • ✅ 14 test cases covering 3D and 4D tensors
  • ✅ Both integer sections (.int overload) and index arrays (.array overload)
  • ✅ Multiple dtypes: float16, bfloat16, float32
  • ✅ All tests passed in 0.77s

Performance

Benchmark completed successfully on H20 GPU in 13.97s.

View operators achieve zero-copy semantics by sharing storage with the original tensor.

Multi-backend Testing

  • ✅ NVIDIA: Passed

Files changed

  • src/flag_gems/ops/dsplit.py: Implementation
  • src/flag_gems/ops/__init__.py: Import registration
  • src/flag_gems/__init__.py: ATen dispatch registration for dsplit.int and dsplit.array
  • conf/operators.yaml: Operator configuration
  • tests/test_dsplit.py: Accuracy tests
  • benchmark/test_dsplit.py: Performance tests

"cumsum_out",
"deg2rad",
"deg2rad_",
"dsplit",

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.

sort by a-z.

logger = logging.getLogger(__name__)


def dsplit(input: torch.Tensor, indices_or_sections: Union[int, List[int]]):

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.

So, it's not a triton operator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants