Commit b66526a
Emit tosa::erf during lowering gelu op (#4151)
The PR adds support to use tosa::erf during lowering of aten.gelu op
Currently, aten.gelu uses its own custom implementation of erf which was
designed before tosa support for tosa::erf :
llvm/llvm-project@1fef1f9
aten.erf is already mapped to tosa::ErfOp
https://github.com/vinitdeodhar/torch-mlir/blob/c785435a049a694a1814a7304ed0c34abe8b2580/lib/Conversion/TorchToTosa/TorchToTosa.cpp#L9176
The two implementations (Existing aten.gelu erf and tosa::erf) produce
numerically different results.
tosa::erf is more precise approximation of the erf function. tosa::erf
approximation is based on the following stackoverflow post:
https://stackoverflow.com/questions/35966695/vectorizable-implementation-of-complementary-error-function-erfcf
The stackoverflow post is in turn based on:
M. M. Shepherd and J. G. Laframboise, "Chebyshev Approximation of
(1+2x)exp(x^2)erfc x in 0 <= x < INF", Mathematics of Computation, Vol.
36,
No. 153, January 1981, pp. 249-253.
Maximum error: 2.65 ulps
---------
Co-authored-by: Vinit Deodhar <[email protected]>1 parent 4bd7d03 commit b66526a
File tree
4 files changed
+62
-72
lines changed- lib/Conversion/TorchToTosa
- projects/pt1
- e2e_testing
- python/torch_mlir_e2e_test/test_suite
- test/Conversion/TorchToTosa
4 files changed
+62
-72
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3369 | 3369 | | |
3370 | 3370 | | |
3371 | 3371 | | |
3372 | | - | |
3373 | | - | |
3374 | | - | |
3375 | | - | |
3376 | | - | |
3377 | | - | |
3378 | | - | |
3379 | | - | |
3380 | | - | |
3381 | | - | |
3382 | | - | |
3383 | | - | |
3384 | | - | |
3385 | | - | |
3386 | | - | |
3387 | | - | |
3388 | | - | |
3389 | | - | |
3390 | | - | |
3391 | | - | |
3392 | | - | |
3393 | | - | |
3394 | | - | |
3395 | | - | |
3396 | | - | |
3397 | | - | |
3398 | | - | |
3399 | | - | |
3400 | | - | |
3401 | | - | |
3402 | | - | |
3403 | | - | |
3404 | | - | |
3405 | | - | |
3406 | | - | |
3407 | | - | |
3408 | | - | |
3409 | | - | |
3410 | | - | |
3411 | | - | |
3412 | | - | |
3413 | | - | |
3414 | | - | |
3415 | | - | |
3416 | | - | |
3417 | | - | |
3418 | | - | |
3419 | | - | |
3420 | | - | |
3421 | | - | |
3422 | | - | |
3423 | | - | |
3424 | | - | |
3425 | | - | |
3426 | | - | |
3427 | | - | |
3428 | | - | |
3429 | | - | |
3430 | | - | |
3431 | | - | |
3432 | | - | |
3433 | | - | |
3434 | | - | |
3435 | | - | |
3436 | | - | |
3437 | | - | |
3438 | | - | |
3439 | | - | |
3440 | | - | |
3441 | | - | |
3442 | | - | |
3443 | 3372 | | |
3444 | 3373 | | |
3445 | 3374 | | |
| |||
3467 | 3396 | | |
3468 | 3397 | | |
3469 | 3398 | | |
3470 | | - | |
| 3399 | + | |
3471 | 3400 | | |
3472 | 3401 | | |
3473 | 3402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2197 | 2197 | | |
2198 | 2198 | | |
2199 | 2199 | | |
| 2200 | + | |
2200 | 2201 | | |
2201 | 2202 | | |
2202 | 2203 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1374 | 1374 | | |
1375 | 1375 | | |
1376 | 1376 | | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
1377 | 1401 | | |
1378 | 1402 | | |
1379 | 1403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3071 | 3071 | | |
3072 | 3072 | | |
3073 | 3073 | | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
3074 | 3110 | | |
3075 | 3111 | | |
3076 | 3112 | | |
| |||
0 commit comments