-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add webgpu plugin EP pipeline #27841
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
9013904
webgpu plugin pipeline
fs-eire 23782b9
2
fs-eire 0a8b240
linux
fs-eire f7c6c34
change npm feed
fs-eire 4639345
fix linux build 2
fs-eire 8cd1590
include version info
fs-eire 794c6a3
fix build tool path
fs-eire 1492f57
fix linux build 3
fs-eire ad6d885
exclude build tools from code sign
fs-eire 781627e
dxc copy
fs-eire 7334ea9
publish U package
fs-eire fe278cd
validate params
fs-eire e4f654d
use version string to detect ORT API version
fs-eire f6d38f5
update packaging pipeline
fs-eire 113c823
fix build
fs-eire 1b3cee6
resolve comments
fs-eire 9037880
Merge remote-tracking branch 'origin/main' into fs-eire/webgpu-plugin…
fs-eire 2a1ffff
fix build flag for arm64
fs-eire 31c4f4c
apply fix according to comments
fs-eire 4b97ea1
save current ort api version
fs-eire 85eb070
resolve comments
fs-eire 04278d9
fix build
fs-eire a81e76d
resolve comments
fs-eire 4d8a762
Merge remote-tracking branch 'origin/main' into fs-eire/webgpu-plugin…
fs-eire ea3aa72
resolve comments
fs-eire 92bfc30
fix build
fs-eire 1214dd2
suppress MSVC ICE
fs-eire 70174de
Address PR review feedback: null checks, binary verification, and nits
fs-eire 1c90606
Add DXC hash verification and fail on RC versioning
fs-eire 1b868f3
Update tools/ci_build/github/linux/build_webgpu_plugin_package.sh
fs-eire e0a4ce8
sign dxc dlls
fs-eire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,68 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
| #include <string_view> | ||
|
|
||
| #include "core/session/onnxruntime_c_api.h" | ||
|
|
||
| namespace onnxruntime::version_check { | ||
|
|
||
| // A simple consteval-friendly result type for ParseUint. | ||
| // std::optional triggers an internal compiler error in MSVC 14.44 when used with consteval. | ||
| struct ParseUintResult { | ||
| uint32_t value; | ||
| bool has_value; | ||
|
|
||
| consteval bool operator==(uint32_t other) const { return has_value && value == other; } | ||
| consteval bool operator!=(uint32_t other) const { return !(*this == other); } | ||
| }; | ||
|
|
||
| inline consteval ParseUintResult ParseUintNone() { return {0, false}; } | ||
|
|
||
| // Parse a non-negative integer from a string_view without leading zeros. | ||
| // Returns a result with has_value == false on failure (empty, leading zero, non-digit, or overflow). | ||
| consteval ParseUintResult ParseUint(std::string_view str) { | ||
| if (str.empty()) return ParseUintNone(); | ||
| // Leading zeros are not allowed (except "0" itself). | ||
| if (str.size() > 1 && str[0] == '0') return ParseUintNone(); | ||
| uint64_t result = 0; | ||
| for (char c : str) { | ||
| if (c < '0' || c > '9') return ParseUintNone(); | ||
| result = result * 10 + static_cast<uint64_t>(c - '0'); | ||
| if (result > UINT32_MAX) return ParseUintNone(); | ||
| } | ||
| return {static_cast<uint32_t>(result), true}; | ||
| } | ||
|
|
||
| // Validates a version string at compile time. | ||
| // It must be in the format "1.Y.Z" where: | ||
| // - Major version is 1 | ||
| // - Y and Z are non-negative integers without leading zeros | ||
| // - Y (minor version) must equal expected_api_version (defaults to ORT_API_VERSION) | ||
| consteval bool IsOrtVersionValid(std::string_view version, uint32_t expected_api_version = ORT_API_VERSION) { | ||
| size_t first_dot = version.find('.'); | ||
| if (first_dot == std::string_view::npos) return false; | ||
| size_t second_dot = version.find('.', first_dot + 1); | ||
| if (second_dot == std::string_view::npos) return false; | ||
| if (version.find('.', second_dot + 1) != std::string_view::npos) return false; // Exactly two dots | ||
| std::string_view major = version.substr(0, first_dot); | ||
| std::string_view minor = version.substr(first_dot + 1, second_dot - first_dot - 1); | ||
| std::string_view patch = version.substr(second_dot + 1); | ||
| if (major != "1") { | ||
| return false; | ||
| } | ||
| auto minor_val = ParseUint(minor); | ||
| auto patch_val = ParseUint(patch); | ||
| if (!minor_val.has_value || !patch_val.has_value) { | ||
| return false; | ||
| } | ||
| if (minor_val.value != expected_api_version) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| } // namespace onnxruntime::version_check |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,31 +1,64 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #include "onnxruntime_config.h" | ||
| #include "core/session/onnxruntime_cxx_api.h" | ||
| #include "core/session/ort_version_check.h" | ||
|
|
||
| #include <cstdint> | ||
| #include <charconv> | ||
| #include <optional> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "absl/strings/str_split.h" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| TEST(CApiTest, VersionConsistencyWithApiVersion) { | ||
| const auto version_string = Ort::GetVersionString(); | ||
| const std::vector<std::string> version_string_components = absl::StrSplit(version_string, '.'); | ||
| ASSERT_EQ(version_string_components.size(), size_t{3}); | ||
|
|
||
| auto to_uint32_t = [](const std::string& s) -> std::optional<uint32_t> { | ||
| uint32_t result{}; | ||
| if (std::from_chars(s.data(), s.data() + s.size(), result).ec == std::errc{}) { | ||
| return result; | ||
| } | ||
| return std::nullopt; | ||
| }; | ||
|
|
||
| ASSERT_NE(to_uint32_t(version_string_components[0]), std::nullopt); | ||
| ASSERT_EQ(to_uint32_t(version_string_components[1]), uint32_t{ORT_API_VERSION}); | ||
| ASSERT_NE(to_uint32_t(version_string_components[2]), std::nullopt); | ||
| using onnxruntime::version_check::IsOrtVersionValid; | ||
| using onnxruntime::version_check::ParseUint; | ||
|
|
||
| // Compile-time tests for ParseUint | ||
| static_assert(ParseUint("0") == 0u); | ||
| static_assert(ParseUint("1") == 1u); | ||
| static_assert(ParseUint("25") == 25u); | ||
| static_assert(ParseUint("123") == 123u); | ||
| static_assert(ParseUint("4294967295") == 4294967295u); // UINT32_MAX | ||
| static_assert(!(ParseUint("4294967296").has_value)); // UINT32_MAX + 1 overflows | ||
| static_assert(!(ParseUint("").has_value)); // empty | ||
| static_assert(!(ParseUint("01").has_value)); // leading zero | ||
| static_assert(!(ParseUint("00").has_value)); // leading zero | ||
| static_assert(!(ParseUint("abc").has_value)); // non-digit | ||
| static_assert(!(ParseUint("1a").has_value)); // trailing non-digit | ||
| static_assert(!(ParseUint("-1").has_value)); // negative sign | ||
| static_assert(!(ParseUint("1.0").has_value)); // contains dot | ||
| static_assert(ParseUint("0").has_value); | ||
| static_assert(!ParseUint("").has_value); | ||
|
|
||
| // Compile-time tests for IsOrtVersionValid (default expected_api_version = ORT_API_VERSION) | ||
| static_assert(IsOrtVersionValid(ORT_VERSION)); // current version must be valid | ||
|
|
||
| // Invalid formats | ||
| static_assert(!IsOrtVersionValid("")); | ||
| static_assert(!IsOrtVersionValid("1")); | ||
| static_assert(!IsOrtVersionValid("1.0")); | ||
| static_assert(!IsOrtVersionValid("1.0.0.0")); // too many dots | ||
| static_assert(!IsOrtVersionValid("2.0.0")); // major != 1 | ||
| static_assert(!IsOrtVersionValid("1.02.0")); // leading zero in minor | ||
| static_assert(!IsOrtVersionValid("1.0.01")); // leading zero in patch | ||
| static_assert(!IsOrtVersionValid("1..0")); // empty minor | ||
| static_assert(!IsOrtVersionValid("1.0.")); // empty patch | ||
| static_assert(!IsOrtVersionValid(".1.0")); // empty major | ||
| static_assert(!IsOrtVersionValid("abc")); // non-numeric | ||
| static_assert(!IsOrtVersionValid("1.abc.0")); // non-numeric minor | ||
| static_assert(!IsOrtVersionValid("1.0.abc")); // non-numeric patch | ||
|
|
||
| // Compile-time tests for IsOrtVersionValid with explicit expected_api_version | ||
| static_assert(IsOrtVersionValid("1.0.0", 0)); | ||
| static_assert(IsOrtVersionValid("1.1.0", 1)); | ||
| static_assert(IsOrtVersionValid("1.25.0", 25)); | ||
| static_assert(IsOrtVersionValid("1.25.3", 25)); | ||
| static_assert(IsOrtVersionValid("1.100.0", 100)); | ||
| static_assert(!IsOrtVersionValid("1.25.0", 24)); // minor doesn't match expected | ||
| static_assert(!IsOrtVersionValid("1.25.0", 26)); // minor doesn't match expected | ||
| static_assert(!IsOrtVersionValid("1.0.0", 1)); // minor 0 != expected 1 | ||
| static_assert(!IsOrtVersionValid("2.0.0", 0)); // major != 1 | ||
| static_assert(!IsOrtVersionValid("1.02.0", 2)); // leading zero in minor | ||
| static_assert(!IsOrtVersionValid("1.0.01", 0)); // leading zero in patch | ||
|
|
||
| TEST(CApiTest, VersionIsValid) { | ||
| // Runtime sanity check — the version string returned by the API is the expected one. | ||
| EXPECT_STREQ(Ort::GetVersionString().c_str(), ORT_VERSION); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.