Skip to content

Commit e391789

Browse files
killeentsoumith
authored andcommitted
TensorLib/Aten --> changes required in pytorch
1 parent 6a333eb commit e391789

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/TH/generic/THTensorMath.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,17 @@ void THTensor_(range)(THTensor *r_, accreal xmin, accreal xmax, accreal step)
19791979
TH_TENSOR_APPLY(real, r_, *r__data = xmin + (i++)*step;);
19801980
}
19811981

1982+
void THTensor_(arange)(THTensor *r_, accreal xmin, accreal xmax, accreal step) {
1983+
#if defined(TH_REAL_IS_FLOAT) || defined(TH_REAL_IS_DOUBLE)
1984+
int m = fmod(xmax - xmin,step) == 0;
1985+
#else
1986+
int m = (xmax - xmin) % step == 0;
1987+
#endif
1988+
if (m)
1989+
xmax -= step;
1990+
THTensor_(range)(r_,xmin,xmax,step);
1991+
}
1992+
19821993
void THTensor_(randperm)(THTensor *r_, THGenerator *_generator, long n)
19831994
{
19841995
real *r__data;

lib/TH/generic/THTensorMath.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ TH_API void THTensor_(zeros)(THTensor *r_, THLongStorage *size);
9292
TH_API void THTensor_(ones)(THTensor *r_, THLongStorage *size);
9393
TH_API void THTensor_(diag)(THTensor *r_, THTensor *t, int k);
9494
TH_API void THTensor_(eye)(THTensor *r_, long n, long m);
95+
TH_API void THTensor_(arange)(THTensor *r_, accreal xmin, accreal xmax, accreal step);
9596
TH_API void THTensor_(range)(THTensor *r_, accreal xmin, accreal xmax, accreal step);
9697
TH_API void THTensor_(randperm)(THTensor *r_, THGenerator *_generator, long n);
9798

0 commit comments

Comments
 (0)