Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Killeen <killeentm@gmail.com>2017-06-21 18:03:39 +0300
committerSoumith Chintala <soumith@gmail.com>2017-06-22 19:55:17 +0300
commite3917893c4bdfc64e46167c4147f759166652e36 (patch)
tree00c2e4e579096b17fa102a8318d2a767465e57fd
parent6a333ebb6a8259efccb6d2a47e3c2c107d188d83 (diff)
TensorLib/Aten --> changes required in pytorch
-rw-r--r--lib/TH/generic/THTensorMath.c11
-rw-r--r--lib/TH/generic/THTensorMath.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/TH/generic/THTensorMath.c b/lib/TH/generic/THTensorMath.c
index 29894e2..24fe11e 100644
--- a/lib/TH/generic/THTensorMath.c
+++ b/lib/TH/generic/THTensorMath.c
@@ -1979,6 +1979,17 @@ void THTensor_(range)(THTensor *r_, accreal xmin, accreal xmax, accreal step)
TH_TENSOR_APPLY(real, r_, *r__data = xmin + (i++)*step;);
}
+void THTensor_(arange)(THTensor *r_, accreal xmin, accreal xmax, accreal step) {
+#if defined(TH_REAL_IS_FLOAT) || defined(TH_REAL_IS_DOUBLE)
+ int m = fmod(xmax - xmin,step) == 0;
+#else
+ int m = (xmax - xmin) % step == 0;
+#endif
+ if (m)
+ xmax -= step;
+ THTensor_(range)(r_,xmin,xmax,step);
+}
+
void THTensor_(randperm)(THTensor *r_, THGenerator *_generator, long n)
{
real *r__data;
diff --git a/lib/TH/generic/THTensorMath.h b/lib/TH/generic/THTensorMath.h
index bacc9df..6337533 100644
--- a/lib/TH/generic/THTensorMath.h
+++ b/lib/TH/generic/THTensorMath.h
@@ -92,6 +92,7 @@ TH_API void THTensor_(zeros)(THTensor *r_, THLongStorage *size);
TH_API void THTensor_(ones)(THTensor *r_, THLongStorage *size);
TH_API void THTensor_(diag)(THTensor *r_, THTensor *t, int k);
TH_API void THTensor_(eye)(THTensor *r_, long n, long m);
+TH_API void THTensor_(arange)(THTensor *r_, accreal xmin, accreal xmax, accreal step);
TH_API void THTensor_(range)(THTensor *r_, accreal xmin, accreal xmax, accreal step);
TH_API void THTensor_(randperm)(THTensor *r_, THGenerator *_generator, long n);