-
Notifications
You must be signed in to change notification settings - Fork 54
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
Adding functional batch_norm to BatchNorm2d substitution #868
Conversation
..._compression_toolkit/core/pytorch/graph_substitutions/substitutions/functional_batch_norm.py
Outdated
Show resolved
Hide resolved
..._compression_toolkit/core/pytorch/graph_substitutions/substitutions/functional_batch_norm.py
Outdated
Show resolved
Hide resolved
..._compression_toolkit/core/pytorch/graph_substitutions/substitutions/functional_batch_norm.py
Outdated
Show resolved
Hide resolved
Also link this PR to the open issue |
..._compression_toolkit/core/pytorch/graph_substitutions/substitutions/functional_batch_norm.py
Outdated
Show resolved
Hide resolved
..._compression_toolkit/core/pytorch/graph_substitutions/substitutions/functional_batch_norm.py
Outdated
Show resolved
Hide resolved
|
||
def get_attributes_from_inputs(self, graph: Graph, node: BaseNode) -> dict: | ||
input_nodes = graph.get_prev_nodes(node) | ||
if len(input_nodes) == 5: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure len(input_nodes) == 4 isn't an option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's and error if "else"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that. I meant that it's not an option in torch. for example if it is craeted like this:
torch.nn.functional.batch_norm(input, running_mean, running_var, weight=weight, bias=None
the bias is still created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if weight\bias = None is doesn't create the input node
..._compression_toolkit/core/pytorch/graph_substitutions/substitutions/functional_batch_norm.py
Outdated
Show resolved
Hide resolved
..._compression_toolkit/core/pytorch/graph_substitutions/substitutions/functional_batch_norm.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See leftover comments
|
||
def get_attributes_from_inputs(self, graph: Graph, node: BaseNode) -> dict: | ||
input_nodes = graph.get_prev_nodes(node) | ||
if len(input_nodes) == 5: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that. I meant that it's not an option in torch. for example if it is craeted like this:
torch.nn.functional.batch_norm(input, running_mean, running_var, weight=weight, bias=None
the bias is still created
|
||
def batch_norm_wrapper(channels): | ||
return partial(nn.functional.batch_norm, | ||
running_mean=torch.zeros(channels, device='cuda'), | ||
running_var=torch.ones(channels, device='cuda')) | ||
running_mean=0+torch.randn(channels, device='cuda'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll probably need to select the device accordingly, because tests are ran on CPU in github
Pull Request Description:
Checklist before requesting a review: