"tests/vscode:/vscode.git/clone" did not exist on "ead94d9383644234fa9f153a950ab8cdc334c588"
fx.py 734 Bytes
Newer Older
Jiaxu Zhu's avatar
Jiaxu Zhu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved


from typing import Tuple

import torch
from mobile_cv.common.misc.oss_utils import fb_overwritable


TORCH_VERSION: Tuple[int, ...] = tuple(int(x) for x in torch.__version__.split(".")[:2])
if TORCH_VERSION > (1, 10):
    from torch.ao.quantization.quantize_fx import convert_fx, prepare_fx, prepare_qat_fx
else:
    from torch.quantization.quantize_fx import convert_fx, prepare_fx, prepare_qat_fx


@fb_overwritable()
def get_prepare_fx_fn(cfg, is_qat):
    return prepare_qat_fx if is_qat else prepare_fx


@fb_overwritable()
24
def get_convert_fx_fn(cfg, example_inputs, qconfig_mapping=None, backend_config=None):
Jiaxu Zhu's avatar
Jiaxu Zhu committed
25
    return convert_fx