Skip to content

Commit

Permalink
[RUNTIME][CRT] support DLTensor whose ndim == 0 (apache#5344)
Browse files Browse the repository at this point in the history
Signed-off-by: windclarion <windclarion@gmail.com>
  • Loading branch information
windclarion authored and dhruvaray committed Apr 28, 2020
1 parent 7448081 commit b9aa07f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/runtime/crt/ndarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ int TVMNDArray_Load(TVMNDArray * ret, const char ** strm) {
ctx = ((DLContext*)*strm)[0]; *strm += sizeof(ctx); // NOLINT(*)
ndim = ((uint32_t*)*strm)[0]; *strm += sizeof(ndim); // NOLINT(*)
dtype = ((DLDataType*)*strm)[0]; *strm += sizeof(dtype); // NOLINT(*)
if ((ndim <= 0) || (ndim > TVM_CRT_MAX_NDIM)) {
fprintf(stderr, "Invalid ndim=%d: expected to be 1 ~ %d.\n", ndim, TVM_CRT_MAX_NDIM);
if ((ndim < 0) || (ndim > TVM_CRT_MAX_NDIM)) {
fprintf(stderr, "Invalid ndim=%d: expected to be 0 ~ %d.\n", ndim, TVM_CRT_MAX_NDIM);
status = -1;
}
if (ctx.device_type != kDLCPU) {
fprintf(stderr, "Invalid DLTensor context: can only save as CPU tensor\n");
status = -1;
}
int64_t shape[TVM_CRT_MAX_NDIM];
int64_t shape[TVM_CRT_MAX_NDIM] = {0};
uint32_t idx;
if (ndim != 0) {
for (idx = 0; idx < ndim; idx++) {
Expand Down

0 comments on commit b9aa07f

Please sign in to comment.