Commit a02f769
[MLAS] Enable FP16 for Gelu (#26815)
Enabled fp16 Gelu for opset20.Gelu uses tanh and ERF functions depending
on the approximation method used. Implemented tanh in sve and erf in sve
and neon .
Gr3E results: with tanh and erf approximation:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link id=Main-File rel=Main-File
href="file:///C:/Users/arunak/AppData/Local/Temp/msohtmlclip1/01/clip.htm">
<link rel=File-List
href="file:///C:/Users/arunak/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml">
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:.75in .7in .75in .7in;
mso-header-margin:.3in;
mso-footer-margin:.3in;}
tr
{mso-height-source:auto;}
col
{mso-width-source:auto;}
br
{mso-data-placement:same-cell;}
td
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:"Aptos Narrow", sans-serif;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
.xl65
{text-align:center;
border:.5pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl66
{text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:1.0pt solid windowtext;
border-left:.5pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl67
{font-weight:700;
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl68
{font-weight:700;
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl69
{font-weight:700;
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl70
{text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl71
{text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl72
{font-weight:700;
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl73
{font-weight:700;
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:.5pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl74
{font-weight:700;
text-align:center;
border-top:none;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl75
{font-weight:700;
border:1.0pt solid windowtext;}
.xl76
{font-weight:700;
text-align:center;
border-top:1.0pt solid windowtext;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;}
.xl77
{font-weight:700;
text-align:center;
border-top:1.0pt solid windowtext;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:none;}
-->
</head>
<body link="#467886" vlink="#96607D">
GELU(ms) | Tanh_SVE | ERF_SVE | Tanh_NEON | ERF_NEON
-- | -- | -- | -- | --
Shape | F32 | F16 | F32 | F16 | F32 | F16 | F32 | F16
100 | 0.007 | 0.007 | 0.007 | 0.007 | 0.007 | 0.007 | 0.007 | 0.007
1000 | 0.008 | 0.007 | 0.012 | 0.008 | 0.008 | 0.008 | 0.012 | 0.008
1000000 | 0.076 | 0.039 | 0.203 | 0.07 | 0.066 | 0.043 | 0.151 | 0.064
</body>
</html>
Gr4 results: with tanh and erf approximation:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link id=Main-File rel=Main-File
href="file:///C:/Users/arunak/AppData/Local/Temp/msohtmlclip1/01/clip.htm">
<link rel=File-List
href="file:///C:/Users/arunak/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml">
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:.75in .7in .75in .7in;
mso-header-margin:.3in;
mso-footer-margin:.3in;}
tr
{mso-height-source:auto;}
col
{mso-width-source:auto;}
br
{mso-data-placement:same-cell;}
td
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:"Aptos Narrow", sans-serif;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
.xl65
{text-align:center;
border:.5pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl66
{text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:1.0pt solid windowtext;
border-left:.5pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl67
{font-weight:700;
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl68
{font-weight:700;
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl69
{font-weight:700;
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl70
{text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl71
{text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#ADADAD;
mso-pattern:black none;}
.xl72
{font-weight:700;
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl73
{font-weight:700;
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:.5pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl74
{font-weight:700;
text-align:center;
border-top:none;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;
background:#F7C7AC;
mso-pattern:black none;}
.xl75
{font-weight:700;
border:1.0pt solid windowtext;}
.xl76
{font-weight:700;
text-align:center;
border-top:1.0pt solid windowtext;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:1.0pt solid windowtext;}
.xl77
{font-weight:700;
text-align:center;
border-top:1.0pt solid windowtext;
border-right:none;
border-bottom:1.0pt solid windowtext;
border-left:none;}
-->
</head>
<body link="#467886" vlink="#96607D">
GELU(ms) | Tanh_SVE | ERF_SVE | Tanh_NEON | ERF_NEON
-- | -- | -- | -- | --
Shape | F32 | F16 | F32 | F16 | F32 | F16 | F32 | F16
100 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005
1000 | 0.006 | 0.006 | 0.008 | 0.006 | 0.006 | 0.006 | 0.008 | 0.006
1000000 | 0.092 | 0.046 | 0.224 | 0.088 | 0.091 | 0.051 | 0.213 | 0.086
</body>
</html>
This PR is a joint contribution by:
Aruna K(@akote123)
Abhishek Jain(@abhijain1204fujitsu)
Sanket Kale(@sanketkaleoss )
---------
Co-authored-by: Sanket Kale <sanketk.kale@fujitsu.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent c7c99ce commit a02f769
19 files changed
Lines changed: 1169 additions & 27 deletions
File tree
- cmake
- onnxruntime
- core
- mlas
- inc
- lib
- sve
- providers/cpu
- math
- tensor
- test/providers/cpu/activation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| 513 | + | |
| 514 | + | |
513 | 515 | | |
| 516 | + | |
514 | 517 | | |
515 | 518 | | |
516 | 519 | | |
| |||
548 | 551 | | |
549 | 552 | | |
550 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
551 | 558 | | |
552 | 559 | | |
553 | 560 | | |
| |||
577 | 584 | | |
578 | 585 | | |
579 | 586 | | |
| 587 | + | |
| 588 | + | |
580 | 589 | | |
581 | 590 | | |
582 | 591 | | |
| |||
988 | 997 | | |
989 | 998 | | |
990 | 999 | | |
991 | | - | |
| 1000 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2237 | 2237 | | |
2238 | 2238 | | |
2239 | 2239 | | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
582 | | - | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
0 commit comments