-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[js/webgpu]FusedConv #17503
[js/webgpu]FusedConv #17503
Changes from all commits
2c994da
7f2213d
112ec16
0c56ada
1c3f556
dc3eb7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[ | ||
{ | ||
"name": "Fused Conv Relu", | ||
"operator": "FusedConv", | ||
"attributes": [ | ||
{ "name": "kernel_shape", "data": [2, 2], "type": "ints" }, | ||
{ "name": "strides", "data": [1, 1], "type": "ints" }, | ||
{ "name": "pads", "data": [0, 0, 0, 0], "type": "ints" }, | ||
{ "name": "group", "data": 1, "type": "int" }, | ||
{ "name": "dilations", "data": [1, 1], "type": "ints" }, | ||
{ "name": "activation", "data": "Relu", "type": "string" } | ||
], | ||
"cases": [ | ||
{ | ||
"name": "T[0]", | ||
"inputs": [ | ||
{ | ||
"data": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0], | ||
"dims": [1, 1, 3, 3], | ||
"type": "float32" | ||
}, | ||
{ | ||
"data": [1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0], | ||
"dims": [2, 1, 2, 2], | ||
"type": "float32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [12.0, 16.0, 24.0, 28.0, 0.0, 0.0, 0.0, 0.0], | ||
"dims": [1, 2, 2, 2], | ||
"type": "float32" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "conv without bias addition A", | ||
"operator": "Conv", | ||
"attributes": [{ "name": "kernel_shape", "data": [2, 2], "type": "ints" }], | ||
"cases": [ | ||
{ | ||
"name": "T[0]", | ||
"inputs": [ | ||
{ | ||
"data": [10, 20, 30, 40, 50, 60, 70, 80, 90], | ||
"dims": [1, 1, 3, 3], | ||
"type": "float32" | ||
}, | ||
{ | ||
"data": [1, 2, 3, 4], | ||
"dims": [1, 1, 2, 2], | ||
"type": "float32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [370, 470, 670, 770], | ||
"dims": [1, 1, 2, 2], | ||
"type": "float32" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,6 +240,8 @@ class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kMSInternalNHW | |
class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kMSInternalNHWCDomain, 1, float, GlobalAveragePool); | ||
class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kMSInternalNHWCDomain, 1, float, GlobalMaxPool); | ||
|
||
class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kMSDomain, 1, float, FusedConv); | ||
|
||
class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kOnnxDomain, 1, 10, float, Conv); | ||
class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kOnnxDomain, 11, float, Conv); | ||
class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kOnnxDomain, 1, 10, float, ConvTranspose); | ||
|
@@ -500,6 +502,8 @@ std::unique_ptr<KernelRegistry> RegisterKernels() { | |
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kMSInternalNHWCDomain, 1, float, GlobalAveragePool)>, | ||
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kMSInternalNHWCDomain, 1, float, GlobalMaxPool)>, | ||
|
||
BuildKernelCreateInfo<ONNX_CPU_OPERATOR_TYPED_MS_KERNEL(kJsExecutionProvider, kMSDomain, 1, float, FusedConv)>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifying the domain, kMSDomain, is not required when using ONNX_CPU_OPERATOR_TYPED_MS_KERNEL macro. Only name, version, type, builder, etc. are required. Is it a CPU operator? |
||
|
||
BuildKernelCreateInfo<ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kOnnxDomain, 1, 10, float, Conv)>, | ||
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kOnnxDomain, 11, float, Conv)>, | ||
BuildKernelCreateInfo<ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kJsExecutionProvider, kOnnxDomain, 1, 10, float, ConvTranspose)>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,5 +94,12 @@ class Conv : public JsKernel { | |
// Tensor w_transposed_; | ||
}; | ||
|
||
template <typename T, bool is_channels_last> | ||
class FusedConv : public Conv<T, is_channels_last> { | ||
public: | ||
explicit FusedConv(const OpKernelInfo& info) : Conv<T, is_channels_last>(info) { | ||
ORT_ENFORCE(info.GetAttr<std::string>("activation", &(this->conv_attrs_.activation)).IsOK()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting this attribute here will not pass the value to JSEP kernel because JSEP kernel is already created in the base class constructor. |
||
} | ||
}; | ||
} // namespace js | ||
} // namespace onnxruntime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to add activation attribute to this test case also?