Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jsep-attention
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire committed Nov 15, 2023
2 parents 543a453 + 0a4d76d commit 955d1a8
Show file tree
Hide file tree
Showing 351 changed files with 13,619 additions and 2,426 deletions.
44 changes: 44 additions & 0 deletions .github/actions/rust-toolchain-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json

name: 'Rust toolchain setup'
description: 'Common setup steps for GitHub workflows for Rust projects'

runs:
using: composite
steps:
- uses: dtolnay/[email protected]
with:
components: clippy, rustfmt
- uses: extractions/setup-just@v1
with:
just-version: '1.15.0' # optional semver specification, otherwise latest

###
### Linux setup
###
- name: rustup
# We need to use the nightly rust tool change to enable registry-auth / to connect to ADO feeds.
if: ${{ (runner.os == 'Linux') }}
run: |
rustup set profile minimal
rustup install
shell: bash
# - name: Cargo login
# if: ${{ (runner.os == 'Linux') }}
# run: just cargo-login-ci
# shell: bash

###
### Windows setup
###
- name: rustup
# We need to use the nightly rust tool change to enable registry-auth / to connect to ADO feeds.
if: ${{ (runner.os == 'Windows') }}
run: |
rustup set profile minimal
rustup install
shell: pwsh
# - name: Cargo login
# if: ${{ (runner.os == 'Windows') }}
# run: just cargo-login-ci-windows
# shell: pwsh
132 changes: 132 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Rust

on: [pull_request]

env:
CARGO_TERM_COLOR: always
RUST_LOG: onnxruntime=debug,onnxruntime-sys=debug
RUST_BACKTRACE: 1
MANIFEST_PATH: ${{ github.workspace }}/rust/Cargo.toml

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain-setup
- name: vendor onnxruntime source
run: just vendor
- name: fmt
run: cargo fmt --all -- --check

download:
name: Download prebuilt ONNX Runtime archive from build.rs
runs-on: ubuntu-latest
env:
ORT_RUST_STRATEGY=download
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain-setup
- run: rustup target install x86_64-unknown-linux-gnu
- run: rustup target install x86_64-apple-darwin
- run: rustup target install i686-pc-windows-msvc
- run: rustup target install x86_64-pc-windows-msvc
# ******************************************************************
- name: Download prebuilt archive (CPU, x86_64-unknown-linux-gnu)
run: cargo build --target x86_64-unknown-linux-gnu --manifest-path ${{ env.MANIFEST_PATH }}
- name: Verify prebuilt archive downloaded (CPU, x86_64-unknown-linux-gnu)
run: ls -lh target/x86_64-unknown-linux-gnu/debug/build/onnxruntime-sys-*/out/onnxruntime-linux-x64-1.*.tgz
# ******************************************************************
- name: Download prebuilt archive (CPU, x86_64-apple-darwin)
run: cargo build --target x86_64-apple-darwin --manifest-path ${{ env.MANIFEST_PATH }}
- name: Verify prebuilt archive downloaded (CPU, x86_64-apple-darwin)
run: ls -lh target/x86_64-apple-darwin/debug/build/onnxruntime-sys-*/out/onnxruntime-osx-x64-1.*.tgz
# ******************************************************************
- name: Download prebuilt archive (CPU, i686-pc-windows-msvc)
run: cargo build --target i686-pc-windows-msvc --manifest-path ${{ env.MANIFEST_PATH }}
- name: Verify prebuilt archive downloaded (CPU, i686-pc-windows-msvc)
run: ls -lh target/i686-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-x86-1.*.zip
# ******************************************************************
- name: Download prebuilt archive (CPU, x86_64-pc-windows-msvc)
run: cargo build --target x86_64-pc-windows-msvc --manifest-path ${{ env.MANIFEST_PATH }}
- name: Verify prebuilt archive downloaded (CPU, x86_64-pc-windows-msvc)
run: ls -lh target/x86_64-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-x64-1.*.zip
# ******************************************************************
- name: Download prebuilt archive (GPU, x86_64-unknown-linux-gnu)
env:
ORT_USE_CUDA: "yes"
run: cargo build --target x86_64-unknown-linux-gnu --manifest-path ${{ env.MANIFEST_PATH }}
- name: Verify prebuilt archive downloaded (GPU, x86_64-unknown-linux-gnu)
run: ls -lh target/x86_64-unknown-linux-gnu/debug/build/onnxruntime-sys-*/out/onnxruntime-linux-x64-gpu-1.*.tgz
# ******************************************************************
- name: Download prebuilt archive (GPU, x86_64-pc-windows-msvc)
env:
ORT_USE_CUDA: "yes"
run: cargo build --target x86_64-pc-windows-msvc --manifest-path ${{ env.MANIFEST_PATH }}
- name: Verify prebuilt archive downloaded (GPU, x86_64-pc-windows-msvc)
run: ls -lh target/x86_64-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-gpu-x64-1.*.zip

test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
target:
[
x86_64-unknown-linux-gnu,
x86_64-apple-darwin,
x86_64-pc-windows-msvc,
i686-pc-windows-msvc,
]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: i686-pc-windows-msvc
os: windows-latest
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain-setup
- name: vendor onnxruntime source
run: just vendor
- run: rustup target install ${{ matrix.target }}
- name: Install additional packages (macOS)
if: contains(matrix.target, 'x86_64-apple-darwin')
run: brew install libomp
- name: Build (cargo build)
run: cargo build --all --manifest-path ${{ env.MANIFEST_PATH }}
- name: Build tests (cargo test)
run: cargo test --no-run --manifest-path ${{ env.MANIFEST_PATH }}
- name: Build onnxruntime with 'model-fetching' feature
run: cargo build --manifest-path ${{ env.MANIFEST_PATH }} --features model-fetching
- name: Test onnxruntime-sys
run: cargo build --package onnxruntime-sys -- --test-threads=1 --nocapture
- name: Test onnxruntime
run: cargo test --manifest-path ${{ env.MANIFEST_PATH }} --features model-fetching -- --test-threads=1 --nocapture

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain-setup
- name: vendor onnxruntime source
run: just vendor
- run: clippy --all-features --manifest-path ${{ env.MANIFEST_PATH }} -- -D warnings

