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

Add GroupNorm support #132

Closed
FL33TW00D opened this issue Mar 22, 2024 · 5 comments · Fixed by #192
Closed

Add GroupNorm support #132

FL33TW00D opened this issue Mar 22, 2024 · 5 comments · Fixed by #192
Labels
help wanted Extra attention is needed

Comments

@FL33TW00D
Copy link
Collaborator

#131 requires GroupNorm support

@FL33TW00D FL33TW00D added the help wanted Extra attention is needed label Mar 22, 2024
@AmineDiro
Copy link

Hi @FL33TW00D I'd like to take a swing at implementing this layer. GroupNorm can be seen as a generalization of LayerNorm but it differs in implementation enough that I think we can add it to the enum and reimplement the kernel

pub enum Norm {
    LayerNorm(LayerNorm),
   GroupNorm(GroupNorm),
}

Quick question, is there a reason for specializing the LayerNorm for vec2 and vec4 separatly?

@FL33TW00D
Copy link
Collaborator Author

@AmineDiro

Enum sounds good!

In WebGPU you can often get big performance boosts from vectorizing, vec2 isn't much of a difference but vec4 can be considerable. Even just a scalar kernel is great!

@AmineDiro
Copy link

Hello, Finally found time to look at the implementation of GroupNorm. If I am not mistaken I think that we have everything in thenorm.rs but I need to check if I am not missing something. For a given tensor of shape B,C, IMG_SIZE applying a groupnorm of num_groups is equivalent to applying LayerNorm on the tensor as B,n_groups, n_channels*IMG_SIZE . Is this coherent with the memory layout of ratchet ?

@FL33TW00D
Copy link
Collaborator Author

Hey @AmineDiro,
Ratchet memory layout is the following:

  1. All buffers are contiguous
  2. All are laid out 1D row major

Everything else is syntax sugar!

@AmineDiro
Copy link

Great so I think it should work! I'll try to push something as soon as possible !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants