Skip to content
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

[js/webgpu] allow to specify callback for profiling data #17820

Closed
wants to merge 5 commits into from

Conversation

fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Oct 6, 2023

Description

allow to specify callback for profiling data

Previous:

ort.env.webgpu.profilingMode = 'default';  // enable profiling

// profiling data will output to console.

Now:

ort.env.webgpu.profiling = {
  mode: 'default';  // enable profiling
  ondata: (data) => {
    // .. process the profiling data
  }
};

//for each kernel, "ondata" will be called once. only output to console if ondata is not specified.

// eslint-disable-next-line no-console
console.log(`[profiling] kernel "${kernelId}|${kernelName}" ${inputShapes}${outputShapes}execution time: ${
endTime - startTime} ns`);
if (this.backend.env.webgpu.profiling?.ondata) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default startTime is always 0. And any use case for profilingTimeBase?

       if (typeof this.backend.profilingTimeBase === 'undefined') {
          this.backend.profilingTimeBase = startTimeU64;
        }
        const startTime = Number(startTimeU64 - this.backend.profilingTimeBase);
        const endTime = Number(endTimeU64 - this.backend.profilingTimeBase);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backend.profilingTimeBase is designed to log the time of the start time of the first completed kernel (startTime64). By using this, the startTime and endTime can be relatively small to fit into int53.

guschmue
guschmue previously approved these changes Oct 11, 2023
@fs-eire
Copy link
Contributor Author

fs-eire commented Dec 6, 2023

Close this one. Use #18732 instead.

The reason why I create a new PR is because somehow the check "license/cla" is not triggered for this PR and seems there is no way to manually trigger it unless create a new PR.

@fs-eire fs-eire closed this Dec 6, 2023
fs-eire added a commit that referenced this pull request Dec 7, 2023
### Description

**This PR is a replacement of #17820.**

allow to specify callback for profiling data

*Previous*:
```js
ort.env.webgpu.profilingMode = 'default';  // enable profiling

// profiling data will output to console.
```

*Now*:
```js
ort.env.webgpu.profiling = {
  mode: 'default';  // enable profiling
  ondata: (data) => {
    // .. process the profiling data
  }
};

//for each kernel, "ondata" will be called once. only output to console if ondata is not specified.
```
siweic0 pushed a commit to siweic0/onnxruntime-web that referenced this pull request May 9, 2024
…8732)

### Description

**This PR is a replacement of microsoft#17820.**

allow to specify callback for profiling data

*Previous*:
```js
ort.env.webgpu.profilingMode = 'default';  // enable profiling

// profiling data will output to console.
```

*Now*:
```js
ort.env.webgpu.profiling = {
  mode: 'default';  // enable profiling
  ondata: (data) => {
    // .. process the profiling data
  }
};

//for each kernel, "ondata" will be called once. only output to console if ondata is not specified.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants