Skip to content

Commit

Permalink
Restore deps.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
adityagoel4512 committed Jan 7, 2024
1 parent 3078acf commit 331ef01
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cmake/deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ flatbuffers;https://github.com/google/flatbuffers/archive/refs/tags/v1.12.0.zip;
fp16;https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b64b145d91.zip;b985f6985a05a1c03ff1bb71190f66d8f98a1494
fxdiv;https://github.com/Maratyszcza/FXdiv/archive/63058eff77e11aa15bf531df5dd34395ec3017c8.zip;a5658f4036402dbca7cebee32be57fb8149811e1
google_benchmark;https://github.com/google/benchmark/archive/refs/tags/v1.7.0.zip;e97c368b176e8614e3f1bf13dd9abcf6a7ad9908
google_nsync;https://github.com/google/nsync/archive/refs/tags/1.23.0.zip;f3233450cf7156fc0bedd1b0e884eddec264897c
googletest;https://github.com/google/googletest/archive/519beb0e52c842729b4b53731d27c0e0c32ab4a2.zip;4b3c37972e4c1bef1185d46f702082f8772ee73f
google_nsync;https://github.com/google/nsync/archive/refs/tags/1.26.0.zip;5e7c00ef6bf5b787386fc040067903ec774e2752
googletest;https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip;0ac421f2ec11af38b0fff0f1992184032731a8bc
googlexnnpack;https://github.com/google/XNNPACK/archive/003c580e696a774afdc984996ee909b7c8d8128c.zip;9f192e3f15e1e37ae9c78d53eeea47e45c5eb31c
json;https://github.com/nlohmann/json/archive/refs/tags/v3.10.5.zip;f257f8dc27c5b8c085dc887b40cddd18ae1f725c
microsoft_gsl;https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.zip;cf368104cd22a87b4dd0c80228919bb2df3e2a14
Expand Down
3 changes: 0 additions & 3 deletions onnxruntime/core/providers/cpu/cpu_execution_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,6 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) {

// Opset 20
BuildKernelCreateInfo<ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, ConstantOfShape)>,
<<<<<<< HEAD
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, bool, ReduceMax)>,
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, float, ReduceMax)>,
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, double, ReduceMax)>,
Expand Down Expand Up @@ -2449,9 +2448,7 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) {
BuildKernelCreateInfo<ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, Float8E5M2FNUZ, IsNaN)>,
#endif
BuildKernelCreateInfo<ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, IsInf)>,
=======
BuildKernelCreateInfo<ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, RegexFullMatch)>,
>>>>>>> 4f27bde807 (RegexFullMatch operator)
};

for (auto& function_table_entry : function_table) {
Expand Down
24 changes: 9 additions & 15 deletions onnxruntime/core/providers/cpu/nn/regex_full_match.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "regex_full_match.h"
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include "core/providers/cpu/nn/regex_full_match.h"
#include "core/common/common.h"

namespace onnxruntime {
Expand All @@ -10,28 +13,19 @@ ONNX_CPU_OPERATOR_KERNEL(
.TypeConstraint("T2", DataTypeImpl::GetTensorType<bool>()),
RegexFullMatch);

RegexFullMatch::RegexFullMatch(const OpKernelInfo& info) : OpKernel(info) {
ORT_ENFORCE(info.GetAttr<std::string>("pattern", &pattern_).IsOK());
ORT_ENFORCE(RE2(pattern_).ok(), "Invalid pattern: ", pattern_);
RegexFullMatch::RegexFullMatch(const OpKernelInfo& info) : OpKernel(info), re_{info.GetAttr<std::string>("pattern")} {
ORT_ENFORCE(re_.ok(), "Invalid regex pattern: ", re_.pattern());
}

Status RegexFullMatch::Compute(OpKernelContext* context) const {
RE2 re(pattern_);
const auto* input_tensor = context->Input<Tensor>(0);
if (nullptr == input_tensor) {
return Status(common::ONNXRUNTIME, common::FAIL, "Input count mismatch");
}
auto* output_tensor = context->Output(0, input_tensor->Shape());
if (nullptr == output_tensor) {
return Status(common::ONNXRUNTIME, common::FAIL, "Output count mismatch");
}
const auto input_data = input_tensor->template DataAsSpan<std::string>();
auto* output_tensor = context->Output(0, input_tensor->Shape());
auto output_data = output_tensor->template MutableDataAsSpan<bool>();
const auto N = input_tensor->Shape().Size();
auto output_iter = output_data.begin();
auto input_iter = input_data.begin();
while (input_iter != output_data.end()) {
*output_iter = RE2::FullMatch(*input_iter, re);
while (input_iter != input_data.end()) {
*output_iter = RE2::FullMatch(*input_iter, re_);
input_iter++;
output_iter++;
}
Expand Down
5 changes: 4 additions & 1 deletion onnxruntime/core/providers/cpu/nn/regex_full_match.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#pragma once

#include "core/framework/op_kernel.h"
Expand All @@ -11,7 +14,7 @@ class RegexFullMatch final : public OpKernel {
Status Compute(OpKernelContext* context) const override;

private:
std::string pattern_;
RE2 re_;
};

} // namespace onnxruntime
22 changes: 21 additions & 1 deletion onnxruntime/test/providers/cpu/nn/regex_full_match_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "gtest/gtest.h"
#include "test/providers/provider_test_utils.h"

namespace onnxruntime {
namespace test {

Expand All @@ -20,5 +19,26 @@ TEST(RegexFullMatch, EmailMatch) {
RunTest({2, 2}, {"[email protected]", "[email protected]", "not email", "[email protected]"}, R"((\W|^)[\w.\-]{0,25}@(yahoo|gmail)\.com(\W|$))", {true, false, false, true});
}

TEST(RegexFullMatch, MultibyteMatch) {
RunTest({1, 2}, {"ä", "a"}, "ä", {true, false});
RunTest({1,}, {"une cédille like in Besançon"}, R"(.*cédille.*)", {true,});
RunTest({1,}, {"une cédille like in Besançon"}, R"(.*cedille.*)", {false,});
RunTest({1,}, {"Mit freundlichen Grüßen"}, R"(.*Grüßen$)", {true,});
RunTest({1,}, {"Mit freundlichen Grüßen"}, R"(.*Grußen$)", {false,});
RunTest({3,}, {"HПонедельник", "Понедельник", "недельник"}, R"(^Понед.*)", {false, true, false,});
RunTest({3,}, {"thank you", "どうもありがとうございます", "こんにちは世界"}, R"(^こんにちは世界.*)", {false, false, true,});
RunTest({3,}, {"नमस्ते, आपसे मिलकर अच्छा लगा", "नमस्ते", "स्वागत एवं नमस्ते"}, R"(.+नमस्ते$)", {false, false, true,});
RunTest({3,}, {"你好,你好吗?", "你好呀", "你好呀!"}, R"(^你好.*\?$)", {true, false, false,});
}

TEST(RegexFullMatch, InvalidPattern) {
std::cout << "TRYING RUN\n";
OpTester test("RegexFullMatch", 20, kOnnxDomain);
test.AddAttribute("pattern", R"([a-z)");
test.AddInput<std::string>("Input", {1,}, {"abcdef",});
test.AddOutput<bool>("Output", {1,}, {false,});
test.Run(BaseTester::ExpectResult::kExpectFailure, "Invalid regex pattern: [a-z");
}

} // namespace test
} // namespace onnxruntime

0 comments on commit 331ef01

Please sign in to comment.