Create a tensor config from this one, keep policy and state unchanged. if there is an non-empty scale and offset, they will be cloned too.
(self)
| 863 | self._channel_axis = channel_axis |
| 864 | |
| 865 | def copy(self): |
| 866 | """Create a tensor config from this one, keep policy and state |
| 867 | unchanged. |
| 868 | |
| 869 | if there is an non-empty scale and offset, they will be cloned too. |
| 870 | """ |
| 871 | scale, offset = None, None |
| 872 | if self.scale is not None: |
| 873 | if isinstance(self.scale, torch.Tensor): |
| 874 | scale = self.scale.clone() |
| 875 | else: scale = self.scale |
| 876 | if self.offset is not None: |
| 877 | if isinstance(self.offset, torch.Tensor): |
| 878 | offset = self.offset.clone() |
| 879 | else: offset = self.offset |
| 880 | config = TensorQuantizationConfig( |
| 881 | policy=self.policy, |
| 882 | rounding=self.rounding, |
| 883 | num_of_bits=self.num_of_bits, |
| 884 | quant_min=self.quant_min, |
| 885 | quant_max=self.quant_max, |
| 886 | scale=scale, offset=offset, |
| 887 | observer_algorithm=self.observer_algorithm, |
| 888 | detail=self.detail.copy(), |
| 889 | state=self.state, |
| 890 | exponent_bits=self.exponent_bits, |
| 891 | channel_axis=self.channel_axis, |
| 892 | visibility=self.visibility |
| 893 | ) |
| 894 | if self.state == QuantizationStates.OVERLAPPED: |
| 895 | config._dominator = self._dominator |
| 896 | return config |
| 897 | |
| 898 | |
| 899 | class ChannelwiseTensorQuantizationConfig(TensorQuantizationConfig): |
no test coverage detected