Skip to content

Commit

Permalink
[clang-tidy] enable modernize-use-override
Browse files Browse the repository at this point in the history
  • Loading branch information
BeingGod committed Jul 18, 2023
1 parent c16ab55 commit b2271a4
Show file tree
Hide file tree
Showing 54 changed files with 88 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Checks: '
-modernize-use-equals-delete,
-modernize-use-noexcept,
-modernize-use-nullptr,
-modernize-use-override,
modernize-use-override,
-modernize-use-transparent-functors,
-modernize-use-uncaught-exceptions,
-performance-faster-string-find,
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ double GetFuseParameterMemorySize() { return FLAGS_fuse_parameter_memory_size; }

class CoalesceGradTensorPass : public ir::Pass {
protected:
void ApplyImpl(ir::Graph *graph) const {
void ApplyImpl(ir::Graph *graph) const override {
if (Get<size_t>(details::kNRanks) <= 1) {
VLOG(6) << "The number of place is" << Get<size_t>(details::kNRanks)
<< ", there doesn't need apply FuseAllReduceOpPass.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class Node;

class FuseAdamOpPass : public FuseOptimizerOpPass {
private:
const std::string GetOpType() const { return "adam"; }
const std::string GetOpType() const override { return "adam"; }

const std::vector<std::string> GetAuxiliaryVarNames() const {
const std::vector<std::string> GetAuxiliaryVarNames() const override {
return {"Moment1", "Moment2", "Beta1Pow", "Beta2Pow"};
}

Expand All @@ -41,7 +41,7 @@ class FuseAdamOpPass : public FuseOptimizerOpPass {
&aux_var_set,
const std::unordered_map<std::string, std::string> &fused_vars_name,
const std::vector<ir::Node *> &adam_ops,
ir::Graph *graph) const {
ir::Graph *graph) const override {
auto fused_adam_node =
FuseAdamOps(aux_var_set, fused_vars_name, adam_ops, graph);
return fused_adam_node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ class Node;

class FuseMomentumOpPass : public FuseOptimizerOpPass {
private:
virtual const std::string GetOpType() const { return "momentum"; }
const std::string GetOpType() const override { return "momentum"; }

virtual const std::vector<std::string> GetAuxiliaryVarNames() const {
const std::vector<std::string> GetAuxiliaryVarNames() const override {
return {"Velocity"};
}

// Fuse Momentum Ops
virtual ir::Node *FuseOptimizerOps(
ir::Node *FuseOptimizerOps(
const std::unordered_map<std::string, std::vector<std::string>> &vars_set,
const std::unordered_map<std::string, std::string> &fused_vars_name,
const std::vector<ir::Node *> &momentum_ops,
ir::Graph *graph) const {
ir::Graph *graph) const override {
PADDLE_ENFORCE_GT(
momentum_ops.size(),
static_cast<size_t>(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ class Node;

class FuseSgdOpPass : public FuseOptimizerOpPass {
private:
virtual const std::string GetOpType() const { return "sgd"; }
const std::string GetOpType() const override { return "sgd"; }

virtual const std::vector<std::string> GetAuxiliaryVarNames() const {
const std::vector<std::string> GetAuxiliaryVarNames() const override {
return {};
}

// Fuse Sgd Ops
virtual ir::Node *FuseOptimizerOps(
ir::Node *FuseOptimizerOps(
const std::unordered_map<std::string, std::vector<std::string>> &vars_set,
const std::unordered_map<std::string, std::string> &fused_vars_name,
const std::vector<ir::Node *> &sgd_ops,
ir::Graph *graph) const {
ir::Graph *graph) const override {
PADDLE_ENFORCE_GT(
sgd_ops.size(),
static_cast<size_t>(0),
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/new_executor/workqueue/workqueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class WorkQueueImpl : public WorkQueue {
options_.always_spinning);
}

virtual ~WorkQueueImpl() {
~WorkQueueImpl() override {
delete queue_;
if (tracker_ != nullptr) {
tracker_->~TaskTracker();
Expand Down Expand Up @@ -94,7 +94,7 @@ class WorkQueueGroupImpl : public WorkQueueGroup {
explicit WorkQueueGroupImpl(
const std::vector<WorkQueueOptions>& queue_options);

~WorkQueueGroupImpl();
~WorkQueueGroupImpl() override;

void AddTask(size_t queue_idx, std::function<void()> fn) override;

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/phi_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class KernelArgsNameMakerByOpProto : public KernelArgsNameMaker {
platform::errors::InvalidArgument("Op proto cannot be nullptr."));
}

~KernelArgsNameMakerByOpProto() {}
~KernelArgsNameMakerByOpProto() override {}

const paddle::small_vector<const char*>& GetInputArgsNames() override;
const paddle::small_vector<const char*>& GetOutputArgsNames() override;
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/memory/allocation/allocator_facade.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,22 @@ class CUDAGraphAllocator
: underlying_allocator_(allocator) {}

public:
~CUDAGraphAllocator() {}
~CUDAGraphAllocator() override {}

static std::shared_ptr<Allocator> Create(
const std::shared_ptr<Allocator>& allocator) {
return std::shared_ptr<Allocator>(new CUDAGraphAllocator(allocator));
}

protected:
phi::Allocation* AllocateImpl(size_t size) {
phi::Allocation* AllocateImpl(size_t size) override {
VLOG(10) << "Allocate " << size << " for CUDA Graph";
return new PrivateAllocation(this,
static_unique_ptr_cast<Allocation>(
underlying_allocator_->Allocate(size)));
}

void FreeImpl(phi::Allocation* allocation) {
void FreeImpl(phi::Allocation* allocation) override {
VLOG(10) << "delete for CUDA Graph";
delete allocation;
}
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/allreduce_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AllReduceDelOp : public framework::OperatorWithKernel {

class AllReduceDelOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor), tensor to be allreduced.");
AddOutput("Out", "(Tensor) the result of allreduced.");
AddAttr<int>("reduce_type", "(int) determine the reduce type.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/alltoall_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AllToAllBaseOp : public framework::OperatorWithKernel {

class AllToAllBaseOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor send.");
AddOutput("Out", "(Tensor) the result of alltoall.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/barrier_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BarrierOp : public framework::OperatorWithKernel {

class BarrierOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) Input data (only used in CUDAKernel).");
AddOutput("Out", "(Tensor) Output data (only used in CUDAKernel).");
AddAttr<int>("ring_id", "(int default 0) communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_allgather_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CAllGatherOp : public framework::OperatorWithKernel {

class CAllGatherOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be allgather");
AddOutput("Out", "(Tensor) the allgather result");
AddAttr<int>("ring_id", "(int default 0) communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_broadcast_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CBroadcastOp : public framework::OperatorWithKernel {

class CBroadcastOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be broadcasted.");
AddOutput("Out", "(Tensor) the result of broadcast.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_comm_init_all_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace operators {

class CCommInitAllInferShape : public framework::InferShapeBase {
public:
~CCommInitAllInferShape() {}
~CCommInitAllInferShape() override {}
void operator()(framework::InferShapeContext* ctx) const override{};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace operators {

class CCommInitMultiTrainerInferShape : public framework::InferShapeBase {
public:
~CCommInitMultiTrainerInferShape() {}
~CCommInitMultiTrainerInferShape() override {}
void operator()(framework::InferShapeContext* ctx) const override{};
};

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_concat_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CConcatOpGradMaker : public framework::SingleGradOpMaker<T> {

class CConcatOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be concated.");
AddOutput("Out", "(Tensor) the result of concat.");
AddAttr<int>("rank", "(int default 0) rank id.").SetDefault(0);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_identity_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CIdentityOp : public framework::OperatorWithKernel {

class CIdentityOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) identity tensor.");
AddOutput("Out", "(Tensor) identity tensor.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_reducescatter_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CReduceScatterOp : public framework::OperatorWithKernel {

class CReduceScatterOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be allgather");
AddOutput("Out", "(Tensor) the allgather result");
AddAttr<int>("ring_id", "(int default 0) communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_scatter_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CScatterOp : public framework::OperatorWithKernel {

class CScatterOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be broadcasted.");
AddOutput("Out", "(Tensor) the result of broadcast.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CSoftmaxWithCrossEntropyOp : public framework::OperatorWithKernel {
class CSoftmaxWithCrossEntropyOpMaker
: public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("Logits",
"(Tensor, default: Tensor<float>), The input tensor of unscaled "
"log probabilities, whose dimension :attr:`axis` should be scaled "
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_split_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CSplitOpGradMaker : public framework::SingleGradOpMaker<T> {

class CSplitOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be split.");
AddOutput("Out", "(Tensor) the result of split.");
AddAttr<int>("rank", "(int default 0) rank id.").SetDefault(0);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_sync_calc_stream_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace operators {

class CSyncCalcStreamOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) Dependency of the variable need to sync");
AddOutput("Out", "(Tensor) Dependency of the variable need to sync");
AddComment(R"DOC(
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_sync_comm_stream_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CSyncCommStreamOp : public framework::OperatorWithKernel {

class CSyncCommStreamOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) Dependency of the variable need to sync")
.AsDuplicable();
AddOutput("Out", "(Tensor) Dependency of the variable need to sync")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_wait_comm_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CWaitCommOp : public framework::OperatorBase {

class CWaitCommOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) Dependency of the variable need to sync")
.AsDuplicable();
AddOutput("Out", "(Tensor) Dependency of the variable need to sync")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/c_wait_compute_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CWaitComputeOp : public framework::OperatorBase {

class CWaitComputeOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) Dependency of the variable need to sync")
.AsDuplicable();
AddOutput("Out", "(Tensor) Dependency of the variable need to sync")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/global_gather_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GlobalGatherOp : public framework::OperatorWithKernel {

class GlobalGatherOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor send.");
AddInput("local_count",
"(Tensor) Tensor which has n_expert * world_size elements that "
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/global_scatter_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class GlobalScatterOp : public framework::OperatorWithKernel {

class GlobalScatterOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor send.");
AddInput("local_count",
"(Tensor) Tensor which has n_expert * world_size elements that "
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/mp_allreduce_sum_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MpAllReduceSumOp : public framework::OperatorWithKernel {

class MpAllReduceSumOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor), tensor to be allreduced in model parallel.");
AddOutput("Out", "(Tensor) the allreduced result in model parallel.");
AddAttr<int>("ring_id", "(int default 0) communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/partial_allgather_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PartialAllGatherOp : public framework::OperatorWithKernel {

class PartialAllGatherOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be partial allgather");
AddOutput("Out", "(Tensor) the allgather result");
AddAttr<int>("ring_id", "(int default 0) communication ring id.")
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/partial_recv_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PartialRecvOp : public framework::OperatorWithKernel {

class PartialRecvOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddOutput("Out", "(Tensor) tensor to receive.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
.SetDefault(0);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/partial_send_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PartialSendOp : public framework::OperatorWithKernel {

class PartialSendMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be sent.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
.SetDefault(0);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/recv_v2_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class RecvOpV2 : public framework::OperatorWithKernel {

class RecvOpV2Maker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddOutput("Out", "(Tensor) tensor to receive.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
.SetDefault(0);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/collective/send_v2_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SendOpV2 : public framework::OperatorWithKernel {

class SendOpV2Maker : public framework::OpProtoAndCheckerMaker {
public:
void Make() {
void Make() override {
AddInput("X", "(Tensor) tensor to be sent.");
AddAttr<int>("ring_id", "(int default 0) nccl communication ring id.")
.SetDefault(0);
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class FusedGemmEpilogueOp : public framework::OperatorWithKernel {
}

phi::KernelKey GetExpectedKernelType(
const framework::ExecutionContext& ctx) const {
const framework::ExecutionContext& ctx) const override {
auto data_type = OperatorWithKernel::IndicateVarDataType(ctx, "X");
return phi::KernelKey(data_type, ctx.GetPlace());
}
Expand Down Expand Up @@ -277,7 +277,7 @@ class FusedGemmEpilogueGradOp : public framework::OperatorWithKernel {
}

phi::KernelKey GetExpectedKernelType(
const framework::ExecutionContext& ctx) const {
const framework::ExecutionContext& ctx) const override {
auto data_type = OperatorWithKernel::IndicateVarDataType(ctx, "DOut");
return phi::KernelKey(data_type, ctx.GetPlace());
}
Expand Down
Loading

0 comments on commit b2271a4

Please sign in to comment.