Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrluo <rluo@ttic.edu>2017-08-23 22:31:18 +0300
committerSoumith Chintala <soumith@gmail.com>2017-08-25 21:01:53 +0300
commita4cc7a3492621aeb0579a3b4358b41e4b613a973 (patch)
tree1eba58ac72f4e874d43df94b54c55175b3c05228
parenta0bf77ff070ca27eb2de31c6465f8ffa4e399be2 (diff)
Not changing dimension size for expand when target size is -1
-rw-r--r--lib/TH/THStorage.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/TH/THStorage.c b/lib/TH/THStorage.c
index f6b63f4..e57181c 100644
--- a/lib/TH/THStorage.c
+++ b/lib/TH/THStorage.c
@@ -132,6 +132,16 @@ int THLongStorage_inferExpandGeometry(long *tensorSizes, long *tensorStrides, lo
long stride = (dim >= 0) ?
tensorStrides[dim] : expandedSizesCalc[i + 1] * expandedStridesCalc[i+1];
long targetSize = THLongStorage_data(sizes)[i];
+ if (targetSize == -1) {
+ if (dim < 0) {
+ THFree(expandedSizesCalc);
+ THFree(expandedStridesCalc);
+ snprintf(error_buffer, buffer_len, "The expanded size of the tensor (%ld) isn't allowed in a leading, non-existing dimension %ld.", targetSize, i);
+ return -1;
+ } else {
+ targetSize = size;
+ }
+ }
if (size != targetSize) {
if (size == 1) {
size = targetSize;