Skip to content

Commit 5025173

Browse files
committed
Update base for Update on "qnn end to end flow"
Patch a few changes including: - support bool tensor type - support fp16 and fix the 8w8a quantization. - add two non-supported ops (slice_scatter and index_put) in common_defs.py stories model working end to end: AOT: fp16: ``` python -m examples.models.llama2.export_llama -kv --qnn -c stories110M.pt -p params.json ``` quantize: ``` python -m examples.models.llama2.export_llama -kv --qnn --pt2e_quantize -c stories110M.pt -p params.json ``` Runtime: ``` /llama_main --model_path=llama2_fp16_qnn_2.21.pte --tokenizer_path=tokenizer.bin --prompt="Once" ``` Output: ``` Once upon a time, there was a boy named Tim. Tim had a pet dog named Max. Max was a big, strong dog. They liked to play and run in the park. One day, Tim and Max went to the park to play. They saw a cat. The cat was up in a tree. Max wanted to help the cat. He tried to climb the tree, but he could not. Then, something unexpected happened. Max started to climb the tree! He was very strong. Max helped the cat come down. The cat was happy. Tim was so proud of his pet. ``` Stories model is too small and sensitive to qunatization. Differential Revision: [D56119738](https://our.internmc.facebook.com/intern/diff/D56119738/) [ghstack-poisoned]
2 parents ae9227e + 075fe40 commit 5025173

File tree

76 files changed

+1211
-672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1211
-672
lines changed

.clang-format

Lines changed: 116 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,55 @@
22
Language: Cpp
33
AccessModifierOffset: -1
44
AlignAfterOpenBracket: AlwaysBreak
5-
AlignConsecutiveMacros: None
6-
AlignConsecutiveAssignments: None
7-
AlignConsecutiveBitFields: None
8-
AlignConsecutiveDeclarations: None
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments:
7+
Enabled: false
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionPointers: false
12+
PadOperators: true
13+
AlignConsecutiveBitFields:
14+
Enabled: false
15+
AcrossEmptyLines: false
16+
AcrossComments: false
17+
AlignCompound: false
18+
AlignFunctionPointers: false
19+
PadOperators: true
20+
AlignConsecutiveDeclarations:
21+
Enabled: false
22+
AcrossEmptyLines: false
23+
AcrossComments: false
24+
AlignCompound: false
25+
AlignFunctionPointers: false
26+
PadOperators: true
27+
AlignConsecutiveMacros:
28+
Enabled: false
29+
AcrossEmptyLines: false
30+
AcrossComments: false
31+
AlignCompound: false
32+
AlignFunctionPointers: false
33+
PadOperators: true
34+
AlignConsecutiveShortCaseStatements:
35+
Enabled: false
36+
AcrossEmptyLines: false
37+
AcrossComments: false
38+
AlignCaseColons: false
939
AlignEscapedNewlines: Left
1040
AlignOperands: DontAlign
11-
AlignTrailingComments: false
41+
AlignTrailingComments:
42+
Kind: Never
43+
OverEmptyLines: 0
1244
AllowAllArgumentsOnNextLine: true
13-
AllowAllConstructorInitializersOnNextLine: true
1445
AllowAllParametersOfDeclarationOnNextLine: false
15-
AllowShortEnumsOnASingleLine: true
46+
AllowBreakBeforeNoexceptSpecifier: Never
1647
AllowShortBlocksOnASingleLine: Never
1748
AllowShortCaseLabelsOnASingleLine: false
49+
AllowShortCompoundRequirementOnASingleLine: true
50+
AllowShortEnumsOnASingleLine: true
1851
AllowShortFunctionsOnASingleLine: Empty
19-
AllowShortLambdasOnASingleLine: All
2052
AllowShortIfStatementsOnASingleLine: Never
53+
AllowShortLambdasOnASingleLine: All
2154
AllowShortLoopsOnASingleLine: false
2255
AlwaysBreakAfterDefinitionReturnType: None
2356
AlwaysBreakAfterReturnType: None
@@ -27,17 +60,18 @@ AttributeMacros:
2760
- __capability
2861
BinPackArguments: false
2962
BinPackParameters: false
63+
BitFieldColonSpacing: Both
3064
BraceWrapping:
3165
AfterCaseLabel: false
3266
AfterClass: false
3367
AfterControlStatement: Never
3468
AfterEnum: false
69+
AfterExternBlock: false
3570
AfterFunction: false
3671
AfterNamespace: false
3772
AfterObjCDeclaration: false
3873
AfterStruct: false
3974
AfterUnion: false
40-
AfterExternBlock: false
4175
BeforeCatch: false
4276
BeforeElse: false
4377
BeforeLambdaBody: false
@@ -46,35 +80,36 @@ BraceWrapping:
4680
SplitEmptyFunction: true
4781
SplitEmptyRecord: true
4882
SplitEmptyNamespace: true
83+
BreakAdjacentStringLiterals: true
84+
BreakAfterAttributes: Leave
85+
BreakAfterJavaFieldAnnotations: false
86+
BreakArrays: true
4987
BreakBeforeBinaryOperators: None
50-
BreakBeforeConceptDeclarations: true
88+
BreakBeforeConceptDeclarations: Always
5189
BreakBeforeBraces: Attach
52-
BreakBeforeInheritanceComma: false
53-
BreakInheritanceList: BeforeColon
90+
BreakBeforeInlineASMColon: OnlyMultiline
5491
BreakBeforeTernaryOperators: true
55-
BreakConstructorInitializersBeforeComma: false
5692
BreakConstructorInitializers: BeforeColon
57-
BreakAfterJavaFieldAnnotations: false
93+
BreakInheritanceList: BeforeColon
5894
BreakStringLiterals: false
5995
ColumnLimit: 80
6096
CommentPragmas: '^ IWYU pragma:'
6197
CompactNamespaces: false
62-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
6398
ConstructorInitializerIndentWidth: 4
6499
ContinuationIndentWidth: 4
65100
Cpp11BracedListStyle: true
66-
DeriveLineEnding: true
67101
DerivePointerAlignment: false
68102
DisableFormat: false
103+
EmptyLineAfterAccessModifier: Never
69104
EmptyLineBeforeAccessModifier: LogicalBlock
70105
ExperimentalAutoDetectBinPacking: false
71106
FixNamespaceComments: true
72107
ForEachMacros:
73108
- FOR_EACH
74109
- FOR_EACH_R
75110
- FOR_EACH_RANGE
76-
StatementAttributeLikeMacros:
77-
- Q_EMIT
111+
IfMacros:
112+
- KJ_IF_MAYBE
78113
IncludeBlocks: Preserve
79114
IncludeCategories:
80115
- Regex: '^<.*\.h(pp)?>'
@@ -91,18 +126,31 @@ IncludeCategories:
91126
CaseSensitive: false
92127
IncludeIsMainRegex: '(Test)?$'
93128
IncludeIsMainSourceRegex: ''
94-
IndentCaseLabels: true
129+
IndentAccessModifiers: false
95130
IndentCaseBlocks: false
131+
IndentCaseLabels: true
132+
IndentExternBlock: AfterExternBlock
96133
IndentGotoLabels: true
97134
IndentPPDirectives: None
98-
IndentExternBlock: AfterExternBlock
99-
IndentRequires: false
135+
IndentRequiresClause: true
100136
IndentWidth: 2
101137
IndentWrappedFunctionNames: false
138+
InsertBraces: false
139+
InsertNewlineAtEOF: false
102140
InsertTrailingCommas: None
141+
IntegerLiteralSeparator:
142+
Binary: 0
143+
BinaryMinDigits: 0
144+
Decimal: 0
145+
DecimalMinDigits: 0
146+
Hex: 0
147+
HexMinDigits: 0
103148
JavaScriptQuotes: Leave
104149
JavaScriptWrapImports: true
105150
KeepEmptyLinesAtTheStartOfBlocks: false
151+
KeepEmptyLinesAtEOF: false
152+
LambdaBodyIndentation: Signature
153+
LineEnding: DeriveLF
106154
MacroBlockBegin: ''
107155
MacroBlockEnd: ''
108156
MaxEmptyLinesToKeep: 1
@@ -112,53 +160,85 @@ ObjCBlockIndentWidth: 2
112160
ObjCBreakBeforeNestedBlockParam: true
113161
ObjCSpaceAfterProperty: false
114162
ObjCSpaceBeforeProtocolList: false
163+
PackConstructorInitializers: NextLine
115164
PenaltyBreakAssignment: 2
116165
PenaltyBreakBeforeFirstCallParameter: 1
117166
PenaltyBreakComment: 300
118167
PenaltyBreakFirstLessLess: 120
168+
PenaltyBreakOpenParenthesis: 0
169+
PenaltyBreakScopeResolution: 500
119170
PenaltyBreakString: 1000
120171
PenaltyBreakTemplateDeclaration: 10
121172
PenaltyExcessCharacter: 1000000
122-
PenaltyReturnTypeOnItsOwnLine: 200
123173
PenaltyIndentedWhitespace: 0
174+
PenaltyReturnTypeOnItsOwnLine: 200
124175
PointerAlignment: Left
176+
PPIndentWidth: -1
177+
QualifierAlignment: Leave
178+
ReferenceAlignment: Pointer
125179
ReflowComments: true
126-
SortIncludes: true
180+
RemoveBracesLLVM: false
181+
RemoveParentheses: Leave
182+
RemoveSemicolon: false
183+
RequiresClausePosition: OwnLine
184+
RequiresExpressionIndentation: OuterScope
185+
SeparateDefinitionBlocks: Leave
186+
ShortNamespaceLines: 1
187+
SkipMacroDefinitionBody: false
188+
SortIncludes: CaseSensitive
127189
SortJavaStaticImport: Before
128-
SortUsingDeclarations: true
190+
SortUsingDeclarations: LexicographicNumeric
129191
SpaceAfterCStyleCast: false
130192
SpaceAfterLogicalNot: false
131193
SpaceAfterTemplateKeyword: true
194+
SpaceAroundPointerQualifiers: Default
132195
SpaceBeforeAssignmentOperators: true
133196
SpaceBeforeCaseColon: false
134197
SpaceBeforeCpp11BracedList: false
135198
SpaceBeforeCtorInitializerColon: true
136199
SpaceBeforeInheritanceColon: true
200+
SpaceBeforeJsonColon: false
137201
SpaceBeforeParens: ControlStatements
138-
SpaceAroundPointerQualifiers: Default
202+
SpaceBeforeParensOptions:
203+
AfterControlStatements: true
204+
AfterForeachMacros: true
205+
AfterFunctionDefinitionName: false
206+
AfterFunctionDeclarationName: false
207+
AfterIfMacros: true
208+
AfterOverloadedOperator: false
209+
AfterPlacementOperator: true
210+
AfterRequiresInClause: false
211+
AfterRequiresInExpression: false
212+
BeforeNonEmptyParentheses: false
139213
SpaceBeforeRangeBasedForLoopColon: true
214+
SpaceBeforeSquareBrackets: false
140215
SpaceInEmptyBlock: false
141-
SpaceInEmptyParentheses: false
142216
SpacesBeforeTrailingComments: 1
143-
SpacesInAngles: false
144-
SpacesInConditionalStatement: false
217+
SpacesInAngles: Never
145218
SpacesInContainerLiterals: true
146-
SpacesInCStyleCastParentheses: false
147-
SpacesInParentheses: false
219+
SpacesInLineCommentPrefix:
220+
Minimum: 1
221+
Maximum: -1
222+
SpacesInParens: Never
223+
SpacesInParensOptions:
224+
InCStyleCasts: false
225+
InConditionalStatements: false
226+
InEmptyParentheses: false
227+
Other: false
148228
SpacesInSquareBrackets: false
149-
SpaceBeforeSquareBrackets: false
150-
BitFieldColonSpacing: Both
151229
Standard: Latest
230+
StatementAttributeLikeMacros:
231+
- Q_EMIT
152232
StatementMacros:
153233
- Q_UNUSED
154234
- QT_REQUIRE_VERSION
155235
TabWidth: 8
156-
UseCRLF: false
157236
UseTab: Never
237+
VerilogBreakBetweenInstancePorts: true
158238
WhitespaceSensitiveMacros:
159-
- STRINGIZE
160-
- PP_STRINGIZE
161239
- BOOST_PP_STRINGIZE
162-
- NS_SWIFT_NAME
163240
- CF_SWIFT_NAME
241+
- NS_SWIFT_NAME
242+
- PP_STRINGIZE
243+
- STRINGIZE
164244
...

backends/apple/coreml/.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
BasedOnStyle: WebKit
2-
BreakBeforeBraces: Attach
32
AllowShortIfStatementsOnASingleLine: false
43
BreakBeforeBinaryOperators: None
54
BreakConstructorInitializers: BeforeColon

backends/apple/coreml/runtime/delegate/ETCoreMLDefaultModelExecutor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
NS_ASSUME_NONNULL_BEGIN
1515
/// The default model executor, the executor ignores logging options.
16-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLDefaultModelExecutor : NSObject<ETCoreMLModelExecutor>
16+
__attribute__((objc_subclassing_restricted))
17+
@interface ETCoreMLDefaultModelExecutor : NSObject<ETCoreMLModelExecutor>
1718

1819
+ (instancetype)new NS_UNAVAILABLE;
1920

backends/apple/coreml/runtime/delegate/ETCoreMLModelCompiler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
NS_ASSUME_NONNULL_BEGIN
1111
/// A class responsible for compiling a CoreML model.
12-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLModelCompiler : NSObject
12+
__attribute__((objc_subclassing_restricted))
13+
@interface ETCoreMLModelCompiler : NSObject
1314

1415
+ (instancetype)new NS_UNAVAILABLE;
1516

backends/apple/coreml/runtime/delegate/ETCoreMLModelLoader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct ModelMetadata;
1616

1717
NS_ASSUME_NONNULL_BEGIN
1818
/// A class responsible for loading a CoreML model.
19-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLModelLoader : NSObject
19+
__attribute__((objc_subclassing_restricted))
20+
@interface ETCoreMLModelLoader : NSObject
2021

2122
+ (instancetype)new NS_UNAVAILABLE;
2223

backends/apple/coreml/runtime/delegate/ETCoreMLModelManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class ModelEventLogger;
2020
typedef void ModelHandle;
2121

2222
/// A class responsible for managing the models loaded by the delegate.
23-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLModelManager : NSObject
23+
__attribute__((objc_subclassing_restricted))
24+
@interface ETCoreMLModelManager : NSObject
2425

2526
+ (instancetype)new NS_UNAVAILABLE;
2627

backends/apple/coreml/runtime/kvstore/key_value_store.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ get_create_store_statement(std::string_view store_name, StorageType key_storage_
5353

5454
std::string get_create_index_statement(std::string_view store_name, std::string_view column_name) {
5555
std::stringstream ss;
56-
ss << "CREATE INDEX IF NOT EXISTS " << column_name << "_INDEX"
57-
<< " ON " << store_name << "(" << column_name << ")";
56+
ss << "CREATE INDEX IF NOT EXISTS " << column_name << "_INDEX" << " ON " << store_name << "(" << column_name << ")";
5857

5958
return ss.str();
6059
}

backends/apple/coreml/runtime/sdk/ETCoreMLModelDebugger.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ typedef NSDictionary<ETCoreMLModelStructurePath*, MLMultiArray*> ETCoreMLModelOu
1515

1616
NS_ASSUME_NONNULL_BEGIN
1717
/// A class responsible for debugging a model.
18-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLModelDebugger : NSObject
18+
__attribute__((objc_subclassing_restricted))
19+
@interface ETCoreMLModelDebugger : NSObject
1920

2021
- (instancetype)init NS_UNAVAILABLE;
2122

backends/apple/coreml/runtime/sdk/ETCoreMLModelProfiler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ typedef NSDictionary<ETCoreMLModelStructurePath*, ETCoreMLOperationProfilingInfo
2121

2222
NS_ASSUME_NONNULL_BEGIN
2323
/// A class responsible for profiling a model.
24-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLModelProfiler : NSObject
24+
__attribute__((objc_subclassing_restricted))
25+
@interface ETCoreMLModelProfiler : NSObject
2526

2627
- (instancetype)init NS_UNAVAILABLE;
2728

backends/apple/coreml/runtime/sdk/ETCoreMLModelStructurePath.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
1717
///
1818
/// The class is a thin wrapper over `executorchcoreml::modelstructure::path`.
1919
///
20-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLModelStructurePath : NSObject<NSCopying>
20+
__attribute__((objc_subclassing_restricted))
21+
@interface ETCoreMLModelStructurePath : NSObject<NSCopying>
2122

2223
- (instancetype)init NS_UNAVAILABLE;
2324

backends/apple/coreml/runtime/sdk/ETCoreMLOperationProfilingInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
NS_ASSUME_NONNULL_BEGIN
1313

1414
/// A class representing the profiling info of an operation.
15-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLOperationProfilingInfo : NSObject<NSCopying>
15+
__attribute__((objc_subclassing_restricted))
16+
@interface ETCoreMLOperationProfilingInfo : NSObject<NSCopying>
1617

1718
- (instancetype)init NS_UNAVAILABLE;
1819

backends/apple/coreml/runtime/sdk/ETCoreMLPair.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
NS_ASSUME_NONNULL_BEGIN
1111
/// A class representing a pair with first and second objects.
12-
__attribute__((objc_subclassing_restricted)) @interface ETCoreMLPair<First, Second> : NSObject<NSCopying>
12+
__attribute__((objc_subclassing_restricted))
13+
@interface ETCoreMLPair<First, Second> : NSObject<NSCopying>
1314

1415
- (instancetype)init NS_UNAVAILABLE;
1516

0 commit comments

Comments
 (0)