-
Notifications
You must be signed in to change notification settings - Fork 531
/
Copy path__init__.py
51 lines (41 loc) · 1.88 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# pyre-unsafe
from dataclasses import dataclass
from enum import Enum
class QuantType(Enum):
NONE = 1
# Used for Operations that don't have weights
STATIC_PER_TENSOR = 2
# Used best for CNN/RNN Models with Conv layers
STATIC_PER_CHANNEL = 3
# Used for Linear Layers and Transformer Based Models
DYNAMIC_PER_CHANNEL = 4
@dataclass
class XNNPACKOptions(object):
quantization: QuantType
delegation: bool
MODEL_NAME_TO_OPTIONS = {
"linear": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"add": XNNPACKOptions(QuantType.STATIC_PER_TENSOR, True),
"add_mul": XNNPACKOptions(QuantType.STATIC_PER_TENSOR, True),
"dl3": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"ic3": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"ic4": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"mv2": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"mv3": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"resnet18": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"resnet50": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"vit": XNNPACKOptions(QuantType.DYNAMIC_PER_CHANNEL, True),
"w2l": XNNPACKOptions(QuantType.DYNAMIC_PER_CHANNEL, True),
"edsr": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
"mobilebert": XNNPACKOptions(QuantType.DYNAMIC_PER_CHANNEL, True),
"llama2": XNNPACKOptions(QuantType.DYNAMIC_PER_CHANNEL, True),
"emformer_join": XNNPACKOptions(QuantType.DYNAMIC_PER_CHANNEL, True),
"emformer_predict": XNNPACKOptions(QuantType.DYNAMIC_PER_CHANNEL, True),
"emformer_transcribe": XNNPACKOptions(QuantType.STATIC_PER_CHANNEL, True),
}
__all__ = [MODEL_NAME_TO_OPTIONS]