Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

size_array operator returns wrong results on MacOS #13098

Closed
anirudhacharya opened this issue Nov 2, 2018 · 4 comments
Closed

size_array operator returns wrong results on MacOS #13098

anirudhacharya opened this issue Nov 2, 2018 · 4 comments

Comments

@anirudhacharya
Copy link
Member

Description

size_array operator returns incorrect results on MacOS but works correctly on Linux systems

Package used (Python/R/Scala/Julia):
I'm using Python

Compiler (gcc/clang/mingw/visual studio):
clang

MXNet commit hash:
50f43f0

Build config:
make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas

Minimum reproducible example

import mxnet as mx
a = mx.nd.array([1,2,3,4,5])
print(mx.nd.size_array(a))

Steps to reproduce

  1. Run the above script in MacOS, the function will return a junk memory location.
  2. Run it on Linux and it will work fine.

What have you tried to solve it?

  1. Use the operator on a linux system.
@anirudhacharya
Copy link
Member Author

@mxnet-label-bot [Operator, Bug]

@wkcn
Copy link
Member

wkcn commented Nov 3, 2018

In src/operator/tensor/elemwise_unary_op_basic.cc#L546,

  const index_t size_var = in_data.Size();
  memcpy(out_data.dptr_, &size_var, 1U * sizeof(int64_t));

In 3rdparty/dmlc-core/include/dmlc/data.h,

typedef unsigned index_t;  

It's confusing that index_t may not the same as int64_t

@apeforest
Copy link
Contributor

@mxnet-label-bot [Call for Contribution, Good First Issue]

@apeforest
Copy link
Contributor

Issue has been fixed:

>>> import mxnet as mx
a = mx.nd.array([1,2,3,4,5])
>>> a = mx.nd.array([1,2,3,4,5])
>>> print(mx.nd.size_array(a))

[5]
<NDArray 1 @cpu(0)>
>>> 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants