Skip to content

Fix UB when converting negative floating values to uint8_t#7644

Merged
apaszke merged 2 commits intomasterfrom
fix_uint8_ub
May 18, 2018
Merged

Fix UB when converting negative floating values to uint8_t#7644
apaszke merged 2 commits intomasterfrom
fix_uint8_ub

Conversation

@apaszke
Copy link
Contributor

@apaszke apaszke commented May 17, 2018

See the comment in the code for a detailed description.

cc: @goldsborough @ezyang

See the comment in the code for a detailed description.
@yf225
Copy link
Contributor

yf225 commented May 17, 2018

@pytorchbot retest this please

TH_TENSOR_APPLY2(real, tensor, TYPE_SRC, src, \
*tensor_data = static_cast<real>( \
static_cast<inter_copy_type_t<real>>( \
TH_half2float(*src_data)));) \

This comment was marked as off-topic.

This comment was marked as off-topic.

@ezyang
Copy link
Contributor

ezyang commented May 17, 2018

The macro ifdef to prevent defining the template is a little goofy but we will live.

@apaszke
Copy link
Contributor Author

apaszke commented May 18, 2018

@ezyang I could put the code in THTensor.c instead of the generic file, but I wanted to keep it close to the actual use.

@apaszke apaszke merged commit 06fa332 into master May 18, 2018
@apaszke apaszke deleted the fix_uint8_ub branch May 18, 2018 09:02
onnxbot added a commit to onnxbot/onnx-fb-universe that referenced this pull request May 18, 2018
petrex pushed a commit to petrex/pytorch that referenced this pull request May 23, 2018
…e2_core_hip

* 'caffe2_core_hip' of github.com:petrex/pytorch:
  Refactor cmake files to not add hip includes and libs globally
  Fix UB when converting negative floating values to uint8_t (pytorch#7644)
  [auto] Update onnx to 3fc5f43 - move finalize function to be public. (onnx/onnx#987) onnx/onnx@3fc5f43
  Fix duplicated thread pool flag
  [caffe2] Fix warning in net_async_tracing.cc (pytorch#7646)
  [auto] Update onnx to 8d548e2 - Update shape inference methods to throw exception (onnx/onnx#986) onnx/onnx@8d548e2
  Fix flaky atomic iter test (pytorch#7649)
  Fix onnx Pow export (pytorch#7657)
  [auto] Update onnx to 8356ad5 - Add unit test framework for the project C++ APIs (onnx/onnx#763) onnx/onnx@8356ad5
  [caffe2][nomnigraph] Add registry for optimization passes (pytorch#7656)
  [auto] Update onnx to 94ca052 - Update mypy version (onnx/onnx#968) onnx/onnx@94ca052
  fix nccl distributed documentation
weiyangfb pushed a commit to weiyangfb/pytorch that referenced this pull request Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants