This is an automated email from the ASF dual-hosted git repository.
csullivan 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 3b274aa6c7 [Hexagon] Allow scalar tensors to have null shape during
allocation (#14376)
3b274aa6c7 is described below
commit 3b274aa6c776c513552d0a5872911a1f163f0869
Author: Janet Schneider <[email protected]>
AuthorDate: Thu Mar 23 13:14:29 2023 -0700
[Hexagon] Allow scalar tensors to have null shape during allocation (#14376)
* [Hexagon] Allow scalar tensors to have null shape during allocation.
* Add unit test for new case (scalar and null shape)
---
src/runtime/hexagon/hexagon_device_api.cc | 2 +-
tests/cpp-runtime/hexagon/hexagon_device_api_tests.cc | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/runtime/hexagon/hexagon_device_api.cc
b/src/runtime/hexagon/hexagon_device_api.cc
index 16e67aa965..27e4eb29cc 100644
--- a/src/runtime/hexagon/hexagon_device_api.cc
+++ b/src/runtime/hexagon/hexagon_device_api.cc
@@ -52,7 +52,7 @@ void HexagonDeviceAPI::GetAttr(Device dev, DeviceAttrKind
kind, TVMRetValue* rv)
// DataSpace: static allocations for Hexagon
void* HexagonDeviceAPI::AllocDataSpace(Device dev, int ndim, const int64_t*
shape, DLDataType dtype,
Optional<String> mem_scope) {
- CHECK(shape) << "shape array is null";
+ CHECK(shape || ndim == 0) << "shape array is null for a non-scalar tensor,
ndim = " << ndim;
CHECK(IsValidDevice(dev)) << "dev.device_type: " << dev.device_type;
// IMPORTANT NOTE!
diff --git a/tests/cpp-runtime/hexagon/hexagon_device_api_tests.cc
b/tests/cpp-runtime/hexagon/hexagon_device_api_tests.cc
index 0d193042a9..d7d306ff65 100644
--- a/tests/cpp-runtime/hexagon/hexagon_device_api_tests.cc
+++ b/tests/cpp-runtime/hexagon/hexagon_device_api_tests.cc
@@ -134,6 +134,9 @@ TEST_F(HexagonDeviceAPITest, alloc_scalar) {
void* hexscalar = hexapi->AllocDataSpace(hex_dev, 0, new int64_t, int8,
global_vtcm_scope);
CHECK(hexscalar != nullptr);
+
+ hexscalar = hexapi->AllocDataSpace(hex_dev, 0, nullptr, int8,
global_vtcm_scope);
+ CHECK(hexscalar != nullptr);
}
// alloc and free of the same buffer on different devices should throw