Skip to content

[Feature Request] nn.Module should also get a device attribute #7460

@nehz

Description

@nehz

Similar to the changes for tensors in 0.4, Modules should also get a .device attribute to allow easy creation of correct tensors.

Use case:

class Net(Module):
    def forward(self, x):
        x = x.to(self.device)

net = Net().cuda()
net.forward(Tensor([1]))   # Don't need conditional or additional .to()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions