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

fix potential floating number overflow, enable float16 #12118

Merged
merged 14 commits into from
Aug 20, 2018

Conversation

zhreshold
Copy link
Member

@zhreshold zhreshold commented Aug 10, 2018

Description

contrib.box_nms and contrib.bipartite_matchin use floating number array to store indices which can be extremely large.
To avoid overflow when float32/float16 is casted to integer, this PR force use int32_t in indices arrays. (the new limit is 2^31 - 1 instead of 2^k + 1 where k is the mantissa bits of float type)

  • Test updated for various dtypes
  • no functionality change
  • no API change

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

@zhreshold
Copy link
Member Author

@ijkguo

@larroy
Copy link
Contributor

larroy commented Aug 11, 2018

Why don't you use size_t instead of int32_t?

@zhreshold
Copy link
Member Author

@larroy Negative number required to mark some indices for special purposes.

@larroy
Copy link
Contributor

larroy commented Aug 11, 2018

ssize_t then? It’s not portable otherwise

@larroy
Copy link
Contributor

larroy commented Aug 14, 2018

@zhreshold did you see my previous comment? Thanks.

@zhreshold
Copy link
Member Author

@larroy Sorry I missed that. But I don't quite get your point. Isn't int32_t portable enough through stdint standard? ssize_t is more problematic in terms of portability because it is not ensured to be at least 4 bytes

@larroy
Copy link
Contributor

larroy commented Aug 14, 2018

http://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html
Ok, seems negative range is not well specified.

@zhreshold
Copy link
Member Author

CI always fails at deploy stage. Do you have a clue? @larroy

@larroy
Copy link
Contributor

larroy commented Aug 15, 2018

minor problem with doc generation. Are you rebased against master?

@zhreshold
Copy link
Member Author

@larroy Yep, just rebased 2 hours ago

@larroy
Copy link
Contributor

larroy commented Aug 15, 2018

It's broken in master #11990

@piiswrong piiswrong merged commit c479eb2 into apache:master Aug 20, 2018
@zhreshold zhreshold deleted the box-nms-fix branch August 20, 2018 21:12
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
* fix potential floating number overflow, enable float16

* fix cuda impl

* fix cuda imple

* fix template substitution for windows

* half_f substantiate operand + fix

* remove ambiguous operand + for mshadow half_T

* fix con't

* use int32_t as indices

* use overload

* try remove ambiguous function overloading

* thrust version limit

* change sizeof cast from floor to ceil  when allocating buffers

* cleaner

* fix alignment of pointers
anirudh2290 pushed a commit to anirudh2290/mxnet that referenced this pull request Sep 19, 2018
* fix potential floating number overflow, enable float16

* fix cuda impl

* fix cuda imple

* fix template substitution for windows

* half_f substantiate operand + fix

* remove ambiguous operand + for mshadow half_T

* fix con't

* use int32_t as indices

* use overload

* try remove ambiguous function overloading

* thrust version limit

* change sizeof cast from floor to ceil  when allocating buffers

* cleaner

* fix alignment of pointers
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants