Skip to content

Commit 1e3e26e

Browse files
gchananfacebook-github-bot
authored andcommitted
Use nDimensionLegacyNoScalars in THTensorDimApply. (pytorch#10388)
Summary: This issue was exposed in pytorch#10383. Pull Request resolved: pytorch#10388 Differential Revision: D9255836 Pulled By: gchanan fbshipit-source-id: 88c5a6415c27d56ff54d00a8957fdc1617cfbde7
1 parent 3667d02 commit 1e3e26e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

aten/src/TH/THTensorDimApply.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define TH_TENSOR_DIM_APPLY3_SIZE_EQ_EXCEPT_DIM(TENSOR1, TENSOR2, TENSOR3, DIMENSION) \
1010
{ \
1111
int shape_check_flag = 0; \
12-
for(TH_TENSOR_DIM_APPLY_i = 0; TH_TENSOR_DIM_APPLY_i < TENSOR1->dim(); TH_TENSOR_DIM_APPLY_i++) \
12+
for(TH_TENSOR_DIM_APPLY_i = 0; TH_TENSOR_DIM_APPLY_i < THTensor_nDimensionLegacyNoScalars(TENSOR1); TH_TENSOR_DIM_APPLY_i++) \
1313
{ \
1414
if (TH_TENSOR_DIM_APPLY_i == DIMENSION) \
1515
continue; \
@@ -42,10 +42,10 @@
4242
if( (DIMENSION < 0) || (DIMENSION >= THTensor_nDimensionLegacyNoScalars(TENSOR1)) ) \
4343
THError("invalid dimension %d (expected to be 0 <= dim < %d)", DIMENSION, THTensor_nDimensionLegacyNoScalars(TENSOR1)); \
4444
int same_dims = 1; \
45-
if( TENSOR1->dim() != TENSOR2->dim() ) { \
45+
if( THTensor_nDimensionLegacyNoScalars(TENSOR1) != THTensor_nDimensionLegacyNoScalars(TENSOR2) ) { \
4646
same_dims = 0; \
4747
} \
48-
if( TENSOR1->dim() != TENSOR3->dim() ) { \
48+
if( THTensor_nDimensionLegacyNoScalars(TENSOR1) != THTensor_nDimensionLegacyNoScalars(TENSOR3) ) { \
4949
same_dims = 0; \
5050
} \
5151
if (same_dims == 0) { \
@@ -147,7 +147,7 @@
147147
\
148148
if( (DIMENSION < 0) || (DIMENSION >= THTensor_nDimensionLegacyNoScalars(TENSOR1)) ) \
149149
THError("invalid dimension %d (expected to be 0 <= dim < %d)", DIMENSION, THTensor_nDimensionLegacyAll(TENSOR1)); \
150-
if( TENSOR1->dim() != TENSOR2->dim() ) { \
150+
if( THTensor_nDimensionLegacyNoScalars(TENSOR1) != THTensor_nDimensionLegacyNoScalars(TENSOR2)) { \
151151
AT_ERROR("inconsistent tensor size, expected ", #TENSOR1, " ", TENSOR1->sizes(), " and ", #TENSOR2, " ", TENSOR2->sizes(), " to have the same number of dimensions"); \
152152
} \
153153
TH_UNUSED int shape_check_flag = 0; \
@@ -182,7 +182,7 @@
182182
if(THTensor_nDimensionLegacyNoScalars(TENSOR1) == 1) \
183183
break; \
184184
\
185-
for(TH_TENSOR_DIM_APPLY_i = 0; TH_TENSOR_DIM_APPLY_i < TENSOR1->dim(); TH_TENSOR_DIM_APPLY_i++) \
185+
for(TH_TENSOR_DIM_APPLY_i = 0; TH_TENSOR_DIM_APPLY_i < THTensor_nDimensionLegacyNoScalars(TENSOR1); TH_TENSOR_DIM_APPLY_i++) \
186186
{ \
187187
if(TH_TENSOR_DIM_APPLY_i == DIMENSION) \
188188
{ \

0 commit comments

Comments
 (0)