Skip to content

Commit 8aaad2b

Browse files
committed
Fix cpp lint
1 parent ddc3f69 commit 8aaad2b

File tree

6 files changed

+38
-27
lines changed

6 files changed

+38
-27
lines changed

src/relax/backend/contrib/nnapi/codegen.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CollectFromCompositeFunctionBody : public ExprVisitor {
4848
explicit CollectFromCompositeFunctionBody(NNAPIJSONSerializer* serializer)
4949
: serializer_(serializer), node_(std::make_shared<JSONGraphNode>()) {}
5050

51-
void VisitExpr_(const CallNode* call_node) override final;
51+
void VisitExpr_(const CallNode* call_node) override;
5252

5353
void SetPermuteDimsAttribute(const CallNode* call_node) {
5454
const auto* permute_dims_attr = call_node->attrs.as<PermuteDimsAttrs>();
@@ -237,12 +237,11 @@ void CollectFromCompositeFunctionBody::VisitExpr_(const CallNode* call_node) {
237237
SetAstypeAttribute(call_node);
238238
} else if (name == "relax.mean") {
239239
SetMeanAttribute(call_node);
240-
}
241-
else if(name == "relax.nn.conv2d"){
240+
} else if (name == "relax.nn.conv2d") {
242241
SetConv2dAttribute(call_node);
243-
}
244-
else if(name == "relax.nn.max_pool2d"){
242+
} else if (name == "relax.nn.max_pool2d") {
245243
SetMaxPool2dAttribute(call_node);
244+
} else {
246245
}
247246
ExprVisitor::VisitExpr_(call_node);
248247
}

src/runtime/contrib/nnapi/nnapi_builder.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <algorithm>
2828
#include <iterator>
29+
#include <utility>
2930

3031
#include "../json/json_runtime.h"
3132
#include "nnapi_ops.h"

src/runtime/contrib/nnapi/nnapi_builder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ class NNAPIModelBuilder {
8484
other.model_ = nullptr;
8585
next_operand_index_ = other.next_operand_index_;
8686
other.next_operand_index_ = 0;
87-
};
87+
}
8888
inline NNAPIModelBuilder& operator=(NNAPIModelBuilder&& other) {
8989
model_ = other.model_;
9090
other.model_ = nullptr;
9191
next_operand_index_ = other.next_operand_index_;
9292
other.next_operand_index_ = 0;
9393
return *this;
94-
};
94+
}
9595

