Skip to content

Commit

Permalink
Fixed cpplint warning/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfeiyue-cfy committed Jun 7, 2024
1 parent 2db27a5 commit 1b57ed0
Show file tree
Hide file tree
Showing 30 changed files with 130 additions and 16 deletions.
3 changes: 2 additions & 1 deletion onnxruntime/core/framework/node_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ void NodeUnit::InitForSingleNode() {
} else if (IsVariadicQLinearOp(qlinear_type)) {
size_t input_num = (input_defs.size() - 2) / 3;
for (size_t i = 0; i < input_num; i++) {
inputs_.push_back(NodeUnitIODef{*input_defs[3 * i + 2], NodeUnitIODef::QuantParam{*input_defs[3 * i + 3], input_defs[3 * i + 4]}});
inputs_.push_back(NodeUnitIODef{*input_defs[3 * i + 2], NodeUnitIODef::QuantParam{*input_defs[3 * i + 3],
input_defs[3 * i + 4]}});
}
outputs_.push_back(NodeUnitIODef{*output_defs[0], NodeUnitIODef::QuantParam{*input_defs[0], input_defs[1]}});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/shared/utils/utils.h"
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <string>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"

namespace onnxruntime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
*
*****************************************************************************/
#pragma once

#include <memory>
#include <vector>
#include "core/providers/vsinpu/builders/op_builder.h"
#include "core/providers/vsinpu/vsinpu_ep_graph.h"
#include "core/providers/vsinpu/vsinpu_util.h"
Expand Down Expand Up @@ -54,7 +55,7 @@ class BaseOpBuilder : public IOpBuilder {
const InitializedTensorSet& initializers, const NodeUnit& node_unit) const;

// TODO:Check if this node_unit's type is supported
virtual bool IsNodeUnitTypeSupported(const NodeUnit& node_unit) const { return true; };
virtual bool IsNodeUnitTypeSupported(const NodeUnit& node_unit) const { return true; }

virtual bool HandleBuildOp(
vsi::npu::GraphEP* graph_ep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/shared/utils/utils.h"
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
namespace onnxruntime {
Expand All @@ -34,6 +37,7 @@ class CastOpBuilder : public BaseOpBuilder {
NodeAttrHelper helper(node_unit.GetNode());
auto op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::DataConvert>();
(*op).BindInput(inputs[0]).BindOutputs(outputs);
graph_ep->GetOps().push_back(std::move(op));
return true;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <limits>
#include <utility>
#include "core/providers/vsinpu/builders/impl/clip_op_builder.h"

namespace onnxruntime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/common.h"
#include "core/providers/shared/utils/utils.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <string>
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/shared/utils/utils.h"
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
namespace onnxruntime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/common.h"
#include "core/providers/shared/utils/utils.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
namespace onnxruntime {
namespace vsi {
Expand Down Expand Up @@ -85,7 +88,6 @@ class PowOpBuilder : public BaseOpBuilder {
(*op).BindInputs(inputs).BindOutputs(outputs);
graph_ep->GetOps().push_back(std::move(op));
return true;
;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/common.h"
#include "core/providers/shared/utils/utils.h"
Expand All @@ -35,9 +38,9 @@ class FlattenOpBuilder : public BaseOpBuilder {
const NodeUnit& node_unit) override {
LOGS_DEFAULT(VERBOSE) << "Creating Flatten Op.";
std::vector<uint32_t> reshape_param;
if (outputs[0]->GetShape().size() == 2)
if (outputs[0]->GetShape().size() == 2) {
reshape_param = outputs[0]->GetShape();
else {
} else {
auto input_shape = inputs[0]->GetShape();
NodeAttrHelper helper(node_unit.GetNode());
int64_t axis = helper.Get("axis", 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand Down Expand Up @@ -68,7 +71,8 @@ class GatherOpBuilder : public BaseOpBuilder {
inputs[1]->CopyDataFromTensor(origin_data.data());
std::vector<int32_t> transformed_data(origin_data.begin(), origin_data.end());
auto transformed_indices = graph_ep->GetGraph()->CreateTensor(
inputs[1]->GetSpec().SetAttribute(tim::vx::TensorAttribute::INPUT).SetDataType(tim::vx::DataType::INT32), transformed_data.data());
inputs[1]->GetSpec().SetAttribute(tim::vx::TensorAttribute::INPUT).SetDataType(tim::vx::DataType::INT32),
transformed_data.data());
(*op).BindInput(inputs[0]).BindInput(transformed_indices).BindOutput(outputs[0]);
}
graph_ep->GetOps().push_back(std::move(op));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/shared/utils/utils.h"
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
namespace onnxruntime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"

namespace onnxruntime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand All @@ -29,7 +32,7 @@ namespace vsi {
namespace npu {
class BasePoolOpBuilder : public BaseOpBuilder {
public:
BasePoolOpBuilder(tim::vx::PoolType pool_type) : pool_type_(pool_type) {}
explicit BasePoolOpBuilder(tim::vx::PoolType pool_type) : pool_type_(pool_type) {}

protected:
bool IsOpSupported(const onnxruntime::GraphViewer& graph_viewer, const Node* node) const override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"

namespace onnxruntime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/shared/utils/utils.h"
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
namespace onnxruntime {
Expand All @@ -35,6 +38,7 @@ class QLinearConcatOpBuilder : public BaseOpBuilder {
axis = util::ReverseAxis(axis, inputs[0]->GetShape().size());
auto op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Concat>(axis, inputs.size());
(*op).BindInputs(inputs).BindOutputs(outputs);
graph_ep->GetOps().push_back(std::move(op));
return true;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <string>
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/shared/utils/utils.h"
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/framework/tensorprotoutils.h"
#include <variant>
namespace onnxruntime {
namespace vsi {
namespace npu {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"

namespace onnxruntime {
Expand All @@ -44,9 +47,9 @@ class QLinearMatMulOpBuilder : public BaseOpBuilder {
auto A_def = input_defs[matrixA];
auto B_def = input_defs[matrixB];
for (auto def : input_defs) {
if (def->Name() == A_def->Name() || def->Name() == B_def->Name())
if (def->Name() == A_def->Name() || def->Name() == B_def->Name()) {
continue;
else {
} else {
if (!graph_viewer.IsConstantInitializer(def->Name(), true)) {
LOGS_DEFAULT(WARNING) << "Scale and zero point must be known before setting graph.";
return false;
Expand All @@ -70,6 +73,7 @@ class QLinearMatMulOpBuilder : public BaseOpBuilder {
LOGS_DEFAULT(INFO) << "Creating QLinearMatmul Op.";
auto op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Matmul>();
(*op).BindInputs(inputs).BindOutputs(outputs);
graph_ep->GetOps().push_back(std::move(op));
return true;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/common.h"
#include "core/providers/shared/utils/utils.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand Down Expand Up @@ -108,11 +111,13 @@ class ResizeOpBuilder : public BaseOpBuilder {
int64_t onnx_size;
inputs[3]->CopyDataFromTensor(&onnx_size);
target_size = static_cast<int>(onnx_size);
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize1d>(resize_type, 0.0f, align_corners, half_pixel_center, target_size);
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize1d>(resize_type, 0.0f, align_corners,
half_pixel_center, target_size);
} else {
float scale;
inputs[scale_index]->CopyDataFromTensor(&scale);
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize1d>(resize_type, scale, align_corners, half_pixel_center, 0);
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize1d>(resize_type, scale, align_corners,
half_pixel_center, 0);
}
} else {
int target_height, target_width;
Expand All @@ -121,7 +126,8 @@ class ResizeOpBuilder : public BaseOpBuilder {
inputs[3]->CopyDataFromTensor(onnx_sizes.data());
target_height = static_cast<int>(onnx_sizes[1]);
target_width = static_cast<int>(onnx_sizes[0]);
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize>(resize_type, 0.0f, align_corners, half_pixel_center, target_height, target_width);
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize>(resize_type, 0.0f, align_corners,
half_pixel_center, target_height, target_width);

Check warning on line 130 in onnxruntime/core/providers/vsinpu/builders/impl/resize_op_builder.h

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/core/providers/vsinpu/builders/impl/resize_op_builder.h:130: Lines should be <= 120 characters long [whitespace/line_length] [2]
} else {
auto input_shape = inputs[0]->GetShape();
std::vector<float> scales(input_shape.size());
Expand All @@ -130,7 +136,8 @@ class ResizeOpBuilder : public BaseOpBuilder {
for (int i = 0; i < input_shape.size(); i++) {
out_shape[i] = input_shape[i] * scales[input_shape.size() - 1 - i];
}
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize>(resize_type, 0, align_corners, half_pixel_center, out_shape[1], out_shape[0]);
op = graph_ep->GetGraph()->CreateOperation<tim::vx::ops::Resize>(resize_type, 0, align_corners,
half_pixel_center, out_shape[1], out_shape[0]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include <functional>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/common.h"
#include "core/providers/shared/utils/utils.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include <memory>
#include <vector>
#include <utility>
#include "core/providers/vsinpu/builders/impl/base_op_builder.h"
#include "core/providers/shared/utils/utils.h"

Expand Down
Loading

0 comments on commit 1b57ed0

Please sign in to comment.