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

pruning #6

Open
starsky68 opened this issue Nov 11, 2021 · 0 comments
Open

pruning #6

starsky68 opened this issue Nov 11, 2021 · 0 comments

Comments

@starsky68
Copy link

starsky68 commented Nov 11, 2021

class ChooseTopEdges(autograd.Function):
""" Chooses the top edges for the forwards pass but allows gradient flow to all edges in the backwards pass"""

@staticmethod
def forward(ctx, weight, prune_rate):
    output = weight.clone()
    _, idx = weight.flatten().abs().sort()
    p = int(prune_rate * weight.numel())
    flat_oup = output.flatten()
    flat_oup[idx[:p]] = 0
    return output

@staticmethod
def backward(ctx, grad_output):
    return grad_output, None, None

Excuse me, although flat_oup is pruned because the element is set to zero, the return in forward is output. Does this play the role of pruning? @dirkgr @schmmd @iellenberger @danyaljj @danyaljj @MLatzke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant