Skip to content

Commit eb4a7dc

Browse files
Jokerensoumith
authored andcommitted
THTensorApply change dims to sizes
1 parent f722498 commit eb4a7dc

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

THTensorApply.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@
209209
#define TH_TENSOR_APPLY2(TYPE1, TENSOR1, TYPE2, TENSOR2, CODE) \
210210
{ \
211211
TYPE1 *TENSOR1##_data = NULL; \
212-
long *TENSOR1##_counter = NULL, *TENSOR1##_dims = NULL, *TENSOR1##_strides = NULL; \
212+
long *TENSOR1##_counter = NULL, *TENSOR1##_sizes = NULL, *TENSOR1##_strides = NULL; \
213213
long TENSOR1##_stride = 0, TENSOR1##_size = 0, TENSOR1##_dim = 0, TENSOR1##_i, TENSOR1##_n; \
214214
TYPE2 *TENSOR2##_data = NULL; \
215-
long *TENSOR2##_counter = NULL, *TENSOR2##_dims = NULL, *TENSOR2##_strides = NULL; \
215+
long *TENSOR2##_counter = NULL, *TENSOR2##_sizes = NULL, *TENSOR2##_strides = NULL; \
216216
long TENSOR2##_stride = 0, TENSOR2##_size = 0, TENSOR2##_dim = 0, TENSOR2##_i, TENSOR2##_n; \
217217
int TH_TENSOR_APPLY_hasFinished = 0; \
218218
long TH_TENSOR_dim_index = 0; \
@@ -240,25 +240,25 @@
240240
TENSOR1##_dim++; \
241241
} \
242242
TENSOR1##_counter = (long*)THAlloc(sizeof(long)*(3*TENSOR1##_dim)); \
243-
TENSOR1##_dims = TENSOR1##_counter + TENSOR1##_dim; \
243+
TENSOR1##_sizes = TENSOR1##_counter + TENSOR1##_dim; \
244244
TENSOR1##_strides = TENSOR1##_counter + 2*TENSOR1##_dim; \
245245
TH_TENSOR_dim_index = TENSOR1##_dim-1; \
246-
TENSOR1##_dims[TH_TENSOR_dim_index] = TENSOR1->size[TENSOR1->nDimension-1]; \
246+
TENSOR1##_sizes[TH_TENSOR_dim_index] = TENSOR1->size[TENSOR1->nDimension-1]; \
247247
TENSOR1##_strides[TH_TENSOR_dim_index] = TENSOR1->stride[TENSOR1->nDimension-1]; \
248248
for(TENSOR1##_i = TENSOR1##_dim-1; TENSOR1##_i >= 0; --TENSOR1##_i) { \
249249
TENSOR1##_counter[TENSOR1##_i] = 0; \
250250
} \
251251
for(TENSOR1##_i = TENSOR1->nDimension-2; TENSOR1##_i >= 0; --TENSOR1##_i) { \
252252
if (TENSOR1->stride[TENSOR1##_i] == TENSOR1->stride[TENSOR1##_i+1] * TENSOR1->size[TENSOR1##_i+1]) { \
253-
TENSOR1##_dims[TH_TENSOR_dim_index] = TENSOR1->size[TENSOR1##_i] * TENSOR1##_dims[TH_TENSOR_dim_index]; \
253+
TENSOR1##_sizes[TH_TENSOR_dim_index] = TENSOR1->size[TENSOR1##_i] * TENSOR1##_sizes[TH_TENSOR_dim_index]; \
254254
} else { \
255255
--TH_TENSOR_dim_index; \
256-
TENSOR1##_dims[TH_TENSOR_dim_index] = TENSOR1->size[TENSOR1##_i]; \
256+
TENSOR1##_sizes[TH_TENSOR_dim_index] = TENSOR1->size[TENSOR1##_i]; \
257257
TENSOR1##_strides[TH_TENSOR_dim_index] = TENSOR1->stride[TENSOR1##_i]; \
258258
} \
259259
} \
260260
/* it will be used for offset updates while looping through the largest contiguous section */ \
261-
TENSOR1##_size = TENSOR1##_dims[TENSOR1##_dim-1]; \
261+
TENSOR1##_size = TENSOR1##_sizes[TENSOR1##_dim-1]; \
262262
/* what is the largest contiguous section? size will store the size of this section */ \
263263
TENSOR1##_stride = TENSOR1##_strides[TENSOR1##_dim-1]; \
264264
\
@@ -270,25 +270,25 @@
270270
TENSOR2##_dim++; \
271271
} \
272272
TENSOR2##_counter = (long*)THAlloc(sizeof(long)*(3*TENSOR2##_dim)); \
273-
TENSOR2##_dims = TENSOR2##_counter + TENSOR2##_dim; \
273+
TENSOR2##_sizes = TENSOR2##_counter + TENSOR2##_dim; \
274274
TENSOR2##_strides = TENSOR2##_counter + 2*TENSOR2##_dim; \
275275
TH_TENSOR_dim_index = TENSOR2##_dim-1; \
276-
TENSOR2##_dims[TH_TENSOR_dim_index] = TENSOR2->size[TENSOR2->nDimension-1]; \
276+
TENSOR2##_sizes[TH_TENSOR_dim_index] = TENSOR2->size[TENSOR2->nDimension-1]; \
277277
TENSOR2##_strides[TH_TENSOR_dim_index] = TENSOR2->stride[TENSOR2->nDimension-1]; \
278278
for(TENSOR2##_i = TENSOR2##_dim-1; TENSOR2##_i >= 0; --TENSOR2##_i) { \
279279
TENSOR2##_counter[TENSOR2##_i] = 0; \
280280
} \
281281
for(TENSOR2##_i = TENSOR2->nDimension-2; TENSOR2##_i >= 0; --TENSOR2##_i) { \
282282
if (TENSOR2->stride[TENSOR2##_i] == TENSOR2->stride[TENSOR2##_i+1] * TENSOR2->size[TENSOR2##_i+1]) { \
283-
TENSOR2##_dims[TH_TENSOR_dim_index] = TENSOR2->size[TENSOR2##_i] * TENSOR2##_dims[TH_TENSOR_dim_index]; \
283+
TENSOR2##_sizes[TH_TENSOR_dim_index] = TENSOR2->size[TENSOR2##_i] * TENSOR2##_sizes[TH_TENSOR_dim_index]; \
284284
} else { \
285285
--TH_TENSOR_dim_index; \
286-
TENSOR2##_dims[TH_TENSOR_dim_index] = TENSOR2->size[TENSOR2##_i]; \
286+
TENSOR2##_sizes[TH_TENSOR_dim_index] = TENSOR2->size[TENSOR2##_i]; \
287287
TENSOR2##_strides[TH_TENSOR_dim_index] = TENSOR2->stride[TENSOR2##_i]; \
288288
} \
289289
} \
290290
/* it will be used for offset updates while looping through the largest contiguous section */ \
291-
TENSOR2##_size = TENSOR2##_dims[TENSOR2##_dim-1]; \
291+
TENSOR2##_size = TENSOR2##_sizes[TENSOR2##_dim-1]; \
292292
/* what is the largest contiguous section? size will store the size of this section */ \
293293
TENSOR2##_stride = TENSOR2##_strides[TENSOR2##_dim-1]; \
294294
} \
@@ -313,7 +313,7 @@
313313
TENSOR1##_counter[TENSOR1##_i]++; \
314314
TENSOR1##_data += TENSOR1##_strides[TENSOR1##_i]; \
315315
\
316-
if(TENSOR1##_counter[TENSOR1##_i] == TENSOR1##_dims[TENSOR1##_i]) \
316+
if(TENSOR1##_counter[TENSOR1##_i] == TENSOR1##_sizes[TENSOR1##_i]) \
317317
{ \
318318
if(TENSOR1##_i == 0) \
319319
{ \
@@ -343,7 +343,7 @@
343343
TENSOR2##_counter[TENSOR2##_i]++; \
344344
TENSOR2##_data += TENSOR2##_strides[TENSOR2##_i]; \
345345
\
346-
if(TENSOR2##_counter[TENSOR2##_i] == TENSOR2##_dims[TENSOR2##_i]) \
346+
if(TENSOR2##_counter[TENSOR2##_i] == TENSOR2##_sizes[TENSOR2##_i]) \
347347
{ \
348348
if(TENSOR2##_i == 0) \
349349
{ \
@@ -392,7 +392,7 @@
392392
#define TH_TENSOR_APPLY(TYPE, TENSOR, CODE) \
393393
{ \
394394
TYPE *TENSOR##_data = NULL; \
395-
long *TENSOR##_counter = NULL, *TENSOR##_dims = NULL, *TENSOR##_strides = NULL; \
395+
long *TENSOR##_counter = NULL, *TENSOR##_sizes = NULL, *TENSOR##_strides = NULL; \
396396
long TENSOR##_stride = 0, TENSOR##_size = 0, TENSOR##_dim = 0, TENSOR##_i; \
397397
int TH_TENSOR_APPLY_hasFinished = 0; \
398398
long TH_TENSOR_dim_index = 0; \
@@ -416,10 +416,10 @@
416416
/* this counter array is empty. */ \
417417
\
418418
TENSOR##_counter = (long*)THAlloc(sizeof(long)*(3*TENSOR##_dim)); \
419-
TENSOR##_dims = TENSOR##_counter + TENSOR##_dim; \
419+
TENSOR##_sizes = TENSOR##_counter + TENSOR##_dim; \
420420
TENSOR##_strides = TENSOR##_counter + 2*TENSOR##_dim; \
421421
TH_TENSOR_dim_index = TENSOR##_dim-1; \
422-
TENSOR##_dims[TH_TENSOR_dim_index] = TENSOR->size[TENSOR->nDimension-1]; \
422+
TENSOR##_sizes[TH_TENSOR_dim_index] = TENSOR->size[TENSOR->nDimension-1]; \
423423
TENSOR##_strides[TH_TENSOR_dim_index] = TENSOR->stride[TENSOR->nDimension-1]; \
424424
/* what is the first stride? */ \
425425
/* TENSOR##_counter tracks where we are in the storage. The offset into the */ \
@@ -430,15 +430,15 @@
430430
} \
431431
for(TENSOR##_i = TENSOR->nDimension-2; TENSOR##_i >= 0; --TENSOR##_i) { \
432432
if (TENSOR->stride[TENSOR##_i] == TENSOR->stride[TENSOR##_i+1] * TENSOR->size[TENSOR##_i+1]) { \
433-
TENSOR##_dims[TH_TENSOR_dim_index] = TENSOR->size[TENSOR##_i] * TENSOR##_dims[TH_TENSOR_dim_index]; \
433+
TENSOR##_sizes[TH_TENSOR_dim_index] = TENSOR->size[TENSOR##_i] * TENSOR##_sizes[TH_TENSOR_dim_index]; \
434434
} else { \
435435
--TH_TENSOR_dim_index; \
436-
TENSOR##_dims[TH_TENSOR_dim_index] = TENSOR->size[TENSOR##_i]; \
436+
TENSOR##_sizes[TH_TENSOR_dim_index] = TENSOR->size[TENSOR##_i]; \
437437
TENSOR##_strides[TH_TENSOR_dim_index] = TENSOR->stride[TENSOR##_i]; \
438438
} \
439439
} \
440440
/* it will be used for offset updates while looping through the largest contiguous section */ \
441-
TENSOR##_size = TENSOR##_dims[TENSOR##_dim-1]; \
441+
TENSOR##_size = TENSOR##_sizes[TENSOR##_dim-1]; \
442442
/* what is the largest contiguous section? size will store the size of this section */ \
443443
TENSOR##_stride = TENSOR##_strides[TENSOR##_dim-1]; \
444444
} \
@@ -464,7 +464,7 @@
464464
/* Jump ahread by the stride of this dimension */ \
465465
TENSOR##_data += TENSOR##_strides[TENSOR##_i]; \
466466
\
467-
if(TENSOR##_counter[TENSOR##_i] == TENSOR##_dims[TENSOR##_i]) \
467+
if(TENSOR##_counter[TENSOR##_i] == TENSOR##_sizes[TENSOR##_i]) \
468468
{ \
469469
if(TENSOR##_i == 0) \
470470
{ \

0 commit comments

Comments
 (0)