quanto

Форк
0
/
test_mm.py 
29 строк · 1.3 Кб
1
# Copyright 2024 The HuggingFace Team. All rights reserved.
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
import pytest
16
import torch
17
from helpers import random_tensor
18

19

20
@pytest.mark.parametrize("input_shape", [[10, 32], [32, 32]])
21
@pytest.mark.parametrize("output_features", [48, 64])
22
@pytest.mark.parametrize("dtype", [torch.float16, torch.float32])
23
def test_dqmm(input_shape, output_features, dtype, device):
24
    input = random_tensor(input_shape, dtype=dtype).to(device)
25
    other = torch.randint(-127, 127, (input_shape[-1], output_features), dtype=torch.int8).to(device)
26
    other_scale = random_tensor((output_features,), dtype=dtype).to(device)
27
    output = torch.ops.quanto.dqmm(input, other, other_scale)
28
    expected = torch.ops.aten.mm(input, other * other_scale)
29
    assert torch.equal(expected, output)
30

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.