Skip to content
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

[WebNN EP] Support MultiHeadAttention(MHA) #24079

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions onnxruntime/core/providers/webnn/builders/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const std::map<std::string_view, std::vector<std::string_view>> decomposed_op_ma
"softmax", "transpose", "where"}},
{"LRN", {"add", "averagePool2d", "div", "mul", "pad", "pow", "transpose"}},
{"MatMulNBits", {"add", "dequantizeLinear", "matmul", "reshape", "transpose"}},
{"MultiHeadAttention", {"add", "cast", "concat", "constant", "div", "matmul", "reshape", "softmax", "transpose"}},
{"RotaryEmbedding", {"add", "concat", "gather", "mul", "reshape", "split"}},
{"SimplifiedLayerNormalization", {"add", "div", "mul", "pow", "reduceMean", "sqrt"}},
{"SkipSimplifiedLayerNormalization", {"add", "div", "mul", "pow", "reduceMean", "sqrt"}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright (c) Intel Corporation. All rights reserved.
// Licensed under the MIT License.

#pragma once

namespace onnxruntime {
namespace webnn {
/*
Expand All @@ -26,10 +28,11 @@ namespace webnn {
|
output
*/
emscripten::val ScaledDotProductAttention(ModelBuilder& model_builder, const Node& node, const logging::Logger& logger,
emscripten::val query, emscripten::val key, emscripten::val value,
emscripten::val scale, emscripten::val attn_mask,
std::vector<uint32_t> reshape_output_shape) {
inline emscripten::val ScaledDotProductAttention(ModelBuilder& model_builder, const Node& node,
const logging::Logger& logger, emscripten::val query,
emscripten::val key, emscripten::val value, emscripten::val scale,
emscripten::val attn_mask,
std::vector<uint32_t> reshape_output_shape) {
emscripten::val common_options = emscripten::val::object();
// B,H,S,N * B,H,kv_S,N = B,H,S,kv_S
common_options.set("label", node.Name() + "_/Attention/qkv/matmul_1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "core/providers/webnn/builders/helper.h"
#include "core/providers/webnn/builders/model_builder.h"
#include "core/providers/webnn/builders/op_builder_factory.h"
#include "cmath"
#include <cmath>

#include "base_op_builder.h"
#include "attention_helper.h"
Expand Down
Loading