Skip to content

Commit

Permalink
default
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 committed Oct 7, 2024
1 parent b67fed4 commit 0eb2ec2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/brevitas/core/scaling/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ def __init__(
scaling_init = scaling_init.to(device=device, dtype=dtype)
if restrict_scaling_impl is not None:
scaling_init = restrict_scaling_impl.restrict_init_tensor(scaling_init)
else:
self.restrict_init_module = Identity()
self.value = StatelessBuffer(scaling_init.detach())
else:
if restrict_scaling_impl is not None:
scaling_init = restrict_scaling_impl.restrict_init_float(scaling_init)
self.restrict_init_module = restrict_scaling_impl.restrict_init_module()
else:
self.restrict_init_module = Identity()
self.value = StatelessBuffer(torch.tensor(scaling_init, dtype=dtype, device=device))

@brevitas.jit.script_method
Expand Down Expand Up @@ -149,6 +154,8 @@ def __init__(
if restrict_scaling_impl is not None:
scaling_init = restrict_scaling_impl.restrict_init_tensor(scaling_init)
self.restrict_init_module = restrict_scaling_impl.restrict_init_module()
else:
self.restrict_init_module = Identity()
if scaling_init.shape == SCALAR_SHAPE and scaling_shape is not None:
scaling_init = torch.full(scaling_shape, scaling_init, dtype=dtype, device=device)
self.value = Parameter(scaling_init)
Expand Down

0 comments on commit 0eb2ec2

Please sign in to comment.