feat(ops): add Copy operator - #872
Merged
Merged
Conversation
voltjia
force-pushed
the
feat/add-copy-operator
branch
from
August 5, 2026 07:27
185b4c9 to
5bae094
Compare
voltjia
marked this pull request as ready for review
August 5, 2026 07:37
This was referenced Aug 6, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Copyoperator with the public C++ signatureCopy(const Tensor src, const bool non_blocking, Tensor out).RearrangeInfinilmAPI and tests intact while reusingCopyKerneldirectly.test_copycoveringnon_blocking, broadcasting, non-contiguous layouts, and float32/float16/bfloat16.Motivation
RearrangeInfinilmwas introduced as an InfiniLM compatibility operator and is now deprecated. A normal operator aligned with an established open-source API is required before downstream callers can migrate away from the suffixed interface.API Alignment
Copy(const Tensor src, const bool non_blocking, Tensor out)Tensor.copy_(src, non_blocking=False) -> Tensorsrcandnon_blockingpreserve the PyTorch order. PyTorch's mutable receiver/returnedselfis represented by trailing caller-providedoutper the InfiniOps input-attribute-output convention. InfiniOps usesCopy/copyrather than an in-place_suffix because mutation is expressed byout. The C++ API requires the defaulted boolean explicitly and does not add a convenience overload.torch.Tensor.copy_Type of Change
feat- new feature / new operator / new platformfix- bug fixperf- performance improvement (no behavioral change)refactor- code restructuring without behavior changetest- adding or fixing tests onlydocs- documentation onlybuild/ci- build system or CI configurationchore- tooling, formatting, or other non-code changesPlatforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
NVIDIA A100-SXM4-80GB,
accelerator-dev/nvidia:latest:Test Results on Supported Platforms
copy+rearrange_infinilm:54 passed, 54 skipped in 1.85s; wrapper generator:22 passed in 1.58sBenchmark / Performance Impact
N/A. This adds an API migration path and reuses the same elementwise copy kernel for the canonical and compatibility operators.
Notes for Reviewers
RearrangeInfinilmremains deprecated and its public signature and test coverage are unchanged.non_blockinghas no effect; the parameter is retained to keep the canonical interface complete.torch_ops.yaml, CMake allowlist, generated artifact, or default-value overload is added.clang-format 21.1.8andruff 0.15.22.