Skip to content

Commit c86f8fa

Browse files
committed
Merge commit '4bef5f5ff97c0b02b9125caf3e68008573c25dd7'
2 parents 3b155fa + 4bef5f5 commit c86f8fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

torch/lib/TH/THStorage.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ int THLongStorage_inferExpandGeometry(long *tensorSizes, long *tensorStrides, lo
132132
long stride = (dim >= 0) ?
133133
tensorStrides[dim] : expandedSizesCalc[i + 1] * expandedStridesCalc[i+1];
134134
long targetSize = THLongStorage_data(sizes)[i];
135+
if (targetSize == -1) {
136+
if (dim < 0) {
137+
THFree(expandedSizesCalc);
138+
THFree(expandedStridesCalc);
139+
snprintf(error_buffer, buffer_len, "The expanded size of the tensor (%ld) isn't allowed in a leading, non-existing dimension %ld.", targetSize, i);
140+
return -1;
141+
} else {
142+
targetSize = size;
143+
}
144+
}
135145
if (size != targetSize) {
136146
if (size == 1) {
137147
size = targetSize;

0 commit comments

Comments
 (0)