9696
NNAPIOperand CreateOperandWithValue(const DLTensor& tensor);
9797
NNAPIOperand CreateOperandWithValue(int32_t tensor_type, std::vector<int64_t> dimensions,

src/runtime/contrib/nnapi/nnapi_ops.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
#include <algorithm>
2424
#include <cstdint>
2525
#include <functional>
26+
#include <memory>
27+
#include <string>
28+
#include <tuple>
29+
#include <unordered_map>
2630
#include <utility>
31+
#include <vector>
2732

2833
#include "nnapi_builder.h"
2934

@@ -115,7 +120,7 @@ void SoftmaxOpConverter::Convert(NNAPIModelBuilder& builder, const JSONGraphNode
115120

116121
// Add the scalar input for beta value at index 1.
117122
const auto& input = inputs[0];
118-
// TODO: Conditionally use float16 beta for float16 input.
123+
// TODO(PLLab): Conditionally use float16 beta for float16 input.
119124
ICHECK_EQ(input.GetTensorType(), ANEURALNETWORKS_TENSOR_FLOAT32)
120125
<< "NNAPI runtime does not support non-float32 inputs for softmax yet";
121126
const float beta = 1.0f;
@@ -128,7 +133,7 @@ void SoftmaxOpConverter::Convert(NNAPIModelBuilder& builder, const JSONGraphNode
128133

129134
// Insert a reshape operation that reshapes `operand` to `dimensions` and return the reshaped
130135
// operand.
131-
NNAPIOperand ReshapeOperand(NNAPIModelBuilder& builder, const NNAPIOperand& operand,
136+
NNAPIOperand ReshapeOperand(NNAPIModelBuilder& builder, const NNAPIOperand& operand, // NOLINT(*)
132137
std::vector<int64_t> dimensions) {
133138
// ANEURALNETWORKS_RESHAPE requires the dimensions to be specified in a int32 tensor.
134139
const std::vector<int32_t> dimensions_int32(dimensions.begin(), dimensions.end());
@@ -148,7 +153,7 @@ NNAPIOperand ReshapeOperand(NNAPIModelBuilder& builder, const NNAPIOperand& oper
148153
return reshaped_operand;
149154
}
150155

151-
NNAPIOperand TransposeOperand(NNAPIModelBuilder& builder, const NNAPIOperand& operand,
156+
NNAPIOperand TransposeOperand(NNAPIModelBuilder& builder, const NNAPIOperand& operand, // NOLINT(*)
152157
std::vector<int64_t> dimensions) {
153158
const std::vector<int32_t> dimensions_int32(dimensions.begin(), dimensions.end());
154159
const std::vector<int64_t> dim_of_axes{static_cast<int64_t>(dimensions_int32.size())};
@@ -281,7 +286,8 @@ void CastOpConverter::Convert(NNAPIModelBuilder& builder, const JSONGraphNode& n
281286
}
282287

283288
template <int TensorType, typename DataType>
284-
NNAPIOperand CreateConv2DBiasOperand(NNAPIModelBuilder& builder, int64_t output_depth) {
289+
NNAPIOperand CreateConv2DBiasOperand(NNAPIModelBuilder& builder, // NOLINT(*)
290+
int64_t output_depth) {
285291
std::vector<DataType> bias(output_depth, 0.0f);
286292

287293
const std::vector<int64_t> dim_of_bias{static_cast<int64_t>(bias.size())};
@@ -324,17 +330,16 @@ void Conv2dOpConverter::Convert(NNAPIModelBuilder& builder, const JSONGraphNode&
324330
CreateConv2DBiasOperand<ANEURALNETWORKS_TENSOR_FLOAT16, uint16_t>(builder, output_depth);
325331
input_indices.push_back(bias_operand.GetOperandIndex());
326332
}
327-
}
328-
else{
333+
} else {
329334
int64_t bias_dim;
330-
for(int i=0; i<inputs[2].GetDimensions().size();i++){
331-
if(inputs[2].GetDimensions()[i]!=1) {
335+
for (int i = 0; i < inputs[2].GetDimensions().size(); i++) {
336+
if (inputs[2].GetDimensions()[i] != 1) {
332337
bias_dim = inputs[2].GetDimensions()[i];
333338
}
334339
}
335340
std::vector<int64_t> bias_dimension = {bias_dim};
336341
NNAPIOperand bias_operand = ReshapeOperand(builder, inputs[2], bias_dimension);
337-
input_indices[2] = bias_operand.GetOperandIndex();
342+
input_indices[2] = bias_operand.GetOperandIndex();
338343
}
339344
// padding operand
340345
std::vector<int32_t> padding;
@@ -588,7 +593,7 @@ const std::unordered_map<std::string, std::unique_ptr<NNAPIOpConverter>>& GetOpC
588593
return map;
589594
}();
590595
return map;
591-
};
596+
}
592597

593598
} // namespace contrib
594599
} // namespace runtime

src/runtime/contrib/nnapi/nnapi_ops.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323

2424
#include <android/NeuralNetworks.h>
2525

26+
#include <memory>
27+
#include <string>
28+
#include <unordered_map>
29+
#include <vector>
30+
2631
#include "../json/json_node.h"
2732
#include "nnapi_builder.h"
2833

@@ -36,7 +41,7 @@ struct NNAPIOpConverterParams {
3641
const JSONGraphNode& node;
3742
std::vector<NNAPIOperand> inputs;
3843
std::vector<NNAPIOperand> outputs;
39-
NNAPIOpConverterParams(const JSONGraphNode& node);
44+
explicit NNAPIOpConverterParams(const JSONGraphNode& node);
4045
};
4146

4247
class NNAPIOpConverter {
@@ -46,9 +51,9 @@ class NNAPIOpConverter {
4651
explicit NNAPIOpConverter(std::string op_name);
4752
virtual ~NNAPIOpConverter() = default;
4853

49-
virtual void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node,
54+
virtual void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node, // NOLINT(*)
5055
const std::vector<NNAPIOperand>& inputs,
51-
std::vector<NNAPIOperand>& outputs) const = 0;
56+
std::vector<NNAPIOperand>& outputs) const = 0; // NOLINT(*)
5257
};
5358

5459
class ElwBinaryOpConverter : public NNAPIOpConverter {
@@ -73,7 +78,7 @@ class UnaryOpConverter : public NNAPIOpConverter {
7378

7479
class SoftmaxOpConverter : public NNAPIOpConverter {
7580
public:
76-
inline explicit SoftmaxOpConverter() : NNAPIOpConverter("softmax") {}
81+
inline SoftmaxOpConverter() : NNAPIOpConverter("softmax") {}
7782
~SoftmaxOpConverter() = default;
7883

7984
void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node,
@@ -83,7 +88,7 @@ class SoftmaxOpConverter : public NNAPIOpConverter {
8388

8489
class MatmulOpConverter : public NNAPIOpConverter {
8590
public:
86-
inline explicit MatmulOpConverter() : NNAPIOpConverter("") {}
91+
inline MatmulOpConverter() : NNAPIOpConverter("") {}
8792
~MatmulOpConverter() = default;
8893

8994
void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node,
@@ -93,7 +98,7 @@ class MatmulOpConverter : public NNAPIOpConverter {
9398

9499
class TransposeOpConverter : public NNAPIOpConverter {
95100
public:
96-
inline explicit TransposeOpConverter() : NNAPIOpConverter("") {}
101+
inline TransposeOpConverter() : NNAPIOpConverter("") {}
97102
~TransposeOpConverter() = default;
98103

99104
void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node,
@@ -112,7 +117,7 @@ class CastOpConverter : public NNAPIOpConverter {
112117
};
113118
class Conv2dOpConverter : public NNAPIOpConverter {
114119
public:
115-
inline explicit Conv2dOpConverter() : NNAPIOpConverter("") {}
120+
inline Conv2dOpConverter() : NNAPIOpConverter("") {}
116121
~Conv2dOpConverter() = default;
117122

118123
void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node,
@@ -122,7 +127,7 @@ class Conv2dOpConverter : public NNAPIOpConverter {
122127

123128
class DenseOpConverter : public NNAPIOpConverter {
124129
public:
125-
inline explicit DenseOpConverter() : NNAPIOpConverter("") {}
130+
inline DenseOpConverter() : NNAPIOpConverter("") {}
126131
~DenseOpConverter() = default;
127132

128133
void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node,
@@ -132,7 +137,7 @@ class DenseOpConverter : public NNAPIOpConverter {
132137

133138
class MaxPool2dOpConverter : public NNAPIOpConverter {
134139
public:
135-
inline explicit MaxPool2dOpConverter() : NNAPIOpConverter("") {}
140+
inline MaxPool2dOpConverter() : NNAPIOpConverter("") {}
136141
~MaxPool2dOpConverter() = default;
137142

138143
void Convert(NNAPIModelBuilder& builder, const JSONGraphNode& node,

src/runtime/contrib/nnapi/nnapi_runtime.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ class NNAPIRuntime : public JSONRuntimeBase {
178178
ExecuteModel(compiled_model.compilation, compiled_model.model_output_operands);
179179
}
180180

181-
void AddOperation(NNAPIModelBuilder& builder, uint32_t nid, const JSONGraphNode& node) {
181+
void AddOperation(NNAPIModelBuilder& builder, uint32_t nid, // NOLINT(*)
182+
const JSONGraphNode& node) {
182183
std::vector<NNAPIOperand> inputs;
183184
std::vector<NNAPIOperand> outputs;
184185

0 commit comments

Comments
 (0)