Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support multiple inheritance in torch.distributions#16772

Closed
fritzo wants to merge 1 commit into
pytorch:masterfrom
probtorch:dist-multiple-inheritance
Closed

Support multiple inheritance in torch.distributions#16772
fritzo wants to merge 1 commit into
pytorch:masterfrom
probtorch:dist-multiple-inheritance

Conversation

@fritzo
Copy link
Copy Markdown
Collaborator

@fritzo fritzo commented Feb 5, 2019

This adds calls to super().__init__() in three classes in torch.distributions.

This is needed when Distribution and Transform objects are used with multiple inheritance, as e.g. combined with torch.nn.Modules. For example

class MyModule(torch.distributions.Transform, torch.nn.Module):
    ...

cc @martinjankowiak @esling who have wanted to use this pattern, e.g. in #16756

@fritzo
Copy link
Copy Markdown
Collaborator Author

fritzo commented Feb 5, 2019

cc @apaszke

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@soumith is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
This adds calls to `super().__init__()` in three classes in torch.distributions.

This is needed when `Distribution` and `Transform` objects are used with multiple inheritance, as e.g. combined with `torch.nn.Module`s. For example
```py
class MyModule(torch.distributions.Transform, torch.nn.Module):
    ...
```
cc  martinjankowiak esling who have wanted to use this pattern, e.g. in pytorch#16756
Pull Request resolved: pytorch#16772

Differential Revision: D13978633

Pulled By: soumith

fbshipit-source-id: 8bc6cca1747cd74d32135ee2fe588bba2ea796f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants