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

tqchen pushed a commit to branch refactor-s2
in repository https://gitbox.apache.org/repos/asf/tvm.git

commit 0d09979104432aaaa041cdd11ed9eeb356063c7d
Author: tqchen <[email protected]>
AuthorDate: Thu Apr 24 08:58:52 2025 -0400

    Upgrade GetDataSize
---
 src/runtime/memory/memory_manager.cc    | 8 ++++----
 src/runtime/ndarray.cc                  | 2 +-
 src/runtime/opencl/opencl_device_api.cc | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/runtime/memory/memory_manager.cc 
b/src/runtime/memory/memory_manager.cc
index 60fd5db5b1..bc09f464ab 100644
--- a/src/runtime/memory/memory_manager.cc
+++ b/src/runtime/memory/memory_manager.cc
@@ -81,7 +81,7 @@ NDArray StorageObj::AllocNDArrayScoped(int64_t offset, 
ShapeTuple shape, DLDataT
     Storage storage_;
   };
 
-  size_t needed_size = ffi::GetPackedDataSize(shape.Product(), dtype);
+  size_t needed_size = ffi::GetDataSize(shape.Product(), dtype);
   ICHECK(offset + needed_size <= this->buffer.size)
       << "storage allocation failure, attempted to allocate " << needed_size 
<< " at offset "
       << offset << " in region that is " << this->buffer.size << "bytes";
@@ -93,7 +93,7 @@ NDArray StorageObj::AllocNDArrayScoped(int64_t offset, 
ShapeTuple shape, DLDataT
 NDArray StorageObj::AllocNDArray(int64_t offset, ShapeTuple shape, DLDataType 
dtype) {
   VerifyDataType(dtype);
 
-  size_t needed_size = ffi::GetPackedDataSize(shape.Product(), dtype);
+  size_t needed_size = ffi::GetDataSize(shape.Product(), dtype);
   ICHECK(offset + needed_size <= this->buffer.size)
       << "storage allocation failure, attempted to allocate " << needed_size 
<< " at offset "
       << offset << " in region that is " << this->buffer.size << "bytes";
@@ -230,7 +230,7 @@ NDArray Allocator::Empty(ShapeTuple shape, DLDataType 
dtype, DLDevice dev,
   };
 
   size_t alignment = GetDataAlignment(dtype);
-  size_t size = ffi::GetPackedDataSize(shape.Product(), dtype);
+  size_t size = ffi::GetDataSize(shape.Product(), dtype);
 
   Buffer buffer;
   if (!mem_scope.defined() || mem_scope.value().empty() || mem_scope.value() 
== "global") {
@@ -250,7 +250,7 @@ Buffer Allocator::Alloc(Device dev, ShapeTuple shape, 
DLDataType type_hint,
   if (AllowMemoryScope(mem_scope)) {
     // by default, we can always redirect to the flat memory allocations
     size_t alignment = GetDataAlignment(type_hint);
-    size_t size = ffi::GetPackedDataSize(shape.Product(), type_hint);
+    size_t size = ffi::GetDataSize(shape.Product(), type_hint);
     return Alloc(dev, size, alignment, type_hint);
   }
   LOG(FATAL) << "Allocator cannot allocate data space with "
diff --git a/src/runtime/ndarray.cc b/src/runtime/ndarray.cc
index 379437b103..b1fdca15ed 100644
--- a/src/runtime/ndarray.cc
+++ b/src/runtime/ndarray.cc
@@ -144,7 +144,7 @@ NDArray NDArray::CreateView(ShapeTuple shape, DLDataType 
dtype,
   }();
   const auto& curr_dl_tensor = *get_mutable();
   size_t curr_size = GetDataSize(curr_dl_tensor);
-  size_t view_size = ffi::GetPackedDataSize(shape.Product(), dtype);
+  size_t view_size = ffi::GetDataSize(shape.Product(), dtype);
   CHECK_LE(relative_byte_offset + view_size, curr_size)
       << "ValueError: "
       << "View with shape " << shape << " and datatype " << dtype << " would 
have a size of "
diff --git a/src/runtime/opencl/opencl_device_api.cc 
b/src/runtime/opencl/opencl_device_api.cc
index 28cc5afd11..2e5aff9413 100644
--- a/src/runtime/opencl/opencl_device_api.cc
+++ b/src/runtime/opencl/opencl_device_api.cc
@@ -852,7 +852,7 @@ class OpenCLPooledAllocator final : public 
memory::PooledAllocator {
   Buffer Alloc(Device dev, ShapeTuple shape, DLDataType type_hint,
                const std::string& mem_scope) override {
     if (AllowMemoryScope(mem_scope)) {
-      size_t size = ffi::GetPackedDataSize(shape.Product(), type_hint);
+      size_t size = ffi::GetDataSize(shape.Product(), type_hint);
       Buffer buf;
       buf.device = dev;
       buf.size = size;

Reply via email to