This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/master by this push:
new 718a9a7 Remove comparison of unsigned expression < 0 warning (#6319)
718a9a7 is described below
commit 718a9a732417f59cdabef1e2100ea059b6d047b4
Author: wrongtest <[email protected]>
AuthorDate: Tue Sep 8 23:05:25 2020 +0800
Remove comparison of unsigned expression < 0 warning (#6319)
* fix: remove warning for if (unsigned < 0...)
* change used types related to dlpack ndim to int32_t
---
src/runtime/crt/common/ndarray.c | 14 +++++++-------
.../crt/include/tvm/runtime/crt/internal/common/ndarray.h | 6 +++---
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/runtime/crt/common/ndarray.c b/src/runtime/crt/common/ndarray.c
index f16db69..4bae6de 100644
--- a/src/runtime/crt/common/ndarray.c
+++ b/src/runtime/crt/common/ndarray.c
@@ -29,7 +29,7 @@
#include "crt_config.h"
-TVMNDArray TVMNDArray_Create(uint32_t ndim, const tvm_index_t* shape,
DLDataType dtype,
+TVMNDArray TVMNDArray_Create(int32_t ndim, const tvm_index_t* shape,
DLDataType dtype,
DLContext ctx) {
TVMNDArray ret;
memset(&ret, 0, sizeof(TVMNDArray));
@@ -42,12 +42,12 @@ TVMNDArray TVMNDArray_Create(uint32_t ndim, const
tvm_index_t* shape, DLDataType
return ret;
}
-TVMNDArray TVMNDArray_Empty(uint32_t ndim, const tvm_index_t* shape,
DLDataType dtype,
+TVMNDArray TVMNDArray_Empty(int32_t ndim, const tvm_index_t* shape, DLDataType
dtype,
DLContext ctx) {
TVMNDArray ret = TVMNDArray_Create(ndim, shape, dtype, ctx);
int64_t num_elems = 1;
int elem_bytes = (dtype.bits + 7) / 8;
- uint32_t idx;
+ int32_t idx;
for (idx = 0; idx < ret.dl_tensor.ndim; ++idx) {
num_elems *= shape[idx];
}
@@ -68,11 +68,11 @@ int TVMNDArray_Load(TVMNDArray* ret, const char** strm) {
reserved = ((uint64_t*)*strm)[0]; // NOLINT(*)
*strm += sizeof(reserved);
DLContext ctx;
- uint32_t ndim;
+ int ndim; // sizeof ndim should match dlpack
DLDataType dtype;
ctx = ((DLContext*)*strm)[0]; // NOLINT(*)
*strm += sizeof(ctx);
- ndim = ((uint32_t*)*strm)[0]; // NOLINT(*)
+ ndim = ((int*)*strm)[0]; // NOLINT(*)
*strm += sizeof(ndim);
dtype = ((DLDataType*)*strm)[0]; // NOLINT(*)
*strm += sizeof(dtype);
@@ -85,7 +85,7 @@ int TVMNDArray_Load(TVMNDArray* ret, const char** strm) {
status = -1;
}
int64_t shape[TVM_CRT_MAX_NDIM] = {0};
- uint32_t idx;
+ int32_t idx;
if (ndim != 0) {
for (idx = 0; idx < ndim; idx++) {
shape[idx] = ((int64_t*)*strm)[0]; // NOLINT(*)
@@ -114,7 +114,7 @@ int TVMNDArray_Load(TVMNDArray* ret, const char** strm) {
return status;
}
-TVMNDArray TVMNDArray_CreateView(TVMNDArray* arr, const tvm_index_t* shape,
uint32_t ndim,
+TVMNDArray TVMNDArray_CreateView(TVMNDArray* arr, const tvm_index_t* shape,
int32_t ndim,
DLDataType dtype) {
TVMNDArray ret = TVMNDArray_Create(ndim, shape, dtype, arr->dl_tensor.ctx);
ret.dl_tensor.data = arr->dl_tensor.data;
diff --git a/src/runtime/crt/include/tvm/runtime/crt/internal/common/ndarray.h
b/src/runtime/crt/include/tvm/runtime/crt/internal/common/ndarray.h
index 8da4b3c..46f65bd 100644
--- a/src/runtime/crt/include/tvm/runtime/crt/internal/common/ndarray.h
+++ b/src/runtime/crt/include/tvm/runtime/crt/internal/common/ndarray.h
@@ -41,15 +41,15 @@ typedef struct TVMNDArray {
DLTensor dl_tensor;
} TVMNDArray;
-TVMNDArray TVMNDArray_Create(uint32_t ndim, const tvm_index_t* shape,
DLDataType dtype,
+TVMNDArray TVMNDArray_Create(int32_t ndim, const tvm_index_t* shape,
DLDataType dtype,
DLContext ctx);
-TVMNDArray TVMNDArray_Empty(uint32_t ndim, const tvm_index_t* shape,
DLDataType dtype,
+TVMNDArray TVMNDArray_Empty(int32_t ndim, const tvm_index_t* shape, DLDataType
dtype,
DLContext ctx);
int TVMNDArray_Load(TVMNDArray* ret, const char** strm);
-TVMNDArray TVMNDArray_CreateView(TVMNDArray* arr, const tvm_index_t* shape,
uint32_t ndim,
+TVMNDArray TVMNDArray_CreateView(TVMNDArray* arr, const tvm_index_t* shape,
int32_t ndim,
DLDataType dtype);
int TVMNDArray_Release(TVMNDArray* arr);