Corrected comment in add sv_expf_inline.h #77
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
sv_expf_inline.h, lines 55 to 63:lane_constscontainsln2_lo,c0,c2,c4, (lane_consts = svld1rq (svptrue_b32 (), &d->ln2_lo)), hence:p12 = svmla_lane (sv_f32 (d->c1), r, lane_consts, 2)is computingc1+ rc2p34 = svmla_lane (sv_f32 (d->c3), r, lane_consts, 3)is computingc3+ rc4p0 = svmul_lane (r, lane_consts, 1)is computing rc0In
p14there isp12+ r^2p34= c1 + rc2+ r^2 (c3+ rc4) =c1+ rc2+ r^2c3+ r^3c4.polywill contain the values forp0+ r^2p14= rc0+ r^2 (c1+ rc2+ r^2c3+ r^3c4) = rc0+ r^2c1+ r^3c2+ r^4c3+ r^5c4Finally the returned value is
scale+scale*poly=scale(1 +poly) =scale* exp(r).Hence
polyis a polynomial of degree 5, not 6 as written in the comment, and the coefficients have to be changed accordingly (c0with r,c1with r^2, etc.).Since on line 42 the final result has been defined as
exp(x) = 2^n (1 + poly(r))andyis not used elsewhere, I would also change theyon line 55 withpoly(r).The error may come from
exp.cwherec0is the coefficient of r^2: