Skip to content

Commit

Permalink
Merge branch 'main' into yifanl/trt_ver_update_1
Browse files Browse the repository at this point in the history
  • Loading branch information
yf711 committed Oct 24, 2024
2 parents f796a62 + 3ae7c3c commit 903a2a8
Show file tree
Hide file tree
Showing 48 changed files with 695 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cffconvert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
validate:
name: "validate"
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- name: Check out a copy of the repository
uses: actions/checkout@v4
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
permissions:
actions: read
contents: read
Expand Down Expand Up @@ -55,6 +55,11 @@ jobs:
java-version: '11'
distribution: 'microsoft'

- if: ${{ matrix.language == 'javascript' }}
uses: actions/setup-node@v4
with:
node-version: 20

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- if: ${{ matrix.language != 'cpp' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on: [push, pull_request]
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:

jobs:
triage:
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: github/[email protected]
with:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
lint-python-format:
# Required workflow
name: Python format
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
Expand Down Expand Up @@ -114,9 +114,12 @@ jobs:

lint-js:
name: Lint JavaScript
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: reviewdog/action-eslint@v1
with:
reporter: github-pr-check
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux_training.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ concurrency:

jobs:
orttraining-linux-ci-pipeline:
runs-on: ubuntu-24.04
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- run: |
python3 -m pip install -r tools/ci_build/github/linux/python/requirements.txt
python3 -m pip install --user -r tools/ci_build/github/linux/python/requirements.txt
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
jobs:
auto-apply-fixes:
name: Suggest fixes
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
permissions:
contents: read
pull-requests: write
Expand All @@ -34,14 +34,13 @@ jobs:
with:
toolchain: stable
components: rustfmt
- name: Install dependencies
- name: Install dependencies and run lintrunner on all files
run: |
python -m pip install -r requirements-dev.txt
python -m pip install lintrunner lintrunner-adapters
export PATH=$HOME/.local/bin:$PATH
set -e
python -m pip install --user -r requirements-dev.txt
python -m pip install --user lintrunner lintrunner-adapters
lintrunner init
- name: Run lintrunner on all files
run: |
set +e
lintrunner f --all-files -v
exit 0
- uses: parkerbxyz/suggest-changes@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-c-apidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ permissions:
jobs:
build:
name: Generate C/C++ API docs
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v4
- name: Install doxygen and dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-csharp-apidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ permissions:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
env:
DOCFXVERSION: 2.62.2
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
placeholder:
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- name: Placeholder step to have workflow included in the GitHub web UI
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-java-apidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions:
jobs:
build:
name: Generate Java docs
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-js-apidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions:
jobs:
build:
name: Generate JS API docs
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-python-apidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ permissions:
jobs:
build:
name: Generate Python API docs
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: actions/checkout@v4
- name: Install tools
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/skip-doc-change.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
{%- for name in job_names %}
job{{ loop.index }}:
name: {{ name }}
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- run: 'echo "No build required, only documentation changed"'
{% endfor %}
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
close-stale-issues:
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
permissions:
issues: write
pull-requests: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/title-only-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:

jobs:
triage:
runs-on: ubuntu-latest
runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"]
steps:
- uses: github/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion js/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Refer to [ONNX Runtime JavaScript examples](https://github.com/microsoft/onnxrun

## Requirements

ONNXRuntime works on Node.js v16.x+ (recommend v18.x+) or Electron v15.x+ (recommend v28.x+).
ONNXRuntime works on Node.js v16.x+ (recommend v20.x+) or Electron v15.x+ (recommend v28.x+).

The following table lists the supported versions of ONNX Runtime Node.js binding provided with pre-built binaries.

Expand Down
4 changes: 4 additions & 0 deletions js/web/lib/wasm/jsep/backend-webgpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,10 @@ export class WebGpuBackend {
this.sessionStatus = 'default';
}

onCreateSession(): void {
this.gpuDataManager.onCreateSession();
}

onReleaseSession(sessionId: number): void {
this.unregisterBuffers(sessionId);
if (this.capturedCommandList.has(sessionId)) {
Expand Down
31 changes: 30 additions & 1 deletion js/web/lib/wasm/jsep/webgpu/gpu-data-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export interface GpuDataManager {
*/
dispose(): void;

/**
* create session related data.
*/
onCreateSession(): void;

/**
* release session related data.
* @param sessionId - specify the session ID.
Expand Down Expand Up @@ -200,6 +205,9 @@ class GpuDataManagerImpl implements GpuDataManager {
// a SessionID -> GPUBuffer[] mapping.
private capturedPendingBuffers: Map<number, GPUBuffer[]>;

// The session count.
private sessionCount: number;

constructor(private backend: WebGpuBackend) {
this.storageCache = new Map();
this.freeBuffers = new Map();
Expand All @@ -213,6 +221,8 @@ class GpuDataManagerImpl implements GpuDataManager {
this.freeBuffers.set(key, []);
this.freeUniformBuffers.set(key, []);
}

this.sessionCount = 0;
}

upload(id: GpuDataId, data: Uint8Array): void {
Expand Down Expand Up @@ -360,7 +370,12 @@ class GpuDataManagerImpl implements GpuDataManager {
release(id: GpuDataId): number {
const cachedData = this.storageCache.get(id);
if (!cachedData) {
throw new Error('releasing data does not exist');
if (this.storageCache.size === 0) {
// cache was previously cleared, no need to release anything.
return 0;
} else {
throw new Error('releasing data does not exist');
}
}

LOG_DEBUG('verbose', () => `[WebGPU] GpuDataManager.release(id=${id}), gpuDataId=${cachedData.gpuData.id}`);
Expand Down Expand Up @@ -460,6 +475,10 @@ class GpuDataManagerImpl implements GpuDataManager {
this.capturedPendingBuffers = new Map();
}

onCreateSession() {
this.sessionCount += 1;
}

onReleaseSession(sessionId: number) {
// release the captured pending buffers.
const pendingBuffers = this.capturedPendingBuffers.get(sessionId);
Expand All @@ -469,6 +488,16 @@ class GpuDataManagerImpl implements GpuDataManager {
});
this.capturedPendingBuffers.delete(sessionId);
}

// release the storage cache if no active sessions.
this.sessionCount -= 1;
if (this.sessionCount === 0) {
LOG_DEBUG('warning', () => '[WebGPU] Clearing webgpu buffer cache');
this.storageCache.forEach((storage) => {
storage.gpuData.buffer.destroy();
});
this.storageCache = new Map();
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions js/web/lib/wasm/wasm-core-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ export const createSession = async (
checkLastError("Can't create a session.");
}

wasm.jsepOnCreateSession?.();

// clear current MLContext after session creation
if (wasm.currentContext) {
wasm.jsepRegisterMLContext!(sessionHandle, wasm.currentContext);
Expand Down
6 changes: 6 additions & 0 deletions js/web/lib/wasm/wasm-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ export declare namespace JSEP {
* @param sessionId - specify the session ID.
*/
jsepOnRunStart: (sessionId: number) => void;
/**
* [exported from pre-jsep.js] Create a session. This function will be called after _OrtCreateSession() is
* called.
* @returns
*/
jsepOnCreateSession: () => void;
/**
* [exported from pre-jsep.js] Release a session. This function will be called before _OrtReleaseSession() is
* called.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ bool ExpandOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers
return false;
}

if (input_shape.empty()) {
LOGS(logger, VERBOSE) << "Expand does not support empty input's shape.";
return false;
}

std::vector<int64_t> output_shape;
if (!GetBidirectionalBroadcastShape(input_shape, new_shape, output_shape)) {
LOGS(logger, VERBOSE) << "The input cannot expand to shape " << GetShapeString(new_shape);
Expand Down
Loading

0 comments on commit 903a2a8

Please sign in to comment.