question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

major difference in performance between sync and async methods to download tensor data

See original GitHub issue

when using webgl backend, tensor.dataSync() is about 35% faster than await tensor.data() when returning larger amounts of data
(in my case, model takes 720x720x3 image as input and produces 720x720x3 image as output)

actual timings are ~100ms for tensor.dataSync() and ~140ms for await tensor.data()
note that there is nothing else executing, this is a single active loop

i wouldn’t mind using dataSync(), but then again any sync calls are not compatible with webgpu backend and maintaining two separate codepaths for webgl and webgpu is a no-op

btw, model in question can be found at https://github.com/vladmandic/anime

environment: tfjs 3.19…0 on chrome 103

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:37 (24 by maintainers)

github_iconTop GitHub Comments

2reactions
vladmandiccommented, Sep 13, 2022

@mattsoulanille @gyagp i just created emscripten issue for this as this is really something that should be patched there - imo anything you do here is just a workaround to avoid bad emscripten behavior

0reactions
google-ml-butler[bot]commented, Sep 27, 2022

Are you satisfied with the resolution of your issue? Yes No

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sync vs. Async Python: What is the Difference?
For most applications, I do not believe the performance difference between sync and async context switches amount to anything significant.
Read more >
Better performance with the tf.data API | TensorFlow Core
However, in a naive synchronous implementation like here, while your pipeline is fetching the data, your model is sitting idle. Conversely, while your...
Read more >
Advanced API Performance: Async Compute and Overlap
This post covers best practices for async compute and overlap on NVIDIA GPUs. To get a high and consistent frame rate in your...
Read more >
Asynchronous vs synchronous execution. What is the ...
So an asynchronous task is not co-coordinated with other tasks, whereas a synchronous task IS co-coordinated with other tasks, so one finishes before...
Read more >
Sync, async, and promises | Cloud Functions for Firebase
// set() returns a promise. We keep the function alive by returning it. return event.data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found