Skip to content

Commit

Permalink
Fixed TypeError in inner class
Browse files Browse the repository at this point in the history
  • Loading branch information
kaddu341 committed Feb 13, 2025
1 parent cd635b9 commit de6d0d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions torchtune/modules/position_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from typing import Any, Optional
from typing import Any, Optional, Union

import torch
from torch import nn
Expand Down Expand Up @@ -349,7 +349,7 @@ def __init__(self, dim_model: int, kdim: int, hidden_size: int) -> None:
)

# concave function to amplify differences among local positions
def phi(self, c: nn.Parameter, x: int | torch.Tensor) -> torch.Tensor:
def phi(self, c: nn.Parameter, x: Union[int, torch.Tensor]) -> torch.Tensor:
return torch.log1p(c * x)

def forward(self, src: torch.Tensor) -> torch.Tensor:
Expand Down

0 comments on commit de6d0d0

Please sign in to comment.