|
209 | 209 | #define TH_TENSOR_APPLY2(TYPE1, TENSOR1, TYPE2, TENSOR2, CODE) \ |
210 | 210 | { \ |
211 | 211 | 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; \ |
213 | 213 | long TENSOR1##_stride = 0, TENSOR1##_size = 0, TENSOR1##_dim = 0, TENSOR1##_i, TENSOR1##_n; \ |
214 | 214 | 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; \ |
216 | 216 | long TENSOR2##_stride = 0, TENSOR2##_size = 0, TENSOR2##_dim = 0, TENSOR2##_i, TENSOR2##_n; \ |
217 | 217 | int TH_TENSOR_APPLY_hasFinished = 0; \ |
218 | 218 | long TH_TENSOR_dim_index = 0; \ |
|
240 | 240 | TENSOR1##_dim++; \ |
241 | 241 | } \ |
242 | 242 | TENSOR1##_counter = (long*)THAlloc(sizeof(long)*(3*TENSOR1##_dim)); \ |
243 | | - TENSOR1##_dims = TENSOR1##_counter + TENSOR1##_dim; \ |
| 243 | + TENSOR1##_sizes = TENSOR1##_counter + TENSOR1##_dim; \ |
244 | 244 | TENSOR1##_strides = TENSOR1##_counter + 2*TENSOR1##_dim; \ |
245 | 245 | 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]; \ |
247 | 247 | TENSOR1##_strides[TH_TENSOR_dim_index] = TENSOR1->stride[TENSOR1->nDimension-1]; \ |
248 | 248 | for(TENSOR1##_i = TENSOR1##_dim-1; TENSOR1##_i >= 0; --TENSOR1##_i) { \ |
249 | 249 | TENSOR1##_counter[TENSOR1##_i] = 0; \ |
250 | 250 | } \ |
251 | 251 | for(TENSOR1##_i = TENSOR1->nDimension-2; TENSOR1##_i >= 0; --TENSOR1##_i) { \ |
252 | 252 | 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]; \ |
254 | 254 | } else { \ |
255 | 255 | --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]; \ |
257 | 257 | TENSOR1##_strides[TH_TENSOR_dim_index] = TENSOR1->stride[TENSOR1##_i]; \ |
258 | 258 | } \ |
259 | 259 | } \ |
260 | 260 | /* 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]; \ |
262 | 262 | /* what is the largest contiguous section? size will store the size of this section */ \ |
263 | 263 | TENSOR1##_stride = TENSOR1##_strides[TENSOR1##_dim-1]; \ |
264 | 264 | \ |
|
270 | 270 | TENSOR2##_dim++; \ |
271 | 271 | } \ |
272 | 272 | TENSOR2##_counter = (long*)THAlloc(sizeof(long)*(3*TENSOR2##_dim)); \ |
273 | | - TENSOR2##_dims = TENSOR2##_counter + TENSOR2##_dim; \ |
| 273 | + TENSOR2##_sizes = TENSOR2##_counter + TENSOR2##_dim; \ |
274 | 274 | TENSOR2##_strides = TENSOR2##_counter + 2*TENSOR2##_dim; \ |
275 | 275 | 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]; \ |
277 | 277 | TENSOR2##_strides[TH_TENSOR_dim_index] = TENSOR2->stride[TENSOR2->nDimension-1]; \ |
278 | 278 | for(TENSOR2##_i = TENSOR2##_dim-1; TENSOR2##_i >= 0; --TENSOR2##_i) { \ |
279 | 279 | TENSOR2##_counter[TENSOR2##_i] = 0; \ |
280 | 280 | } \ |
281 | 281 | for(TENSOR2##_i = TENSOR2->nDimension-2; TENSOR2##_i >= 0; --TENSOR2##_i) { \ |
282 | 282 | 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]; \ |
284 | 284 | } else { \ |
285 | 285 | --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]; \ |
287 | 287 | TENSOR2##_strides[TH_TENSOR_dim_index] = TENSOR2->stride[TENSOR2##_i]; \ |
288 | 288 | } \ |
289 | 289 | } \ |
290 | 290 | /* 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]; \ |
292 | 292 | /* what is the largest contiguous section? size will store the size of this section */ \ |
293 | 293 | TENSOR2##_stride = TENSOR2##_strides[TENSOR2##_dim-1]; \ |
294 | 294 | } \ |
|
313 | 313 | TENSOR1##_counter[TENSOR1##_i]++; \ |
314 | 314 | TENSOR1##_data += TENSOR1##_strides[TENSOR1##_i]; \ |
315 | 315 | \ |
316 | | - if(TENSOR1##_counter[TENSOR1##_i] == TENSOR1##_dims[TENSOR1##_i]) \ |
| 316 | + if(TENSOR1##_counter[TENSOR1##_i] == TENSOR1##_sizes[TENSOR1##_i]) \ |
317 | 317 | { \ |
318 | 318 | if(TENSOR1##_i == 0) \ |
319 | 319 | { \ |
|
343 | 343 | TENSOR2##_counter[TENSOR2##_i]++; \ |
344 | 344 | TENSOR2##_data += TENSOR2##_strides[TENSOR2##_i]; \ |
345 | 345 | \ |
346 | | - if(TENSOR2##_counter[TENSOR2##_i] == TENSOR2##_dims[TENSOR2##_i]) \ |
| 346 | + if(TENSOR2##_counter[TENSOR2##_i] == TENSOR2##_sizes[TENSOR2##_i]) \ |
347 | 347 | { \ |
348 | 348 | if(TENSOR2##_i == 0) \ |
349 | 349 | { \ |
|
392 | 392 | #define TH_TENSOR_APPLY(TYPE, TENSOR, CODE) \ |
393 | 393 | { \ |
394 | 394 | 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; \ |
396 | 396 | long TENSOR##_stride = 0, TENSOR##_size = 0, TENSOR##_dim = 0, TENSOR##_i; \ |
397 | 397 | int TH_TENSOR_APPLY_hasFinished = 0; \ |
398 | 398 | long TH_TENSOR_dim_index = 0; \ |
|
416 | 416 | /* this counter array is empty. */ \ |
417 | 417 | \ |
418 | 418 | TENSOR##_counter = (long*)THAlloc(sizeof(long)*(3*TENSOR##_dim)); \ |
419 | | - TENSOR##_dims = TENSOR##_counter + TENSOR##_dim; \ |
| 419 | + TENSOR##_sizes = TENSOR##_counter + TENSOR##_dim; \ |
420 | 420 | TENSOR##_strides = TENSOR##_counter + 2*TENSOR##_dim; \ |
421 | 421 | 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]; \ |
423 | 423 | TENSOR##_strides[TH_TENSOR_dim_index] = TENSOR->stride[TENSOR->nDimension-1]; \ |
424 | 424 | /* what is the first stride? */ \ |
425 | 425 | /* TENSOR##_counter tracks where we are in the storage. The offset into the */ \ |
|
430 | 430 | } \ |
431 | 431 | for(TENSOR##_i = TENSOR->nDimension-2; TENSOR##_i >= 0; --TENSOR##_i) { \ |
432 | 432 | 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]; \ |
434 | 434 | } else { \ |
435 | 435 | --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]; \ |
437 | 437 | TENSOR##_strides[TH_TENSOR_dim_index] = TENSOR->stride[TENSOR##_i]; \ |
438 | 438 | } \ |
439 | 439 | } \ |
440 | 440 | /* 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]; \ |
442 | 442 | /* what is the largest contiguous section? size will store the size of this section */ \ |
443 | 443 | TENSOR##_stride = TENSOR##_strides[TENSOR##_dim-1]; \ |
444 | 444 | } \ |
|
464 | 464 | /* Jump ahread by the stride of this dimension */ \ |
465 | 465 | TENSOR##_data += TENSOR##_strides[TENSOR##_i]; \ |
466 | 466 | \ |
467 | | - if(TENSOR##_counter[TENSOR##_i] == TENSOR##_dims[TENSOR##_i]) \ |
| 467 | + if(TENSOR##_counter[TENSOR##_i] == TENSOR##_sizes[TENSOR##_i]) \ |
468 | 468 | { \ |
469 | 469 | if(TENSOR##_i == 0) \ |
470 | 470 | { \ |
|
0 commit comments