Coverage for / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / components / quantization / tensor / base.py: 60%
10 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-25 05:45 +0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-25 05:45 +0800
1# Copyright 2026 Huawei Technologies Co., Ltd
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ============================================================================
15"""Storage contract for typed low-precision tensors."""
17from typing import Any
20class QuantizedTensorStorage:
21 """Describe the physical storage owned by a quantized tensor format."""
23 def update_usage(self, rowwise: bool = True, colwise: bool = True) -> None:
24 """Release directional representations that are no longer required."""
26 raise NotImplementedError(
27 f"{type(self).__name__} does not implement update_usage()."
28 )
30 def is_rowwise(self) -> bool:
31 """Return whether row-wise quantized data is available."""
33 raise NotImplementedError(
34 f"{type(self).__name__} does not implement is_rowwise()."
35 )
37 def is_colwise(self) -> bool:
38 """Return whether column-wise quantized data is available."""
40 raise NotImplementedError(
41 f"{type(self).__name__} does not implement is_colwise()."
42 )
44 def get_metadata(self) -> dict[str, Any]:
45 """Return the data needed to rebuild the quantized tensor."""
47 raise NotImplementedError(
48 f"{type(self).__name__} does not implement get_metadata()."
49 )