From b02687cc92b55fa7c292018111f177d2fc3ee287 Mon Sep 17 00:00:00 2001 From: Galaxy1458 <55453380+Galaxy1458@users.noreply.github.com> Date: Sun, 23 Apr 2023 09:57:24 +0800 Subject: [PATCH] remove some [-Wunused-parameter] (#53162) * test,test=develop * test,test=develop * test,test=develop * test,test=develop * test,test=develop * test,test=develop * test,test=develop --- paddle/fluid/framework/data_feed.h | 36 ++++++++++--------- paddle/fluid/framework/details/op_registry.h | 4 +-- paddle/fluid/framework/inplace_op_inference.h | 4 +-- paddle/fluid/framework/ir/generate_pass.cc | 3 +- paddle/fluid/framework/ir/pass.h | 2 +- paddle/fluid/framework/op_desc.h | 3 +- paddle/fluid/framework/op_registry.h | 7 ++-- paddle/fluid/framework/operator.h | 11 +++--- paddle/fluid/framework/reader.h | 2 +- paddle/fluid/imperative/dygraph_grad_maker.h | 2 +- paddle/fluid/imperative/op_base.h | 3 +- paddle/phi/common/transform.h | 2 +- paddle/phi/core/infermeta_utils.h | 2 +- paddle/phi/kernels/funcs/elementwise_base.h | 8 ++--- 14 files changed, 48 insertions(+), 41 deletions(-) diff --git a/paddle/fluid/framework/data_feed.h b/paddle/fluid/framework/data_feed.h index 0905f397ae0..415508944c9 100644 --- a/paddle/fluid/framework/data_feed.h +++ b/paddle/fluid/framework/data_feed.h @@ -976,11 +976,11 @@ class GraphDataGenerator { void ResetEpochFinish() { epoch_finish_ = false; } void ClearSampleState(); void DumpWalkPath(std::string dump_path, size_t dump_rate); - void SetDeviceKeys(std::vector* device_keys, int type) { + void SetDeviceKeys(std::vector* device_keys UNUSED, + int type UNUSED) { // type_to_index_[type] = h_device_keys_.size(); // h_device_keys_.push_back(device_keys); } - std::vector> SampleNeighbors( int64_t* uniq_nodes, int len, @@ -1126,7 +1126,7 @@ class DataFeed { } virtual ~DataFeed() {} virtual void Init(const DataFeedDesc& data_feed_desc) = 0; - virtual bool CheckFile(const char* filename) { + virtual bool CheckFile(const char* filename UNUSED) { PADDLE_THROW(platform::errors::Unimplemented( "This function(CheckFile) is not implemented.")); } @@ -1415,13 +1415,13 @@ class InMemoryDataFeed : public DataFeed { protected: virtual bool ParseOneInstance(T* instance) = 0; virtual bool ParseOneInstanceFromPipe(T* instance) = 0; - virtual void ParseOneInstanceFromSo(const char* str, - T* instance, - CustomParser* parser) {} - virtual int ParseInstanceFromSo(int len, - const char* str, - std::vector* instances, - CustomParser* parser) { + virtual void ParseOneInstanceFromSo(const char* str UNUSED, + T* instance UNUSED, + CustomParser* parser UNUSED) {} + virtual int ParseInstanceFromSo(int len UNUSED, + const char* str UNUSED, + std::vector* instances UNUSED, + CustomParser* parser UNUSED) { return 0; } virtual void PutToFeedVec(const std::vector& ins_vec) = 0; @@ -1656,7 +1656,7 @@ struct RecordCandidate { class RecordCandidateList { public: RecordCandidateList() = default; - RecordCandidateList(const RecordCandidateList&) {} + RecordCandidateList(const RecordCandidateList& UNUSED) {} size_t Size() { return cur_size_; } void ReSize(size_t length); @@ -1802,9 +1802,9 @@ class MultiSlotInMemoryDataFeed : public InMemoryDataFeed { protected: virtual bool ParseOneInstance(Record* instance); virtual bool ParseOneInstanceFromPipe(Record* instance); - virtual void ParseOneInstanceFromSo(const char* str, - Record* instance, - CustomParser* parser) {} + virtual void ParseOneInstanceFromSo(const char* str UNUSED, + Record* instance UNUSED, + CustomParser* parser UNUSED) {} virtual int ParseInstanceFromSo(int len, const char* str, std::vector* instances, @@ -1828,11 +1828,13 @@ class SlotRecordInMemoryDataFeed : public InMemoryDataFeed { protected: bool Start() override; int Next() override; - bool ParseOneInstance(SlotRecord* instance) override { return false; } - bool ParseOneInstanceFromPipe(SlotRecord* instance) override { return false; } + bool ParseOneInstance(SlotRecord* instance UNUSED) override { return false; } + bool ParseOneInstanceFromPipe(SlotRecord* instance UNUSED) override { + return false; + } // virtual void ParseOneInstanceFromSo(const char* str, T* instance, // CustomParser* parser) {} - void PutToFeedVec(const std::vector& ins_vec) override {} + void PutToFeedVec(const std::vector& ins_vec UNUSED) override {} virtual void LoadIntoMemoryByCommand(void); virtual void LoadIntoMemoryByLib(void); diff --git a/paddle/fluid/framework/details/op_registry.h b/paddle/fluid/framework/details/op_registry.h index 7642d0f64a0..19b3a281afe 100644 --- a/paddle/fluid/framework/details/op_registry.h +++ b/paddle/fluid/framework/details/op_registry.h @@ -320,7 +320,7 @@ struct OpInfoFiller { template struct OpInfoFiller { - void operator()(const char* op_type, OpInfo* info) const { + void operator()(const char* op_type UNUSED, OpInfo* info) const { // Note: if fill InferShapeFN by this Filler, the infershape here // will overwrite the op->InferShape func registered in kOperator Filler info->infer_shape_ = [](InferShapeContext* ctx) { @@ -360,7 +360,7 @@ struct OpInfoFiller { // A fake OpInfoFiller of void template <> struct OpInfoFiller { - void operator()(const char* op_type, OpInfo* info) const {} + void operator()(const char* op_type UNUSED, OpInfo* info UNUSED) const {} }; } // namespace details diff --git a/paddle/fluid/framework/inplace_op_inference.h b/paddle/fluid/framework/inplace_op_inference.h index 93bbec251fe..2a1a44e57a3 100644 --- a/paddle/fluid/framework/inplace_op_inference.h +++ b/paddle/fluid/framework/inplace_op_inference.h @@ -18,7 +18,7 @@ #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/type_defs.h" - +#include "paddle/phi/core/macros.h" namespace paddle { namespace framework { @@ -40,7 +40,7 @@ class InplaceOpInference { class class_name final : public ::paddle::framework::InplaceOpInference { \ public: \ std::unordered_map operator()( \ - bool use_cuda) const final { \ + bool use_cuda UNUSED) const final { \ return {__VA_ARGS__}; \ } \ } diff --git a/paddle/fluid/framework/ir/generate_pass.cc b/paddle/fluid/framework/ir/generate_pass.cc index 455af834278..dd58b090764 100644 --- a/paddle/fluid/framework/ir/generate_pass.cc +++ b/paddle/fluid/framework/ir/generate_pass.cc @@ -53,7 +53,8 @@ class operation_visitor { : type_(type) {} template - Attribute operator()(const T1& attr, const T2& operation) const { + Attribute operator()(const T1& attr UNUSED, + const T2& operation UNUSED) const { PADDLE_THROW(platform::errors::Unimplemented("Unimplemented operand.")); } diff --git a/paddle/fluid/framework/ir/pass.h b/paddle/fluid/framework/ir/pass.h index 50d7434c7d9..c7f76cb0bfd 100644 --- a/paddle/fluid/framework/ir/pass.h +++ b/paddle/fluid/framework/ir/pass.h @@ -169,7 +169,7 @@ class Pass { virtual bool SupportApplyProgramViaGraph() const { return true; } protected: - virtual void ApplyImpl(Graph *graph) const { + virtual void ApplyImpl(Graph *graph UNUSED) const { PADDLE_THROW(platform::errors::Unimplemented( "The virtual pass called is not implemented.")); } diff --git a/paddle/fluid/framework/op_desc.h b/paddle/fluid/framework/op_desc.h index d6ce42d5c65..45c7ba639f6 100644 --- a/paddle/fluid/framework/op_desc.h +++ b/paddle/fluid/framework/op_desc.h @@ -25,6 +25,7 @@ limitations under the License. */ #include "paddle/fluid/framework/attribute.h" #include "paddle/fluid/framework/type_defs.h" #include "paddle/fluid/framework/var_desc.h" +#include "paddle/phi/core/macros.h" namespace paddle { namespace framework { @@ -150,7 +151,7 @@ class OpDesc { const AttributeMap &GetRuntimeAttrMap() const; - std::vector InputNames(bool with_attr_var = false) const { + std::vector InputNames(bool with_attr_var UNUSED = false) const { return MapKeys(inputs_); } std::vector OutputNames() const { return MapKeys(outputs_); } diff --git a/paddle/fluid/framework/op_registry.h b/paddle/fluid/framework/op_registry.h index 61c976cfc7a..c0c62a6fd2a 100644 --- a/paddle/fluid/framework/op_registry.h +++ b/paddle/fluid/framework/op_registry.h @@ -35,6 +35,7 @@ limitations under the License. */ #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/shape_inference.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/core/macros.h" namespace paddle { namespace framework { @@ -218,9 +219,9 @@ struct OpKernelRegistrarFunctor { template struct OpKernelRegistrarFunctor { - void operator()(const char* op_type, - const char* library_type, - int customized_type_value) const {} + void operator()(const char* op_type UNUSED, + const char* library_type UNUSED, + int customized_type_value UNUSED) const {} }; // User can register many kernel in one place. The data type could be diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index 57ba880f4f2..f055213f7bb 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -44,6 +44,7 @@ limitations under the License. */ #include "paddle/phi/core/compat/op_utils.h" #include "paddle/phi/core/kernel_context.h" #include "paddle/phi/core/kernel_factory.h" +#include "paddle/phi/core/macros.h" #include "paddle/utils/flat_hash_map.h" namespace paddle { @@ -353,11 +354,11 @@ class OperatorBase { void SetIsCalledByExecutor(bool x) { run_by_executor_ = x; } - virtual void SetIsRuntimeInferShape(bool x) {} + virtual void SetIsRuntimeInferShape(bool x UNUSED) {} - virtual void RuntimeInferShape(const Scope& scope, - const platform::Place& place, - const RuntimeContext& ctx) const {} + virtual void RuntimeInferShape(const Scope& scope UNUSED, + const platform::Place& place UNUSED, + const RuntimeContext& ctx UNUSED) const {} virtual platform::Place GetExecutionPlace( const platform::Place& place) const { @@ -794,7 +795,7 @@ class OperatorWithKernel : public OperatorBase { const phi::KernelKey& expected_kernel_type) const; platform::Place GetExecutionPlace( - const platform::Place& platform) const override { + const platform::Place& platform UNUSED) const override { return kernel_type_->place_; } diff --git a/paddle/fluid/framework/reader.h b/paddle/fluid/framework/reader.h index 9215d701510..103b9a3ca0d 100644 --- a/paddle/fluid/framework/reader.h +++ b/paddle/fluid/framework/reader.h @@ -73,7 +73,7 @@ class ReaderBase { virtual ~ReaderBase(); protected: - virtual void ReadNextImpl(paddle::framework::LoDTensorArray* out) {} + virtual void ReadNextImpl(paddle::framework::LoDTensorArray* out UNUSED) {} virtual void ShutdownImpl() {} diff --git a/paddle/fluid/imperative/dygraph_grad_maker.h b/paddle/fluid/imperative/dygraph_grad_maker.h index 0683bdc16a8..a81d1c50db8 100644 --- a/paddle/fluid/imperative/dygraph_grad_maker.h +++ b/paddle/fluid/imperative/dygraph_grad_maker.h @@ -61,7 +61,7 @@ class GradOpBaseMakerBase { virtual std::shared_ptr operator()() const = 0; TracedVarList InputGrad( - const std::string& name, bool drop_empty_grad = true) const { + const std::string& name, bool drop_empty_grad UNUSED = true) const { return GetVarBaseList(name, /*is_input=*/true); } diff --git a/paddle/fluid/imperative/op_base.h b/paddle/fluid/imperative/op_base.h index fedcdcbf93a..73cf12a8c4c 100644 --- a/paddle/fluid/imperative/op_base.h +++ b/paddle/fluid/imperative/op_base.h @@ -118,7 +118,8 @@ class OpBase { attrs_[name] = v; } - void SetBlockAttr(const std::string& name, framework::BlockDesc* block) { + void SetBlockAttr(const std::string& name UNUSED, + framework::BlockDesc* block UNUSED) { PADDLE_THROW(platform::errors::PermissionDenied( "SetBlockAttr is not support in dygraph OpBase")); } diff --git a/paddle/phi/common/transform.h b/paddle/phi/common/transform.h index 38ec0b56273..e80561284b8 100644 --- a/paddle/phi/common/transform.h +++ b/paddle/phi/common/transform.h @@ -70,7 +70,7 @@ struct Transform { template <> struct Transform { template - void operator()(const phi::CPUContext& context, + void operator()(const phi::CPUContext& context UNUSED, InputIter first, InputIter last, OutputIter result, diff --git a/paddle/phi/core/infermeta_utils.h b/paddle/phi/core/infermeta_utils.h index 729c56352cf..ba09bf9b5d4 100644 --- a/paddle/phi/core/infermeta_utils.h +++ b/paddle/phi/core/infermeta_utils.h @@ -254,7 +254,7 @@ struct InferMetaFnImpl { template struct InferMetaFnCallHelper> { template - static void Call(InferMetaContext* ctx, Args&... args) { + static void Call(InferMetaContext* ctx UNUSED, Args&... args) { return infer_meta_fn(args...); } }; diff --git a/paddle/phi/kernels/funcs/elementwise_base.h b/paddle/phi/kernels/funcs/elementwise_base.h index 1d40d4d8c29..b2c747d5348 100644 --- a/paddle/phi/kernels/funcs/elementwise_base.h +++ b/paddle/phi/kernels/funcs/elementwise_base.h @@ -224,7 +224,7 @@ class TransformFunctor { trans(ctx_, x_, x_ + nx_, y_, z_, func_); } - inline void RunRowWise(int n, int pre) const { + inline void RunRowWise(int n) const { phi::Transform trans; if (is_xsize_larger_) { trans(ctx_, @@ -243,7 +243,7 @@ class TransformFunctor { } } - inline void RunMidWise(int n, int pre, int post) const { + inline void RunMidWise(int n, int post) const { phi::Transform trans; if (is_xsize_larger_) { trans(ctx_, @@ -435,10 +435,10 @@ void ElementwiseCompute(const CPUContext &dev_ctx, } if (post == 1) { - functor.RunRowWise(n, pre); + functor.RunRowWise(n); return; } else { - functor.RunMidWise(n, pre, post); + functor.RunMidWise(n, post); return; } } -- GitLab