Skip to content

Commit 3b274aa

Browse files
authored
[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)
1 parent b56d7f5 commit 3b274aa

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/runtime/hexagon/hexagon_device_api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void HexagonDeviceAPI::GetAttr(Device dev, DeviceAttrKind kind, TVMRetValue* rv)
5252
// DataSpace: static allocations for Hexagon
5353
void* HexagonDeviceAPI::AllocDataSpace(Device dev, int ndim, const int64_t* shape, DLDataType dtype,
5454
Optional<String> mem_scope) {
55-
CHECK(shape) << "shape array is null";
55+
CHECK(shape || ndim == 0) << "shape array is null for a non-scalar tensor, ndim = " << ndim;
5656
CHECK(IsValidDevice(dev)) << "dev.device_type: " << dev.device_type;
5757

5858
// IMPORTANT NOTE!

tests/cpp-runtime/hexagon/hexagon_device_api_tests.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ TEST_F(HexagonDeviceAPITest, alloc_scalar) {
134134

135135
void* hexscalar = hexapi->AllocDataSpace(hex_dev, 0, new int64_t, int8, global_vtcm_scope);
136136
CHECK(hexscalar != nullptr);
137+
138+
hexscalar = hexapi->AllocDataSpace(hex_dev, 0, nullptr, int8, global_vtcm_scope);
139+
CHECK(hexscalar != nullptr);
137140
}
138141

139142
// alloc and free of the same buffer on different devices should throw

0 commit comments

Comments
 (0)