Skip to content

Commit

Permalink
Revert "[BUG] Fix bug in cast in quantization (#480)"
Browse files Browse the repository at this point in the history
This reverts commit 04332b7.
  • Loading branch information
vadiklyutiy committed Dec 21, 2024
1 parent 087f057 commit 89618ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions python/hidet/graph/ops/quant/symmetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# limitations under the License.
from typing import Union, List
from hidet import ir
from hidet.ir.type import DataType, int32
from hidet.ir.type import DataType
from hidet.ir.expr import cast, if_then_else
from hidet.ir.compute.primitives import TensorNode, compute
from hidet.ir import primitives as prim
Expand All @@ -36,9 +36,7 @@ def __init__(self, w: TensorNode, quant_type: DataType, dims: Union[int, List[in

def scale_weight(*indices):
scale_indices = [indices[i] for i in range(len(indices)) if not i in dims]
# Have to cast to int32 first because there are several ways convert bf16 to int8
cast_to_int = cast(prim.round(w[indices] / scale[scale_indices]), int32)
return cast(cast_to_int, quant_type)
return cast(prim.round(w[indices] / scale[scale_indices]), quant_type)

wq = compute(name='quantize', shape=w.shape, fcompute=scale_weight)
super().__init__(
Expand Down
1 change: 1 addition & 0 deletions python/hidet/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = "0.5.0"

0 comments on commit 89618ef

Please sign in to comment.