Skip to content

Commit

Permalink
Feat (core): simplify binary_sign impl (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
volcacius authored Jul 17, 2023
1 parent 32fba9e commit 2622a2b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/brevitas/function/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def binary_sign(x: Tensor) -> Tensor:
tensor([ 1., -1., 1.])
"""
positive_mask = torch.ge(x, 0.0)
negative_mask = torch.lt(x, 0.0)
y = positive_mask.to(x.dtype) - negative_mask.to(x.dtype)
y = positive_mask.to(x.dtype) * 2. - 1.
return y


Expand Down

0 comments on commit 2622a2b

Please sign in to comment.