package-sys:
name: Package onnxruntime-sys
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/rust-toolchain-setup
- name: vendor onnxruntime source
run: just vendor
- run: cargo package --allow-dirty --package onnxruntime-sys
9 changes: 7 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v4.1.1
- uses: actions/stale@v8.0.0
with:
# Comma separated list of labels that can be assigned to issues to exclude them from being marked as stale
exempt-issue-labels: contributions welcome, feature request, regression
# Override exempt-all-assignees but only to exempt the issues with an assignee to be marked as stale automatically
exempt-all-issue-assignees: true
# Used to ignore the issues and pull requests created before the start date
# Start date should be April 19, 2022 - corresponds to the day previous stale bot stopped working
start-date: '2022-04-19T00:00:00Z'
# Number of days without activity before the actions/stale action labels an issue
days-before-issue-stale: 30
# Number of days without activity before the actions/stale action closes an issue
days-before-issue-close: 7
days-before-issue-close: 30
# Label you want to apply to issues that have been inactive for the amount of time specified by days-before-issue-stale
stale-issue-label: "stale"
# Comment that you want to add to issues that are labeled by the actions/stale action
Expand Down
19 changes: 0 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,6 @@
},
// Enable Python linting and Pylance type checking
"python.analysis.typeCheckingMode": "basic",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length",
"120"
],
"python.sortImports.args": [
"--profile",
"black",
"--line-length",
"120"
],
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pydocstyleEnabled": true,
"python.linting.pydocstyleArgs": [
"--convention=google"
],
"python.linting.banditEnabled": true,
"cpplint.lineLength": 120,
"cpplint.filters": [
"-build/include_subdir",
Expand Down
2 changes: 1 addition & 1 deletion cgmanifests/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "d10b27fe37736d2944630ecd7557cefa95cf87c9",
"commitHash": "e7248b26a1ed53fa030c5c459f7ea095dfd276ac",
"repositoryUrl": "https://gitlab.com/libeigen/eigen.git"
}
}
Expand Down
8 changes: 4 additions & 4 deletions cgmanifests/generated/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "003c580e696a774afdc984996ee909b7c8d8128c",
"commitHash": "0da379fc4808f9601faef392352018c741c0f297",
"repositoryUrl": "https://github.com/google/XNNPACK.git"
},
"comments": "googlexnnpack"
Expand Down Expand Up @@ -226,7 +226,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "1787867f6183f056420e532eec640cba25efafea",
"commitHash": "4fe0e1e183925bf8cfa6aae24237e724a96479b8",
"repositoryUrl": "https://github.com/Maratyszcza/pthreadpool.git"
},
"comments": "pthreadpool"
Expand Down Expand Up @@ -286,7 +286,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "c4f6b8c6bc94ff69048492fb34df0dfaf1983933",
"commitHash": "6f47420213f757831fae65c686aa471749fa8d60",
"repositoryUrl": "https://github.com/NVIDIA/cutlass.git"
},
"comments": "cutlass"
Expand Down Expand Up @@ -316,7 +316,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "d52ec01652b7d620386251db92455968d8d90bdc",
"commitHash": "a4f72a314a85732ed67d5aa8d1088d207a7e0e61",
"repositoryUrl": "https://github.com/ROCmSoftwarePlatform/composable_kernel.git"
},
"comments": "composable_kernel"
Expand Down
14 changes: 14 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,21 @@ if(NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
find_package(Iconv REQUIRED)
set(ICONV_LIB Iconv::Iconv)
endif()

find_package(Patch)
if (WIN32 AND NOT Patch_FOUND)
# work around CI machines missing patch from the git install by falling back to the binary in this repo.
# replicate what happens in https://github.com/Kitware/CMake/blob/master/Modules/FindPatch.cmake but without
# the hardcoded suffixes in the path to the patch binary.
find_program(Patch_EXECUTABLE NAMES patch PATHS ${PROJECT_SOURCE_DIR}/external/git.Win32.2.41.03.patch)
if(Patch_EXECUTABLE)
set(Patch_FOUND 1)
if (NOT TARGET Patch::patch)
add_executable(Patch::patch IMPORTED)
set_property(TARGET Patch::patch PROPERTY IMPORTED_LOCATION ${Patch_EXECUTABLE})
endif()
endif()
endif()
if(Patch_FOUND)
message("Patch found: ${Patch_EXECUTABLE}")
endif()
Expand Down
13 changes: 9 additions & 4 deletions cmake/deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
#since the file contains a version string: "lts_20230802". However, the file is for debugging purposes only and would
#not affect built binaries.
#
# NOTE: You must run deps_update_and_upload.py when ready to test your changes in a CI.
# NOTE: You must run deps_update_and_upload.py and generate_cgmanifest.py when ready to test your changes in a CI.
# See https://microsoft.sharepoint.com/teams/ONNX2/_layouts/OneNote.aspx?id=%2Fteams%2FONNX2%2FShared%20Documents%2FNotebooks%2FONNX%20Ecosystem%20Team%20Notebook&wd=target%28Development.one%7C63D3AB47-51D1-4A62-9965-66882234BD44%2FAdd%20or%20update%20a%20dependency%20in%20deps.txt%7C0E9ED71D-89D5-40FA-B05F-C0123289C591%2F%29
#
abseil_cpp;https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.zip;04271dfbfac59269b6939e1e9d5faf0d18a7ba91
cxxopts;https://github.com/jarro2783/cxxopts/archive/3c73d91c0b04e2b59462f0a741be8c07024c1bc0.zip;6c6ca7f8480b26c8d00476e0e24b7184717fe4f0
date;https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip;2dac0c81dc54ebdd8f8d073a75c053b04b56e159
dlpack;https://github.com/dmlc/dlpack/archive/refs/tags/v0.6.zip;4d565dd2e5b31321e5549591d78aa7f377173445
eigen;https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip;ef24286b7ece8737c99fa831b02941843546c081
# This Eigen commit id matches the eigen archive being consumed from https://gitlab.com/libeigen/eigen/-/archive/3.4/eigen-3.4.zip
# prior to the 3.4.1 RC changing the bits and invalidating the hash.
# it contains changes on top of 3.4.0 which are required to fix build issues.
# Until the 3.4.1 release this is the best option we have.
# Issue link: https://gitlab.com/libeigen/eigen/-/issues/2744
eigen;https://gitlab.com/libeigen/eigen/-/archive/e7248b26a1ed53fa030c5c459f7ea095dfd276ac/eigen-e7248b26a1ed53fa030c5c459f7ea095dfd276ac.zip;be8be39fdbc6e60e94fa7870b280707069b5b81a
flatbuffers;https://github.com/google/flatbuffers/archive/refs/tags/v1.12.0.zip;ba0a75fd12dbef8f6557a74e611b7a3d0c5fe7bf
fp16;https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b64b145d91.zip;b985f6985a05a1c03ff1bb71190f66d8f98a1494
fxdiv;https://github.com/Maratyszcza/FXdiv/archive/63058eff77e11aa15bf531df5dd34395ec3017c8.zip;a5658f4036402dbca7cebee32be57fb8149811e1
Expand Down Expand Up @@ -46,7 +51,7 @@ pytorch_cpuinfo;https://github.com/pytorch/cpuinfo/archive/959002f82d7962a473d8b
re2;https://github.com/google/re2/archive/refs/tags/2022-06-01.zip;aa77313b76e91b531ee7f3e45f004c6a502a5374
safeint;https://github.com/dcleblanc/SafeInt/archive/refs/tags/3.0.28.zip;23f252040ff6cb9f1fd18575b32fa8fb5928daac
tensorboard;https://github.com/tensorflow/tensorboard/archive/373eb09e4c5d2b3cc2493f0949dc4be6b6a45e81.zip;67b833913605a4f3f499894ab11528a702c2b381
cutlass;https://github.com/NVIDIA/cutlass/archive/refs/tags/v3.0.0.zip;0f95b3c1fc1bd1175c4a90b2c9e39074d1bccefd
cutlass;https://github.com/NVIDIA/cutlass/archive/refs/tags/v3.1.0.zip;757f90a795034a89d4f48a79d1f009f7a04c8dee
utf8_range;https://github.com/protocolbuffers/utf8_range/archive/72c943dea2b9240cd09efde15191e144bc7c7d38.zip;9925739c9debc0efa2adcb194d371a35b6a03156
extensions;https://github.com/microsoft/onnxruntime-extensions/archive/94142d8391c9791ec71c38336436319a2d4ac7a0.zip;4365ac5140338b4cb75a39944a4be276e3829b3c
composable_kernel;https://github.com/ROCmSoftwarePlatform/composable_kernel/archive/d52ec01652b7d620386251db92455968d8d90bdc.zip;6b5ce8edf3625f8817086c194fbf94b664e1b0e0
composable_kernel;https://github.com/ROCmSoftwarePlatform/composable_kernel/archive/a4f72a314a85732ed67d5aa8d1088d207a7e0e61.zip;f57357ab6d300e207a632d034ebc8aa036a090d9
50 changes: 38 additions & 12 deletions cmake/external/abseil-cpp.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,56 @@
</Type>
<!-- Should handle both flat hash_set and hash_map -->
<Type Name="absl::lts_20230802::container_internal::raw_hash_set&lt;*&gt;">
<DisplayString Condition="size_ == 0">empty</DisplayString>
<DisplayString>{{ size={size_} }}</DisplayString>
<Intrinsic Name="_commonfields" Expression="settings_.value"/>
<Intrinsic Name="_size" Expression="settings_.value.compressed_tuple_.value"/>
<Intrinsic Name="_capacity" Expression="_commonfields().capacity_"/>
<Intrinsic Name="_control" Expression="_commonfields().control_"/>
<Intrinsic Name="_slots" Expression="(slot_type*)(_commonfields().slots_)"/>
<DisplayString Condition="_size() == 0">empty</DisplayString>
<DisplayString IncludeView="noparens">size={ _size() }</DisplayString>
<DisplayString ExcludeView="noparens">size=({_size()})</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple">size_</Item>
<Item Name="[capacity]" ExcludeView="simple">capacity_</Item>
<CustomListItems MaxItemsPerView="5000">
<Item Name="[Size]">_size()</Item>
<Item Name="[Capacity]" ExcludeView="noparens">_capacity()</Item>
<CustomListItems MaxItemsPerView="100">
<Variable Name="nslot" InitialValue="0" />
<Size>size_</Size>
<Size>_size()</Size>
<Loop>
<!-- bool IsFull(ctrl_t c) const { return c >= 0; } -->
<If Condition="ctrl_[nslot] &gt;= 0">
<Item>slots_[nslot]</Item>
<If Condition="_control()[nslot] &gt;= 0">
<Item>_slots()[nslot]</Item>
</If>
<Exec>nslot++</Exec>
<Break Condition="nslot == capacity_" />
<Break Condition="nslot == _capacity()" />
</Loop>
</CustomListItems>
</Expand>
</Type>

<!-- Primitive types stored as a value -->
<Type Name="absl::lts_20230802::container_internal::Storage&lt;*,*,0&gt;">
<DisplayString IncludeView="noparens">*($T1 *){value}</DisplayString>
<DisplayString ExcludeView="noparens">(*($T1 *){value})</DisplayString>
<Expand>
<ExpandedItem>*($T1 *){value}</ExpandedItem>
</Expand>
</Type>

<!-- For storage inherited from the type -->
<Type Name="absl::lts_20230802::container_internal::Storage&lt;*,*,1&gt;">
<DisplayString IncludeView="noparens">*($T1 *)this</DisplayString>
<DisplayString ExcludeView="noparens">(*($T1 *)this)</DisplayString>
<Expand>
<ExpandedItem>*($T1 *)this</ExpandedItem>
</Expand>
</Type>

<Type Name="absl::lts_20230802::container_internal::map_slot_type&lt;*&gt;">
<DisplayString>{{ {value.first}:{value.second} }}</DisplayString>
<DisplayString IncludeView="noparens">{value.first}, {value.second}</DisplayString>
<DisplayString ExcludeView="noparens">({value.first}, {value.second})</DisplayString>
<Expand>
<Item Name="[key]" ExcludeView="simple">value.first</Item>
<Item Name="[value]" ExcludeView="simple">value.second</Item>
<Item Name="first" ExcludeView="simple">value.first</Item>
<Item Name="second" ExcludeView="simple">value.second</Item>
</Expand>
</Type>
</AutoVisualizer>
Loading

0 comments on commit 955d1a8

Please sign in to comment.