示例#1
0
 def forward(self, x: Tensor) -> Tuple[Tensor, Tensor, Tensor]:
     scale = self.scaling_impl(x)
     y = binary_sign_ste(x) * scale
     y = self.delay_wrapper(x, y)
     return y, scale, self.bit_width()
示例#2
0
 def forward(self, x: Tensor) -> Tuple[Tensor, Tensor, Tensor]:
     scale = self.scaling_impl(x)
     y = tensor_clamp(x, - scale, scale)
     y = binary_sign_ste(y) * scale
     return y, scale, self.bit_width()
示例#3
0
文件: quant.py 项目: xrick/brevitas
 def forward(self, x: Tensor, zero_hw_sentinel: Tensor) -> Tuple[Tensor, Tensor, Tensor]:
     scale = self.scaling_impl(zero_hw_sentinel)
     y = tensor_clamp(x, - scale, scale)
     y = binary_sign_ste(y) * scale
     return y, scale, zero_hw_sentinel + self.bit_width
示例#4
0
 def forward(self, x: Tensor) -> Tuple[Tensor, Tensor, Tensor, Tensor]:
     scale = self.scaling_impl(x)
     y = self.tensor_clamp_impl(x, - scale, scale)
     y = binary_sign_ste(y) * scale
     y = self.delay_wrapper(x, y)
     return y, scale, self.zero_point(), self.bit_width()