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

Optimization: Cash kernels and move creation to correct device #227

Open
zakajd opened this issue Feb 4, 2021 · 1 comment
Open

Optimization: Cash kernels and move creation to correct device #227

zakajd opened this issue Feb 4, 2021 · 1 comment
Labels
enhancement Making some part of the codebase better without introduction of new features feature New feature or request

Comments

@zakajd
Copy link
Collaborator

zakajd commented Feb 4, 2021

Is your feature request related to a problem? Please describe.
Most metrics use some kind of kernels for extraction of image features.
Now those kernels are created each time when metric is called. That's slow and redundant when the function is called hundreds of times.

Another problem related to performance is creation of temporal tensors first on CPU and later moving them to GPU if needed (.to(x.device)).

Describe the solution you'd like

  1. Add support for cashing kernels between runs. Add kernel param to functional API. Create and store kernel in class API
  2. Replace .to(x.device) and simmular calls to explicit creation of tensor on target device. Like torch.ones(N, N, device=x.device).

Additional context
For metrics that use more than one kernel implementation details can be discussed.

@zakajd zakajd added feature New feature or request enhancement Making some part of the codebase better without introduction of new features labels Feb 4, 2021
@denproc denproc self-assigned this Feb 5, 2023
@denproc denproc linked a pull request Feb 5, 2023 that will close this issue
@denproc denproc removed a link to a pull request Feb 5, 2023
@denproc denproc removed their assignment Feb 5, 2023
@denproc
Copy link
Collaborator

denproc commented Feb 5, 2023

Hi @zakajd,

The second part of the proposed solution is partially implemented in #334.

While the proposed changes cover the tensor creation related to filters and colour conversions, some parts of the library could still use .to (piq/base.py, fid.py, perceptual.py, pieapp.py and piq/functional/resize.py).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Making some part of the codebase better without introduction of new features feature New feature or request
2 participants