[Feat] Improve device switching for transforms
See original GitHub issue🚀 Feature
Improve device switching for transforms
Motivation
Currently tensors are stored as is within transforms (I’m using kornia.Rotate
as example here, but this same is valid for many other transforms). This, makes the switching between devices inconvenient, since torch.nn.Module.to()
does not affect them:
import torch
import kornia
angle = torch.tensor(30.0).view(1, -1)
transform = kornia.Rotate(angle)
print(transform.angle.device)
transform = transform.to("cuda")
print(transform.angle.device)
cpu
cpu
Pitch
Register all tensors as buffers:
from torch import nn
class RotateMock(nn.Module):
def __init__(self, angle: torch.Tensor) -> None:
super().__init__()
self.register_buffer("angle", angle)
transform = RotateMock(angle)
print(transform.angle.device)
transform = transform.to("cuda")
print(transform.angle.device)
cpu
cuda:0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
arXiv:2101.03961v3 [cs.LG] 16 Jun 2022
These models improve the pre-training speed of a strongly tuned T5-XXL baseline by. 4x. 2. Switch Transformer. The guiding design principle for ...
Read more >Impedance Matching Devices - Mini-Circuits Blog
Explore impedance matching techniques and understand the differences between the various types of impedance matching devices, ...
Read more >A Review of Resistive Switching Devices: Performance ...
A brief introduction to the RS mechanisms and materials is provided, followed by a detailed discussion of the performance improvement methods ...
Read more >Bandwidth Improvement of MMIC Single-Pole-Double-Throw ...
In this paper, we propose a new configuration for improving the isolation bandwidth of MMIC single-pole-double-throw (SPDT) passive high-electron-mobility ...
Read more >Advances of RRAM Devices: Resistive Switching Mechanisms ...
With the transformation of resistance states, RRAM devices can complete the data storage process based on '0' or '1'.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nope. I’ll see if I have time this week to send a PR. Otherwise I’ll get back to you.
It shall be enough.