You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/01/16 06:18:08 UTC

[GitHub] stephenrawls commented on issue #13880: MXNET-1295 Adding integer index support to Sequence* family of operators.

stephenrawls commented on issue #13880: MXNET-1295 Adding integer index support to Sequence* family of operators.
URL: https://github.com/apache/incubator-mxnet/pull/13880#issuecomment-454665451
 
 
   @szha Okay I added unit tests. As I alluded to in my original PR, it wasn't exactly clear the best way to do this, because the testing code seems to have a lot of assumptions that all argument types will be the same type, and that the only possible argument types are floats.
   
   For example, there are `assert dtype in (np.float16, np.float32, np.float64)` sprinkled all throughout the unit test framework, and I don't know what other assumptions I'll break if I change any of that.
   
   Also, the unit tests are relying on test_utils.py to convert all input arrays to a single input type, e.g. here is an example:
   
   ```
       location = {k: mx.nd.array(v, ctx=ctx, dtype=dtype) if isinstance(v, np.ndarray) \
                  else v for k, v in location.items()}
   ```
   
   I ended up modifying the logic so that I could control the dtype of each array independently by just creating the original numpy array to be the data type that I want, and telling the code to keep the numpy dtype when converting to mxnet.ndarray:
   
   ```
       location = {k: mx.nd.array(v, ctx=ctx, dtype=v.dtype if dtype == "asnumpy" else dtype) if isinstance(v, np.ndarray) \
                  else v for k, v in location.items()}
   ```
   
   If you want to use the new behavior, you have to opt-in and pass "asnumpy" as the dtype.
   
   Take a look, and if you prefer a different approach just let me know.
   
   Best,
   Stephen
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services