-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[ | ||
{ | ||
"name": "QuickGelu test", | ||
"operator": "QuickGelu", | ||
"opset": { "domain": "com.microsoft", "version": 1 }, | ||
"cases": [ | ||
{ | ||
"name": "[2x4]", | ||
"inputs": [ | ||
{ | ||
"data": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, -0.8], | ||
"dims": [2, 4], | ||
"type": "float32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [0.0542447, 0.116857, 0.187484, 0.265566, 0.350388, 0.441123, 0.53689, 0.636815], | ||
"dims": [2, 4], | ||
"type": "float32" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "[3x5]", | ||
"inputs": [ | ||
{ | ||
"data": [0.1, 0.2, 0.3, 0.4, 0.5, 1, 2, 3, 4, 5, 1.1, 1.2, 1.3, 1.4, -1.5], | ||
"dims": [3, 5], | ||
"type": "float32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [ | ||
0.0542447, 0.116857, 0.187484, 0.265566, 0.350388, 0.845795, 1.9356, 2.98192, 3.99558, 4.99899, 0.953383, | ||
1.0622, 1.17178, 1.2817, 1.39166 | ||
], | ||
"dims": [3, 5], | ||
"type": "float32" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "quick_gelu.h" | ||
|
||
namespace onnxruntime { | ||
namespace contrib { | ||
namespace js { | ||
|
||
using onnxruntime::js::JsepSupportedFloatTypes; | ||
|
||
ONNX_OPERATOR_KERNEL_EX( | ||
QuickGelu, | ||
kMSDomain, | ||
1, | ||
kJsExecutionProvider, | ||
(*KernelDefBuilder::Create()) | ||
.TypeConstraint("T", JsepSupportedFloatTypes()), | ||
QuickGelu); | ||
|
||
} // namespace js | ||
} // namespace contrib | ||
} // namespace onnxruntime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include "core/providers/js/js_kernel.h" | ||
|
||
namespace onnxruntime { | ||
namespace contrib { | ||
namespace js { | ||
|
||
using onnxruntime::js::JsKernel; | ||
|
||
class QuickGelu final : public JsKernel { | ||
public: | ||
explicit QuickGelu(const OpKernelInfo& info) : JsKernel(info) { | ||
float alpha = info.GetAttrOrDefault<float>("alpha", 1.0); | ||
JSEP_INIT_KERNEL_ATTRIBUTE(QuickGelu, ({"alpha" : $1}), alpha); | ||
} | ||
}; | ||
|
||
} // namespace js | ||
} // namespace contrib | ||
} // namespace onnxruntime |