Enforce non-negativity of tensor construction (#17077)
authorDmytro Dzhulgakov <dzhulgakov@fb.com>
Thu, 21 Feb 2019 17:22:12 +0000 (09:22 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 21 Feb 2019 17:28:53 +0000 (09:28 -0800)
commit5744d5213d0bcd56b9029a4abaa5148a33ed66b3
tree563b3a8f64c40198d12da4fc4c0914f5faeb79fc
parent94a95a0c7f3c38530a9cbc79932ea89ce092d1c2
Enforce non-negativity of tensor construction (#17077)

Summary:
Apparently, before the only way we enforced it was size>=0 in alloc_cpu. So empty((5,-5)) would fail but empty((-5,-5)) would hang :)

Please suggest better place to enforce it if any.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17077

Differential Revision: D14077930

Pulled By: dzhulgakov

fbshipit-source-id: 1120513300fd5448e06fa15c2d72f9b0ee5734e4
aten/src/ATen/native/TensorFactories.cpp
aten/src/ATen/native/TensorFactories.h
aten/src/ATen/native/cuda/TensorFactories.cu
aten/src/ATen/test/basic.cpp