Skip to content

Commit eeef157

Browse files
authored
Format c++ code under winml/ (#16660)
winml/ was previously excluded from lintrunner config. This change includes the directory and adds the clang-format config file specific to winml/ that fits existing style. --------- Signed-off-by: Justin Chu <[email protected]>
1 parent 6499301 commit eeef157

File tree

191 files changed

+12715
-10781
lines changed

Some content is hidden

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

191 files changed

+12715
-10781
lines changed

.lintrunner.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ exclude_patterns = [
157157
'onnxruntime/core/flatbuffers/schema/*.fbs.h', # Generated code
158158
'onnxruntime/core/graph/contrib_ops/quantization_defs.cc',
159159
'onnxruntime/core/mlas/**', # Contains assembly code
160-
'winml/**', # FIXME: Enable clang-format for winml
160+
'winml/lib/Api.Image/shaders/**', # Contains data chunks
161161
]
162162
command = [
163163
'python',

winml/.clang-format

+253
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
# Use clang-format -dump-config -style=google to get the base configuration
2+
---
3+
Language: Cpp
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: BlockIndent
6+
AlignArrayOfStructures: Right
7+
AlignConsecutiveAssignments:
8+
Enabled: false
9+
AcrossEmptyLines: false
10+
AcrossComments: false
11+
AlignCompound: false
12+
PadOperators: false
13+
AlignConsecutiveBitFields:
14+
Enabled: false
15+
AcrossEmptyLines: false
16+
AcrossComments: false
17+
AlignCompound: false
18+
PadOperators: false
19+
AlignConsecutiveDeclarations:
20+
Enabled: false
21+
AcrossEmptyLines: false
22+
AcrossComments: false
23+
AlignCompound: false
24+
PadOperators: false
25+
AlignConsecutiveMacros:
26+
Enabled: false
27+
AcrossEmptyLines: false
28+
AcrossComments: false
29+
AlignCompound: false
30+
PadOperators: false
31+
AlignEscapedNewlines: Left
32+
AlignOperands: DontAlign
33+
AlignTrailingComments:
34+
Kind: Leave
35+
OverEmptyLines: 0
36+
AllowAllArgumentsOnNextLine: true
37+
AllowAllParametersOfDeclarationOnNextLine: true
38+
AllowShortBlocksOnASingleLine: Never
39+
AllowShortCaseLabelsOnASingleLine: false
40+
AllowShortEnumsOnASingleLine: false
41+
AllowShortFunctionsOnASingleLine: InlineOnly
42+
AllowShortIfStatementsOnASingleLine: Never
43+
AllowShortLambdasOnASingleLine: All
44+
AllowShortLoopsOnASingleLine: false
45+
AlwaysBreakAfterReturnType: None
46+
AlwaysBreakBeforeMultilineStrings: true
47+
AlwaysBreakTemplateDeclarations: Yes
48+
AttributeMacros:
49+
- __capability
50+
BinPackArguments: false
51+
BinPackParameters: false
52+
BitFieldColonSpacing: Both
53+
BraceWrapping:
54+
AfterCaseLabel: false
55+
AfterClass: false
56+
AfterControlStatement: Never
57+
AfterEnum: false
58+
AfterExternBlock: false
59+
AfterFunction: false
60+
AfterNamespace: false
61+
AfterObjCDeclaration: false
62+
AfterStruct: false
63+
AfterUnion: false
64+
BeforeCatch: false
65+
BeforeElse: false
66+
BeforeLambdaBody: false
67+
BeforeWhile: false
68+
IndentBraces: false
69+
SplitEmptyFunction: true
70+
SplitEmptyRecord: true
71+
SplitEmptyNamespace: true
72+
BreakAfterAttributes: Never
73+
BreakBeforeBinaryOperators: None
74+
BreakBeforeConceptDeclarations: Always
75+
BreakBeforeBraces: Attach
76+
BreakBeforeInlineASMColon: OnlyMultiline
77+
BreakBeforeTernaryOperators: true
78+
BreakConstructorInitializers: BeforeColon
79+
BreakInheritanceList: BeforeColon
80+
BreakStringLiterals: false
81+
ColumnLimit: 120
82+
CommentPragmas: "^ IWYU pragma:"
83+
CompactNamespaces: false
84+
ConstructorInitializerIndentWidth: 2
85+
ContinuationIndentWidth: 2
86+
Cpp11BracedListStyle: true
87+
DerivePointerAlignment: false
88+
DisableFormat: false
89+
EmptyLineAfterAccessModifier: Never
90+
EmptyLineBeforeAccessModifier: LogicalBlock
91+
FixNamespaceComments: true
92+
ForEachMacros:
93+
- foreach
94+
- Q_FOREACH
95+
- BOOST_FOREACH
96+
IfMacros:
97+
- KJ_IF_MAYBE
98+
IncludeBlocks: Regroup
99+
IncludeCategories:
100+
- Regex: '^<ext/.*\.h>'
101+
Priority: 2
102+
SortPriority: 0
103+
CaseSensitive: false
104+
- Regex: '^<.*\.h>'
105+
Priority: 1
106+
SortPriority: 0
107+
CaseSensitive: false
108+
- Regex: "^<.*"
109+
Priority: 2
110+
SortPriority: 0
111+
CaseSensitive: false
112+
- Regex: ".*"
113+
Priority: 3
114+
SortPriority: 0
115+
CaseSensitive: false
116+
IncludeIsMainRegex: "([-_](test|unittest))?$"
117+
IncludeIsMainSourceRegex: ""
118+
IndentAccessModifiers: false
119+
IndentCaseBlocks: false
120+
IndentCaseLabels: true
121+
IndentExternBlock: AfterExternBlock
122+
IndentGotoLabels: true
123+
IndentPPDirectives: None
124+
IndentRequiresClause: true
125+
IndentWidth: 2
126+
IndentWrappedFunctionNames: false
127+
InsertBraces: false
128+
InsertNewlineAtEOF: true
129+
InsertTrailingCommas: Wrapped
130+
IntegerLiteralSeparator:
131+
Binary: 0
132+
BinaryMinDigits: 0
133+
Decimal: 0
134+
DecimalMinDigits: 0
135+
Hex: 0
136+
HexMinDigits: 0
137+
KeepEmptyLinesAtTheStartOfBlocks: false
138+
LambdaBodyIndentation: Signature
139+
LineEnding: DeriveLF
140+
MacroBlockBegin: ""
141+
MacroBlockEnd: ""
142+
MaxEmptyLinesToKeep: 1
143+
NamespaceIndentation: None
144+
ObjCBinPackProtocolList: Never
145+
ObjCBlockIndentWidth: 2
146+
ObjCBreakBeforeNestedBlockParam: true
147+
ObjCSpaceAfterProperty: false
148+
ObjCSpaceBeforeProtocolList: true
149+
PackConstructorInitializers: CurrentLine
150+
PenaltyBreakAssignment: 2
151+
PenaltyBreakBeforeFirstCallParameter: 1
152+
PenaltyBreakComment: 300
153+
PenaltyBreakFirstLessLess: 120
154+
PenaltyBreakOpenParenthesis: 0
155+
PenaltyBreakString: 1000
156+
PenaltyBreakTemplateDeclaration: 10
157+
PenaltyExcessCharacter: 1000000
158+
PenaltyIndentedWhitespace: 0
159+
PenaltyReturnTypeOnItsOwnLine: 200
160+
PointerAlignment: Left
161+
PPIndentWidth: -1
162+
QualifierAlignment: Leave
163+
RawStringFormats:
164+
- Language: Cpp
165+
Delimiters:
166+
- cc
167+
- CC
168+
- cpp
169+
- Cpp
170+
- CPP
171+
- "c++"
172+
- "C++"
173+
CanonicalDelimiter: ""
174+
BasedOnStyle: google
175+
- Language: TextProto
176+
Delimiters:
177+
- pb
178+
- PB
179+
- proto
180+
- PROTO
181+
EnclosingFunctions:
182+
- EqualsProto
183+
- EquivToProto
184+
- PARSE_PARTIAL_TEXT_PROTO
185+
- PARSE_TEST_PROTO
186+
- PARSE_TEXT_PROTO
187+
- ParseTextOrDie
188+
- ParseTextProtoOrDie
189+
- ParseTestProto
190+
- ParsePartialTestProto
191+
CanonicalDelimiter: pb
192+
BasedOnStyle: google
193+
ReferenceAlignment: Pointer
194+
ReflowComments: false
195+
RemoveBracesLLVM: false
196+
RemoveSemicolon: false
197+
RequiresClausePosition: OwnLine
198+
RequiresExpressionIndentation: OuterScope
199+
SeparateDefinitionBlocks: Leave
200+
ShortNamespaceLines: 1
201+
SortIncludes: Never
202+
SortJavaStaticImport: Before
203+
SortUsingDeclarations: LexicographicNumeric
204+
SpaceAfterCStyleCast: false
205+
SpaceAfterLogicalNot: false
206+
SpaceAfterTemplateKeyword: true
207+
SpaceAroundPointerQualifiers: Default
208+
SpaceBeforeAssignmentOperators: true
209+
SpaceBeforeCaseColon: false
210+
SpaceBeforeCpp11BracedList: false
211+
SpaceBeforeCtorInitializerColon: true
212+
SpaceBeforeInheritanceColon: true
213+
SpaceBeforeParens: ControlStatements
214+
SpaceBeforeParensOptions:
215+
AfterControlStatements: true
216+
AfterForeachMacros: true
217+
AfterFunctionDefinitionName: false
218+
AfterFunctionDeclarationName: false
219+
AfterIfMacros: true
220+
AfterOverloadedOperator: false
221+
AfterRequiresInClause: false
222+
AfterRequiresInExpression: false
223+
BeforeNonEmptyParentheses: false
224+
SpaceBeforeRangeBasedForLoopColon: true
225+
SpaceBeforeSquareBrackets: false
226+
SpaceInEmptyBlock: false
227+
SpaceInEmptyParentheses: false
228+
SpacesBeforeTrailingComments: 2
229+
SpacesInAngles: Never
230+
SpacesInConditionalStatement: false
231+
SpacesInContainerLiterals: true
232+
SpacesInCStyleCastParentheses: false
233+
SpacesInLineCommentPrefix:
234+
Minimum: 1
235+
Maximum: -1
236+
SpacesInParentheses: false
237+
SpacesInSquareBrackets: false
238+
Standard: Auto
239+
StatementAttributeLikeMacros:
240+
- Q_EMIT
241+
StatementMacros:
242+
- Q_UNUSED
243+
- QT_REQUIRE_VERSION
244+
TabWidth: 8
245+
UseTab: Never
246+
WhitespaceSensitiveMacros:
247+
- BOOST_PP_STRINGIZE
248+
- CF_SWIFT_NAME
249+
- NS_SWIFT_NAME
250+
- PP_STRINGIZE
251+
- STRINGIZE
252+
- STRINGIFY
253+
- XSTRINGIFY

winml/adapter/abi_custom_registry_impl.cpp

+44-44
Original file line numberDiff line numberDiff line change
@@ -10,75 +10,75 @@
1010
namespace Windows::AI::MachineLearning::Adapter {
1111

1212
HRESULT STDMETHODCALLTYPE AbiCustomRegistryImpl::RegisterOperatorSetSchema(
13-
const MLOperatorSetId* opSetId,
14-
int baseline_version,
15-
const MLOperatorSchemaDescription* const* schema,
16-
uint32_t schemaCount,
17-
_In_opt_ IMLOperatorTypeInferrer* typeInferrer,
18-
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer) const noexcept try {
13+
const MLOperatorSetId* opSetId,
14+
int baseline_version,
15+
const MLOperatorSchemaDescription* const* schema,
16+
uint32_t schemaCount,
17+
_In_opt_ IMLOperatorTypeInferrer* typeInferrer,
18+
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer
19+
) const noexcept try {
1920
#ifdef LAYERING_DONE
2021
for (uint32_t i = 0; i < schemaCount; ++i) {
2122
telemetry_helper.RegisterOperatorSetSchema(
22-
schema[i]->name,
23-
schema[i]->inputCount,
24-
schema[i]->outputCount,
25-
schema[i]->typeConstraintCount,
26-
schema[i]->attributeCount,
27-
schema[i]->defaultAttributeCount);
23+
schema[i]->name,
24+
schema[i]->inputCount,
25+
schema[i]->outputCount,
26+
schema[i]->typeConstraintCount,
27+
schema[i]->attributeCount,
28+
schema[i]->defaultAttributeCount
29+
);
2830
}
2931
#endif
3032

3133
// Delegate to base class
3234
return AbiCustomRegistry::RegisterOperatorSetSchema(
33-
opSetId,
34-
baseline_version,
35-
schema,
36-
schemaCount,
37-
typeInferrer,
38-
shapeInferrer);
35+
opSetId, baseline_version, schema, schemaCount, typeInferrer, shapeInferrer
36+
);
3937
}
4038
CATCH_RETURN();
4139

4240
HRESULT STDMETHODCALLTYPE AbiCustomRegistryImpl::RegisterOperatorKernel(
43-
const MLOperatorKernelDescription* opKernel,
44-
IMLOperatorKernelFactory* operatorKernelFactory,
45-
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer) const noexcept {
41+
const MLOperatorKernelDescription* opKernel,
42+
IMLOperatorKernelFactory* operatorKernelFactory,
43+
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer
44+
) const noexcept {
4645
return RegisterOperatorKernel(opKernel, operatorKernelFactory, shapeInferrer, nullptr, false, false, false);
4746
}
4847

4948
HRESULT STDMETHODCALLTYPE AbiCustomRegistryImpl::RegisterOperatorKernel(
50-
const MLOperatorKernelDescription* opKernel,
51-
IMLOperatorKernelFactory* operatorKernelFactory,
52-
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer,
53-
_In_opt_ IMLOperatorSupportQueryPrivate* supportQuery,
54-
bool isInternalOperator,
55-
bool canAliasFirstInput,
56-
bool supportsGraph,
57-
const uint32_t* requiredInputCountForGraph,
58-
_In_reads_(constantCpuInputCount) const uint32_t* requiredConstantCpuInputs,
59-
uint32_t constantCpuInputCount) const noexcept try {
49+
const MLOperatorKernelDescription* opKernel,
50+
IMLOperatorKernelFactory* operatorKernelFactory,
51+
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer,
52+
_In_opt_ IMLOperatorSupportQueryPrivate* supportQuery,
53+
bool isInternalOperator,
54+
bool canAliasFirstInput,
55+
bool supportsGraph,
56+
const uint32_t* requiredInputCountForGraph,
57+
_In_reads_(constantCpuInputCount) const uint32_t* requiredConstantCpuInputs,
58+
uint32_t constantCpuInputCount
59+
) const noexcept try {
6060
#ifdef LAYERING_DONE
6161
// Log a custom op telemetry if the operator is not a built-in DML operator
6262
if (!isInternalOperator) {
6363
telemetry_helper.LogRegisterOperatorKernel(
64-
opKernel->name,
65-
opKernel->domain,
66-
static_cast<int>(opKernel->executionType));
64+
opKernel->name, opKernel->domain, static_cast<int>(opKernel->executionType)
65+
);
6766
}
6867
#endif
6968

7069
// Delegate to base class
7170
return AbiCustomRegistry::RegisterOperatorKernel(
72-
opKernel,
73-
operatorKernelFactory,
74-
shapeInferrer,
75-
supportQuery,
76-
isInternalOperator,
77-
canAliasFirstInput,
78-
supportsGraph,
79-
requiredInputCountForGraph,
80-
requiredConstantCpuInputs,
81-
constantCpuInputCount);
71+
opKernel,
72+
operatorKernelFactory,
73+
shapeInferrer,
74+
supportQuery,
75+
isInternalOperator,
76+
canAliasFirstInput,
77+
supportsGraph,
78+
requiredInputCountForGraph,
79+
requiredConstantCpuInputs,
80+
constantCpuInputCount
81+
);
8282
}
8383
CATCH_RETURN();
8484

0 commit comments

Comments
 (0)