From dfb739c89a9045b9906f347a911fe3dc94440baa Mon Sep 17 00:00:00 2001 From: Dilshod Tadjibaev <939125+antimora@users.noreply.github.com> Date: Thu, 15 Feb 2024 10:39:06 -0600 Subject: [PATCH] Rename GELU to Gelu (#1311) * Rename GELU to Gelu This is to follow Rust naming convention --- README.md | 2 +- burn-book/src/building-blocks/module.md | 4 ++-- burn-core/src/nn/attention/mha.rs | 6 +++--- burn-core/src/nn/gelu.rs | 4 ++-- burn-core/src/nn/transformer/pwff.rs | 8 ++++---- burn-no-std-tests/src/conv.rs | 4 ++-- examples/mnist-inference-web/README.md | 8 ++++---- examples/mnist-inference-web/src/model.rs | 8 ++++---- examples/mnist/src/model.rs | 8 ++++---- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index e8edbaa66a..6da4ec9a2c 100644 --- a/README.md +++ b/README.md @@ -508,7 +508,7 @@ pub struct PositionWiseFeedForward { linear_inner: nn::Linear, linear_outer: nn::Linear, dropout: nn::Dropout, - gelu: nn::GELU, + gelu: nn::Gelu, } impl PositionWiseFeedForward { diff --git a/burn-book/src/building-blocks/module.md b/burn-book/src/building-blocks/module.md index cb5d9cf5ef..1a95813f1e 100644 --- a/burn-book/src/building-blocks/module.md +++ b/burn-book/src/building-blocks/module.md @@ -14,7 +14,7 @@ pub struct PositionWiseFeedForward { linear_inner: Linear, linear_outer: Linear, dropout: Dropout, - gelu: GELU, + gelu: Gelu, } impl PositionWiseFeedForward { @@ -113,7 +113,7 @@ Burn comes with built-in modules that you can use to build your own modules. | `LayerNorm` | `nn.LayerNorm` | | `GroupNorm` | `nn.GroupNorm` | | `Dropout` | `nn.Dropout` | -| `GELU` | `nn.GELU` | +| `Gelu` | `nn.Gelu` | | `Linear` | `nn.Linear` | | `Embedding` | `nn.Embedding` | | `Relu` | `nn.ReLU` | diff --git a/burn-core/src/nn/attention/mha.rs b/burn-core/src/nn/attention/mha.rs index 1ad3679366..28840ea3f9 100644 --- a/burn-core/src/nn/attention/mha.rs +++ b/burn-core/src/nn/attention/mha.rs @@ -55,7 +55,7 @@ pub struct MultiHeadAttention { value: nn::Linear, output: nn::Linear, dropout: nn::Dropout, - activation: nn::GELU, + activation: nn::Gelu, n_heads: usize, d_k: usize, min_float: f64, @@ -87,7 +87,7 @@ impl MultiHeadAttentionConfig { value: linear(self), output: linear(self), dropout: nn::DropoutConfig::new(self.dropout).init(), - activation: nn::GELU::new(), + activation: nn::Gelu::new(), n_heads: self.n_heads, d_k: self.d_model / self.n_heads, min_float: self.min_float, @@ -111,7 +111,7 @@ impl MultiHeadAttentionConfig { value: linear(self, record.value), output: linear(self, record.output), dropout: nn::DropoutConfig::new(self.dropout).init(), - activation: nn::GELU::new(), + activation: nn::Gelu::new(), n_heads: self.n_heads, d_k: self.d_model / self.n_heads, min_float: self.min_float, diff --git a/burn-core/src/nn/gelu.rs b/burn-core/src/nn/gelu.rs index 020b6e5ee0..37a395e37e 100644 --- a/burn-core/src/nn/gelu.rs +++ b/burn-core/src/nn/gelu.rs @@ -6,9 +6,9 @@ use crate::tensor::Tensor; /// Applies the Gaussian Error Linear Units function element-wise. #[derive(Module, Clone, Debug, Default)] -pub struct GELU {} +pub struct Gelu {} -impl GELU { +impl Gelu { /// Create the module. pub fn new() -> Self { Self {} diff --git a/burn-core/src/nn/transformer/pwff.rs b/burn-core/src/nn/transformer/pwff.rs index d72c3127e6..996d6c6202 100644 --- a/burn-core/src/nn/transformer/pwff.rs +++ b/burn-core/src/nn/transformer/pwff.rs @@ -4,7 +4,7 @@ use crate::nn::Initializer; use crate::{ config::Config, module::Module, - nn::{Dropout, DropoutConfig, Linear, LinearConfig, GELU}, + nn::{Dropout, DropoutConfig, Gelu, Linear, LinearConfig}, tensor::{backend::Backend, Tensor}, }; @@ -36,7 +36,7 @@ pub struct PositionWiseFeedForward { linear_inner: Linear, linear_outer: Linear, dropout: Dropout, - gelu: GELU, + gelu: Gelu, } impl PositionWiseFeedForwardConfig { @@ -50,7 +50,7 @@ impl PositionWiseFeedForwardConfig { .with_initializer(self.initializer.clone()) .init(device), dropout: DropoutConfig::new(self.dropout).init(), - gelu: GELU::new(), + gelu: Gelu::new(), } } /// Initialize a new [position-wise feed-forward](PositionWiseFeedForward) module with a @@ -63,7 +63,7 @@ impl PositionWiseFeedForwardConfig { linear_inner: LinearConfig::new(self.d_model, self.d_ff).init_with(record.linear_inner), linear_outer: LinearConfig::new(self.d_ff, self.d_model).init_with(record.linear_outer), dropout: DropoutConfig::new(self.dropout).init(), - gelu: GELU::new(), + gelu: Gelu::new(), } } } diff --git a/burn-no-std-tests/src/conv.rs b/burn-no-std-tests/src/conv.rs index 60db5b412e..191d595056 100644 --- a/burn-no-std-tests/src/conv.rs +++ b/burn-no-std-tests/src/conv.rs @@ -11,7 +11,7 @@ use burn::{ pub struct ConvBlock { conv: nn::conv::Conv2d, pool: nn::pool::MaxPool2d, - activation: nn::GELU, + activation: nn::Gelu, } #[derive(Config)] @@ -29,7 +29,7 @@ impl ConvBlock { let pool = nn::pool::MaxPool2dConfig::new(config.kernel_size) .with_padding(nn::PaddingConfig2d::Same) .init(); - let activation = nn::GELU::new(); + let activation = nn::Gelu::new(); Self { conv, diff --git a/examples/mnist-inference-web/README.md b/examples/mnist-inference-web/README.md index 943507fbb3..6785f03a24 100644 --- a/examples/mnist-inference-web/README.md +++ b/examples/mnist-inference-web/README.md @@ -44,10 +44,10 @@ values. Layers: 1. Input Image (28,28, 1ch) -2. `Conv2d`(3x3, 8ch), `BatchNorm2d`, `GELU` -3. `Conv2d`(3x3, 16ch), `BatchNorm2d`, `GELU` -4. `Conv2d`(3x3, 24ch), `BatchNorm2d`, `GELU` -5. `Linear`(11616, 32), `GELU` +2. `Conv2d`(3x3, 8ch), `BatchNorm2d`, `Gelu` +3. `Conv2d`(3x3, 16ch), `BatchNorm2d`, `Gelu` +4. `Conv2d`(3x3, 24ch), `BatchNorm2d`, `Gelu` +5. `Linear`(11616, 32), `Gelu` 6. `Linear`(32, 10) 7. Softmax Output diff --git a/examples/mnist-inference-web/src/model.rs b/examples/mnist-inference-web/src/model.rs index b48c8c2ddf..4993560342 100644 --- a/examples/mnist-inference-web/src/model.rs +++ b/examples/mnist-inference-web/src/model.rs @@ -16,7 +16,7 @@ pub struct Model { dropout: nn::Dropout, fc1: nn::Linear, fc2: nn::Linear, - activation: nn::GELU, + activation: nn::Gelu, } const NUM_CLASSES: usize = 10; @@ -43,7 +43,7 @@ impl Model { fc1, fc2, dropout, - activation: nn::GELU::new(), + activation: nn::Gelu::new(), } } @@ -70,7 +70,7 @@ impl Model { pub struct ConvBlock { conv: nn::conv::Conv2d, norm: BatchNorm, - activation: nn::GELU, + activation: nn::Gelu, } impl ConvBlock { @@ -83,7 +83,7 @@ impl ConvBlock { Self { conv, norm, - activation: nn::GELU::new(), + activation: nn::Gelu::new(), } } diff --git a/examples/mnist/src/model.rs b/examples/mnist/src/model.rs index e63d528d3f..ff254d4bc1 100644 --- a/examples/mnist/src/model.rs +++ b/examples/mnist/src/model.rs @@ -17,7 +17,7 @@ pub struct Model { dropout: nn::Dropout, fc1: nn::Linear, fc2: nn::Linear, - activation: nn::GELU, + activation: nn::Gelu, } impl Default for Model { @@ -51,7 +51,7 @@ impl Model { dropout, fc1, fc2, - activation: nn::GELU::new(), + activation: nn::Gelu::new(), } } @@ -92,7 +92,7 @@ impl Model { pub struct ConvBlock { conv: nn::conv::Conv2d, norm: BatchNorm, - activation: nn::GELU, + activation: nn::Gelu, } impl ConvBlock { @@ -105,7 +105,7 @@ impl ConvBlock { Self { conv, norm, - activation: nn::GELU::new(), + activation: nn::Gelu::new(), } }