Skip to content

Commit c43b120

Browse files
sighingnowsoumith
authored andcommitted
Improve float precision stability of linspace op, fix 4419. (#4470)
Signed-off-by: HE, Tao <sighingnow@gmail.com>
1 parent cc9dc3f commit c43b120

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

aten/src/TH/generic/THTensorMath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3383,7 +3383,7 @@ void THTensor_(linspace)(THTensor *r_, real a, real b, int64_t n)
33833383
THTensor_(set1d)(r_, 0, a);
33843384
} else {
33853385
TH_TENSOR_APPLY(real, r_,
3386-
*r__data = a + i*(b-a)/((real)(n-1));
3386+
*r__data = a + (b-a)/((real)(n-1))*i;
33873387
i++;
33883388
);
33893389
}

0 commit comments

Comments
 (0)