This is an automated email from the ASF dual-hosted git repository.

tlopex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 2516b1fd0d [REFACTOR][RUNTIME] Phase out IntTuple alias; use 
ffi::Shape directly (#19471)
2516b1fd0d is described below

commit 2516b1fd0d96f61e4f47b2cd9cf163786b54facc
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed Apr 29 14:46:57 2026 -0400

    [REFACTOR][RUNTIME] Phase out IntTuple alias; use ffi::Shape directly 
(#19471)
    
    ## Summary
    
    `include/tvm/runtime/int_tuple.h` was a 2-line alias header
    (`using IntTuple = ffi::Shape`). The alias adds indirection without
    earning its keep — `ffi::Shape` is short enough that aliasing it gives
    no ergonomic gain, and the layered name makes the reader follow one
    extra
    hop ("what's IntTuple? oh, Shape") at every call site.
    
    - Deleted `include/tvm/runtime/int_tuple.h`
    - Rewrote the 5 use sites (`disco/session.h`, `disco/bcast_session.h`,
      `vm/kv_state.h`, `vm/attn_utils.h`, `vm/attn_backend.h`) to use
      `ffi::Shape` / `ffi::ShapeObj` directly
    - The `as_int_tuple()` member function in `attn_utils.h` keeps its name
      (semantic identifier; renaming is out of scope)
---
 include/tvm/runtime/disco/session.h |  4 ++--
 include/tvm/runtime/int_tuple.h     | 38 -------------------------------------
 src/runtime/disco/bcast_session.h   |  2 +-
 src/runtime/vm/attn_backend.h       |  1 -
 src/runtime/vm/attn_utils.h         |  7 ++++---
 src/runtime/vm/kv_state.h           | 15 ++++++++-------
 6 files changed, 15 insertions(+), 52 deletions(-)

diff --git a/include/tvm/runtime/disco/session.h 
b/include/tvm/runtime/disco/session.h
index daae2954af..c81a379454 100644
--- a/include/tvm/runtime/disco/session.h
+++ b/include/tvm/runtime/disco/session.h
@@ -73,8 +73,8 @@
 #ifndef TVM_RUNTIME_DISCO_SESSION_H_
 #define TVM_RUNTIME_DISCO_SESSION_H_
 
+#include <tvm/ffi/container/shape.h>
 #include <tvm/ffi/function.h>
-#include <tvm/runtime/int_tuple.h>
 #include <tvm/runtime/object.h>
 #include <tvm/runtime/tensor.h>
 
@@ -240,7 +240,7 @@ class SessionObj : public Object {
    * \param ccl The name of the communication backend, e.g., nccl, rccl, mpi.
    * \param device_ids The device ids of the workers.
    */
-  TVM_RUNTIME_DLL virtual void InitCCL(ffi::String ccl, IntTuple device_ids) = 
0;
+  TVM_RUNTIME_DLL virtual void InitCCL(ffi::String ccl, ffi::Shape device_ids) 
= 0;
   /*!
    * \brief Get the value of a register from a remote worker.
    * \param reg_id The id of the register to be fetched.
diff --git a/include/tvm/runtime/int_tuple.h b/include/tvm/runtime/int_tuple.h
deleted file mode 100644
index 032e8b9a32..0000000000
--- a/include/tvm/runtime/int_tuple.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*!
- * \file int_tuple.h
- * \brief Defines tuple of integers.
- */
-#ifndef TVM_RUNTIME_INT_TUPLE_H_
-#define TVM_RUNTIME_INT_TUPLE_H_
-
-#include <tvm/ffi/container/shape.h>
-
-namespace tvm {
-namespace runtime {
-
-// We simply redirects to ffi::Shape, and ffi::ShapeObj
-using IntTuple = ffi::Shape;
-using IntTupleObj = ffi::ShapeObj;
-
-}  // namespace runtime
-}  // namespace tvm
-#endif  // TVM_RUNTIME_INT_TUPLE_H_
diff --git a/src/runtime/disco/bcast_session.h 
b/src/runtime/disco/bcast_session.h
index 119ca36409..dc9760ee81 100644
--- a/src/runtime/disco/bcast_session.h
+++ b/src/runtime/disco/bcast_session.h
@@ -41,7 +41,7 @@ class BcastSessionObj : public SessionObj {
   void CopyToWorker0(const Tensor& host_array, const DRef& remote_array) 
override;
   void SyncWorker(int worker_id) override;
   void Shutdown() override;
-  void InitCCL(ffi::String ccl, IntTuple device_ids) override;
+  void InitCCL(ffi::String ccl, ffi::Shape device_ids) override;
   ffi::Any DebugGetFromRemote(int64_t reg_id, int worker_id) override = 0;
   void DebugSetRegister(int64_t reg_id, ffi::AnyView value, int worker_id) 
override = 0;
 
diff --git a/src/runtime/vm/attn_backend.h b/src/runtime/vm/attn_backend.h
index 7f87f4f36d..5db83ff499 100644
--- a/src/runtime/vm/attn_backend.h
+++ b/src/runtime/vm/attn_backend.h
@@ -28,7 +28,6 @@
 #include <tvm/ffi/container/array.h>
 #include <tvm/ffi/function.h>
 #include <tvm/runtime/device_api.h>
-#include <tvm/runtime/int_tuple.h>
 #include <tvm/runtime/logging.h>
 
 #include <memory>
diff --git a/src/runtime/vm/attn_utils.h b/src/runtime/vm/attn_utils.h
index afb962e4fc..c883705c82 100644
--- a/src/runtime/vm/attn_utils.h
+++ b/src/runtime/vm/attn_utils.h
@@ -24,6 +24,7 @@
 #ifndef TVM_RUNTIME_VM_ATTN_UTILS_H_
 #define TVM_RUNTIME_VM_ATTN_UTILS_H_
 
+#include <tvm/ffi/container/shape.h>
 #include <tvm/runtime/tensor.h>
 
 #include <algorithm>
@@ -286,7 +287,7 @@ GetBlockIdsOnDepth(const std::vector<Sequence*>& sequences,
  * input blocks.
  */
 inline std::pair<std::vector<std::pair<int32_t, int32_t>>, bool> 
GetChunkedBlockIds(
-    const std::vector<int32_t>& block_ids, bool enable_coalesce, const 
IntTuple& append_lengths,
+    const std::vector<int32_t>& block_ids, bool enable_coalesce, const 
ffi::Shape& append_lengths,
     const std::vector<Block>& global_block_pool, bool is_decode_request) {
   std::vector<std::pair<int32_t, int32_t>> uncoalesced_block_ids;
   std::vector<std::pair<int32_t, int32_t>> coalesced_block_ids;
@@ -389,13 +390,13 @@ class HostMemoryVector {
   /*! \brief Return the vector as an Tensor. */
   Tensor as_tensor() { return data_.CreateView({current_size_}, data_->dtype); 
}
 
-  IntTuple as_int_tuple() const {
+  ffi::Shape as_int_tuple() const {
     std::vector<int64_t> values;
     values.reserve(current_size_);
     for (int i = 0; i < current_size_; ++i) {
       values.push_back(static_cast<int32_t*>(data_->data)[i]);
     }
-    return IntTuple(values);
+    return ffi::Shape(values);
   }
 
  private:
diff --git a/src/runtime/vm/kv_state.h b/src/runtime/vm/kv_state.h
index 33c669f18a..70a1fb8893 100644
--- a/src/runtime/vm/kv_state.h
+++ b/src/runtime/vm/kv_state.h
@@ -19,9 +19,10 @@
 #ifndef TVM_RUNTIME_VM_KV_STATE_H_
 #define TVM_RUNTIME_VM_KV_STATE_H_
 #include <tvm/ffi/container/array.h>
+#include <tvm/ffi/container/shape.h>
 #include <tvm/ffi/function.h>
+#include <tvm/ffi/optional.h>
 #include <tvm/runtime/device_api.h>
-#include <tvm/runtime/int_tuple.h>
 #include <tvm/runtime/logging.h>
 #include <tvm/runtime/object.h>
 #include <tvm/runtime/tensor.h>
@@ -95,8 +96,8 @@ class KVStateObj : public Object {
    * is a chain.
    */
   virtual void BeginForward(
-      const IntTuple& seq_ids, const IntTuple& append_lengths,
-      const ffi::Optional<IntTuple>& token_tree_parent_ptr = std::nullopt) = 0;
+      const ffi::Shape& seq_ids, const ffi::Shape& append_lengths,
+      const ffi::Optional<ffi::Shape>& token_tree_parent_ptr = std::nullopt) = 
0;
 
   /*!
    * \brief Mark the start of the forward function.
@@ -155,15 +156,15 @@ class AttentionKVCacheObj : public KVStateObj {
    * \param seq_ids The ids of the sequences to commit.
    * \param leaf_indices The leaf token tree node index of each sequence.
    */
-  virtual void CommitAcceptedTokenTreeNodes(const IntTuple& seq_ids,
-                                            const IntTuple& leaf_indices) = 0;
+  virtual void CommitAcceptedTokenTreeNodes(const ffi::Shape& seq_ids,
+                                            const ffi::Shape& leaf_indices) = 
0;
 
   /*! \brief Prepare for the disaggregation KV data receive for the specified 
sequence and length.*/
-  virtual IntTuple DisaggPrepareRecv(int64_t seq_id, int length) = 0;
+  virtual ffi::Shape DisaggPrepareRecv(int64_t seq_id, int length) = 0;
 
   /*! \brief Mark which tokens' KV cache needs to be sent to other devices */
   virtual void DisaggMarkSend(int64_t seq_id, int64_t begin,
-                              const IntTuple& compressed_remote_position_map,
+                              const ffi::Shape& compressed_remote_position_map,
                               int32_t recver_pe_offset) = 0;
 
   /************** Attention **************/

Reply via email to