From 58b713e0acbc705ffe28ceeccc0e04188ab87f9b Mon Sep 17 00:00:00 2001 From: Shiyi Zou Date: Thu, 29 Aug 2024 11:09:42 +0800 Subject: [PATCH] enable cpu support --- js/web/docs/webnn-operators.md | 2 +- onnxruntime/core/providers/webnn/builders/helper.h | 2 +- .../core/providers/webnn/builders/impl/lstm_op_builder.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/web/docs/webnn-operators.md b/js/web/docs/webnn-operators.md index ca50b5e431823..123516d421474 100644 --- a/js/web/docs/webnn-operators.md +++ b/js/web/docs/webnn-operators.md @@ -51,7 +51,7 @@ operators and the supported opset domain/versions in **WebNN EP** by ONNX Runtim | LessOrEqual | ai.onnx(12-15, 16+) | lesserOrEqual | ✓ | ✓ | | | Log | ai.onnx(7-12, 13+) | log | ✓ | ✓ | | | LpPool | ai.onnx(7-10, 11-17, 18+) | l2Pool2d | ✗ | ✓ | Only supports 4-D input, 2-D 'kernel_shape', 'p' value is 2 | -| LSTM | ai.onnx(7-13, 14+) | lstm | ✗ | ✓ | Only supports 'layout' == 0, 'input_forget' == 0. 'clip' is not supported. The activation functions in 'activations' must be one of 'Relu', 'Tanh', 'Sigmoid'. Forward and backward activations must be the same if bidirectional. 'sequence_lens' if present should be constant with values equal to the first dimension length of input 'X' | +| LSTM | ai.onnx(7-13, 14+) | lstm | ✓ | ✓ | Only supports 'layout' == 0, 'input_forget' == 0. 'clip' is not supported. The activation functions in 'activations' must be one of 'Relu', 'Tanh', 'Sigmoid'. Forward and backward activations must be the same if bidirectional. 'sequence_lens' if present should be constant with values equal to the first dimension length of input 'X' | | MatMul | ai.onnx(7-8, 9-12, 13+) | matmul | ✓ | ✓ | | | Max | ai.onnx(7, 8-11, 12, 13+) | max | ✓ | ✓ | | | MaxPool | ai.onnx(7, 8-9, 10, 11, 12+) | maxPool2d | ✓ | ✓ | Only supports 4-D input, 2-D 'kernel_shape', 'storage_order' != 1, one output | diff --git a/onnxruntime/core/providers/webnn/builders/helper.h b/onnxruntime/core/providers/webnn/builders/helper.h index 3c649eff85447..3c67de3acdb05 100644 --- a/onnxruntime/core/providers/webnn/builders/helper.h +++ b/onnxruntime/core/providers/webnn/builders/helper.h @@ -198,7 +198,7 @@ static const InlinedHashMap op_map = { {"LessOrEqual", {"lesserOrEqual", true}}, {"Log", {"log", true}}, {"LpPool", {"l2Pool2d", false}}, - {"LSTM", {"lstm", false}}, + {"LSTM", {"lstm", true}}, {"MatMul", {"matmul", true}}, {"MatMulInteger", {"matmulInteger", false}}, {"Max", {"max", true}}, diff --git a/onnxruntime/core/providers/webnn/builders/impl/lstm_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/lstm_op_builder.cc index 2f6d2f497a27b..e24a9b2c68474 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/lstm_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/lstm_op_builder.cc @@ -145,8 +145,8 @@ bool LstmOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers, LOGS(logger, ERROR) << "Cannot read sequence lens tensor"; return false; } - if (!std::all_of(sequence_lens.begin(), sequence_lens.end(), - [steps](int32_t lens) -> bool { return steps == lens; })) { + if (std::any_of(sequence_lens.begin(), sequence_lens.end(), + [steps](int32_t lens) -> bool { return steps != lens; })) { LOGS(logger, ERROR) << "LSTM: every sequence length must be equal to input shape[0]"; return false; }