diff --git a/paddle/fluid/operators/array_operator.h b/paddle/fluid/operators/array_operator.h index d30dc6eeaf5d76..9aaae3f5455e80 100644 --- a/paddle/fluid/operators/array_operator.h +++ b/paddle/fluid/operators/array_operator.h @@ -36,7 +36,7 @@ class ArrayOp : public framework::OperatorBase { auto *i = scope.FindVar(Input("I")); PADDLE_ENFORCE_NOT_NULL(i, common::errors::NotFound("Input(I) is not found.")); - auto &i_tensor = i->Get(); + auto &i_tensor = i->Get(); PADDLE_ENFORCE_EQ(i_tensor.numel(), 1, common::errors::InvalidArgument( @@ -54,7 +54,7 @@ class ArrayOp : public framework::OperatorBase { i_tensor.place().GetType() == phi::AllocationType::XPU || i_tensor.place().GetType() == phi::AllocationType::CUSTOM) { // FIXME: Avoid copy from GPU to CPU - phi::DenseTensor t; + DenseTensor t; phi::Copy(dev_ctx, i_tensor, phi::CPUPlace(), false, &t); dev_ctx.Wait(); offset = static_cast(*t.data()); diff --git a/paddle/fluid/operators/assert_op.cc b/paddle/fluid/operators/assert_op.cc index 40b2aae95c617e..5c485013829f73 100644 --- a/paddle/fluid/operators/assert_op.cc +++ b/paddle/fluid/operators/assert_op.cc @@ -59,7 +59,7 @@ class AssertOp : public framework::OperatorBase { PADDLE_ENFORCE_NOT_NULL( cond_var_ptr, common::errors::NotFound("Input(Condition) of AssertOp is not found.")); - const phi::DenseTensor &cond = cond_var_ptr->Get(); + const DenseTensor &cond = cond_var_ptr->Get(); PADDLE_ENFORCE_EQ( cond.numel(), 1, @@ -79,7 +79,7 @@ class AssertOp : public framework::OperatorBase { const std::vector &x_names = Inputs(kData.data()); for (const std::string &name : x_names) { const framework::Variable *x_var_ptr = scope.FindVar(name); - const phi::DenseTensor &x_tensor = x_var_ptr->Get(); + const DenseTensor &x_tensor = x_var_ptr->Get(); formatter.Print(x_tensor, name); } diff --git a/paddle/fluid/operators/assign_op.h b/paddle/fluid/operators/assign_op.h index 8290f3e2e17c12..467fb217861d6b 100644 --- a/paddle/fluid/operators/assign_op.h +++ b/paddle/fluid/operators/assign_op.h @@ -36,8 +36,8 @@ class AssignFunctor { AssignFunctor(framework::Variable *out, const phi::DeviceContext &dev_ctx) : out_(out), dev_ctx_(dev_ctx) {} - void operator()(const phi::DenseTensor &lod_tensor) const { - auto &out_tensor = *out_->GetMutable(); + void operator()(const DenseTensor &lod_tensor) const { + auto &out_tensor = *out_->GetMutable(); copy_tensor(lod_tensor, &out_tensor); } @@ -68,8 +68,7 @@ class AssignFunctor { } private: - void copy_tensor(const phi::DenseTensor &lod_tensor, - phi::DenseTensor *out) const { + void copy_tensor(const DenseTensor &lod_tensor, DenseTensor *out) const { if (!lod_tensor.IsInitialized()) return; auto &out_tensor = *out; paddle::framework::TensorCopy(lod_tensor, lod_tensor.place(), &out_tensor); diff --git a/paddle/fluid/operators/batch_norm_op.cc b/paddle/fluid/operators/batch_norm_op.cc index cae59f38004c63..52b3cd1e0a0934 100644 --- a/paddle/fluid/operators/batch_norm_op.cc +++ b/paddle/fluid/operators/batch_norm_op.cc @@ -188,24 +188,22 @@ phi::KernelKey BatchNormOp::GetExpectedKernelType( PADDLE_ENFORCE_EQ( bn_param_type, framework::TransToProtoVarType( - ctx.Input("Scale")->dtype()), + ctx.Input("Scale")->dtype()), common::errors::InvalidArgument("Scale input should be of float type")); } if (ctx.HasInput("Bias")) { PADDLE_ENFORCE_EQ( bn_param_type, - framework::TransToProtoVarType( - ctx.Input("Bias")->dtype()), + framework::TransToProtoVarType(ctx.Input("Bias")->dtype()), common::errors::InvalidArgument("Bias input should be of float type")); } PADDLE_ENFORCE_EQ( bn_param_type, - framework::TransToProtoVarType( - ctx.Input("Mean")->dtype()), + framework::TransToProtoVarType(ctx.Input("Mean")->dtype()), common::errors::InvalidArgument("Mean input should be of float type")); PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Variance")->dtype()), + ctx.Input("Variance")->dtype()), common::errors::InvalidArgument( "Variance input should be of float type")); return phi::KernelKey(input_data_type, ctx.GetPlace()); @@ -213,7 +211,7 @@ phi::KernelKey BatchNormOp::GetExpectedKernelType( phi::KernelKey BatchNormOp::GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const { #ifdef PADDLE_WITH_DNNL // Only input require reshaping, weights and @@ -387,9 +385,9 @@ phi::KernelKey BatchNormGradOp::GetExpectedKernelType( PADDLE_THROW( common::errors::InvalidArgument("can't find gradient variable of Y")); } - const phi::DenseTensor *t = nullptr; - if (var->IsType()) { - t = &var->Get(); + const DenseTensor *t = nullptr; + if (var->IsType()) { + t = &var->Get(); } if (t == nullptr) { PADDLE_THROW( @@ -402,7 +400,7 @@ phi::KernelKey BatchNormGradOp::GetExpectedKernelType( phi::KernelKey BatchNormGradOp::GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const { #ifdef PADDLE_WITH_DNNL // Only input require reshaping, weights and @@ -529,9 +527,9 @@ phi::KernelKey BatchNormDoubleGradOp::GetExpectedKernelType( PADDLE_THROW( common::errors::NotFound("cannot find gradient variable of Y")); } - const phi::DenseTensor *t = nullptr; - if (var->IsType()) { - t = &var->Get(); + const DenseTensor *t = nullptr; + if (var->IsType()) { + t = &var->Get(); } if (t == nullptr) { PADDLE_THROW( diff --git a/paddle/fluid/operators/beam_search_decode_op.h b/paddle/fluid/operators/beam_search_decode_op.h index 62dd771128607b..c843046dae3bb8 100644 --- a/paddle/fluid/operators/beam_search_decode_op.h +++ b/paddle/fluid/operators/beam_search_decode_op.h @@ -43,7 +43,7 @@ struct BeamSearchDecodeFunctor { auto* dev_ctx = pool.Get(step_ids_origin_[0].place()); // Copy all tensors in the input tensor array for (auto& step_id : step_ids_origin_) { - phi::DenseTensor out; + DenseTensor out; if (step_id.numel() > 0) { if (tensor_on_gpu_) { dev_ctx->Wait(); @@ -65,7 +65,7 @@ struct BeamSearchDecodeFunctor { auto* dev_ctx = pool.Get(step_scores_origin_[0].place()); // Copy all tensors in the input tensor array for (auto& step_score : step_scores_origin_) { - phi::DenseTensor out; + DenseTensor out; if (step_score.numel() > 0) { if (tensor_on_gpu_) { dev_ctx->Wait(); diff --git a/paddle/fluid/operators/beam_search_decode_op_def.h b/paddle/fluid/operators/beam_search_decode_op_def.h index 0cea29a9b48d5d..2a459ccb81aaf6 100644 --- a/paddle/fluid/operators/beam_search_decode_op_def.h +++ b/paddle/fluid/operators/beam_search_decode_op_def.h @@ -53,8 +53,8 @@ struct BeamSearchDecoder { * with word score. * Param: * sentence_vector_list: sentence_vector for each source sentence. - * id_tensor: result phi::DenseTensor for sentences of id. - * score_tensor: result phi::DenseTensor for sentences of score. + * id_tensor: result DenseTensor for sentences of id. + * score_tensor: result DenseTensor for sentences of score. * reverse: whether ids of sentence in sentence_vector_list is reversed * sort_by_score: whether to sort hypotheses of each sentence by scores. */ diff --git a/paddle/fluid/operators/cast_op.cc b/paddle/fluid/operators/cast_op.cc index 4a87fcaf5f824b..d54fafacbed952 100644 --- a/paddle/fluid/operators/cast_op.cc +++ b/paddle/fluid/operators/cast_op.cc @@ -91,7 +91,7 @@ class CastOp : public framework::OperatorWithKernel { phi::KernelKey GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { // CastOp kernel's device type is decided by input tensor place - auto *tensor = ctx.Input("X"); + auto *tensor = ctx.Input("X"); PADDLE_ENFORCE_EQ(tensor->IsInitialized(), true, common::errors::PreconditionNotMet( diff --git a/paddle/fluid/operators/collective/recv_v2_op.cu.cc b/paddle/fluid/operators/collective/recv_v2_op.cu.cc index ab866f015cd06f..8fa6b3ae6060b2 100644 --- a/paddle/fluid/operators/collective/recv_v2_op.cu.cc +++ b/paddle/fluid/operators/collective/recv_v2_op.cu.cc @@ -48,7 +48,7 @@ phi::DDim recv_shape_info(const phi::Place &place, phi::DataType shape_dtype = phi::DataType::INT32; // step1: recv the shape size - phi::DenseTensor gpu_shape_size_tensor(shape_dtype); + DenseTensor gpu_shape_size_tensor(shape_dtype); if (!group) { gpu_shape_size_tensor.Resize({1}); gpu_shape_size_tensor.mutable_data(place, shape_dtype); @@ -57,11 +57,11 @@ phi::DDim recv_shape_info(const phi::Place &place, } // copy the shape size tensor to cpu - phi::DenseTensor *cpu_shape_size_tensor = new phi::DenseTensor(shape_dtype); + DenseTensor *cpu_shape_size_tensor = new phi::DenseTensor(shape_dtype); cpu_shape_size_tensor->Resize({1}); cpu_shape_size_tensor->mutable_data(phi::CPUPlace(), shape_dtype); if (group) { - std::vector shape_size_tensor; + std::vector shape_size_tensor; shape_size_tensor.emplace_back(*cpu_shape_size_tensor); auto shape_size_task = group->Recv(shape_size_tensor, peer); } else { @@ -73,7 +73,7 @@ phi::DDim recv_shape_info(const phi::Place &place, VLOG(3) << "recv the shape size: " << shape_size << " from peer"; // step2: recv the shape - phi::DenseTensor gpu_shape_tensor(shape_dtype); + DenseTensor gpu_shape_tensor(shape_dtype); if (!group) { gpu_shape_tensor.Resize({shape_size}); gpu_shape_tensor.mutable_data(place, shape_dtype); @@ -81,11 +81,11 @@ phi::DDim recv_shape_info(const phi::Place &place, } // copy the shape tensor to cpu - phi::DenseTensor *cpu_shape_tensor = new phi::DenseTensor(shape_dtype); + DenseTensor *cpu_shape_tensor = new phi::DenseTensor(shape_dtype); cpu_shape_tensor->Resize({shape_size}); cpu_shape_tensor->mutable_data(phi::CPUPlace(), shape_dtype); if (group) { - std::vector shape_tensor; + std::vector shape_tensor; shape_tensor.emplace_back(*cpu_shape_tensor); auto shape_task = group->Recv(shape_tensor, peer); } else { @@ -132,9 +132,9 @@ class RecvOpV2CUDAKernel : public framework::OpKernel { if (map->has(rid)) { // Use ProcessGroup distributed::ProcessGroup *pg = map->get(rid); - std::vector out_tensor; + std::vector out_tensor; auto out_shape = ctx.Attr>("out_shape"); - auto out = ctx.Output("Out"); + auto out = ctx.Output("Out"); // auto out_dims = out->dims(); if (dynamic_shape) { @@ -185,7 +185,7 @@ class RecvOpV2CUDAKernel : public framework::OpKernel { } auto out_shape = ctx.Attr>("out_shape"); - auto out = ctx.Output("Out"); + auto out = ctx.Output("Out"); // auto out_dims = out->dims(); auto numel = out->numel(); diff --git a/paddle/fluid/operators/collective/send_v2_op.cu.cc b/paddle/fluid/operators/collective/send_v2_op.cu.cc index 28c126d2f2f6fc..f7720671d29afa 100644 --- a/paddle/fluid/operators/collective/send_v2_op.cu.cc +++ b/paddle/fluid/operators/collective/send_v2_op.cu.cc @@ -49,14 +49,14 @@ void send_shape_info(const phi::DenseTensor& x, int shape_size = dims.size(); // step1: send the shape size - phi::DenseTensor cpu_shape_size_tensor(shape_dtype); + DenseTensor cpu_shape_size_tensor(shape_dtype); cpu_shape_size_tensor.Resize({1}); cpu_shape_size_tensor.mutable_data(phi::CPUPlace(), shape_dtype); auto* cpu_data = cpu_shape_size_tensor.data(); cpu_data[0] = shape_size; if (group) { - std::vector shape_size_tensor; + std::vector shape_size_tensor; shape_size_tensor.template emplace_back(cpu_shape_size_tensor); auto shape_size_task = group->Send(shape_size_tensor, peer); } else { @@ -71,7 +71,7 @@ void send_shape_info(const phi::DenseTensor& x, VLOG(3) << "send the shape size: " << shape_size << " to peer"; // step2: send the shape - phi::DenseTensor cpu_shape_tensor(shape_dtype); + DenseTensor cpu_shape_tensor(shape_dtype); cpu_shape_tensor.Resize({shape_size}); cpu_shape_tensor.mutable_data(phi::CPUPlace(), shape_dtype); auto* cpu_shape_data = cpu_shape_tensor.data(); @@ -80,7 +80,7 @@ void send_shape_info(const phi::DenseTensor& x, } if (group) { - std::vector shape_tensor; + std::vector shape_tensor; shape_tensor.template emplace_back(cpu_shape_tensor); auto shape_task = group->Send(shape_tensor, peer); } else { @@ -119,7 +119,7 @@ class SendOpV2CUDAKernel : public framework::OpKernel { if (map->has(rid)) { // Use ProcessGroup distributed::ProcessGroup* pg = map->get(rid); - auto x = ctx.Input("X"); + auto x = ctx.Input("X"); if (dynamic_shape) { // dynamic shape for switch send/recv @@ -133,7 +133,7 @@ class SendOpV2CUDAKernel : public framework::OpKernel { pg); } - std::vector in_tensor; + std::vector in_tensor; in_tensor.push_back(*x); auto task = pg->Send(in_tensor, peer); return; @@ -168,7 +168,7 @@ class SendOpV2CUDAKernel : public framework::OpKernel { stream = ctx.cuda_device_context().stream(); } - auto x = ctx.Input("X"); + auto x = ctx.Input("X"); int64_t numel = x->numel(); if (dynamic_shape) { diff --git a/paddle/fluid/operators/controlflow/conditional_block_infer_op.cc b/paddle/fluid/operators/controlflow/conditional_block_infer_op.cc index 71249994b851ed..60c677ef64fa21 100644 --- a/paddle/fluid/operators/controlflow/conditional_block_infer_op.cc +++ b/paddle/fluid/operators/controlflow/conditional_block_infer_op.cc @@ -60,10 +60,9 @@ class ConditionalBlockInferOp : public ConditionalOp { // vector or tensor, whether need to execute the operators in sub-block // depends on the input variables (Input). auto xs = InputTensors(scope, "Input"); - need_run = - std::all_of(xs.begin(), xs.end(), [](const phi::DenseTensor *t) { - return t->numel() != 0; - }); + need_run = std::all_of(xs.begin(), xs.end(), [](const DenseTensor *t) { + return t->numel() != 0; + }); } if (need_run) { diff --git a/paddle/fluid/operators/controlflow/conditional_block_op.cc b/paddle/fluid/operators/controlflow/conditional_block_op.cc index 6e0fda76ae5a3b..27c476111c73cb 100644 --- a/paddle/fluid/operators/controlflow/conditional_block_op.cc +++ b/paddle/fluid/operators/controlflow/conditional_block_op.cc @@ -60,10 +60,9 @@ class ConditionalBlockOp : public ConditionalOp { // vector or tensor, whether need to execute the operators in sub-block // depends on the input variables (Input). auto xs = InputTensors(scope, ConditionalOp::kInputs); - need_run = - std::all_of(xs.begin(), xs.end(), [](const phi::DenseTensor *t) { - return t->numel() != 0; - }); + need_run = std::all_of(xs.begin(), xs.end(), [](const DenseTensor *t) { + return t->numel() != 0; + }); } if (need_run) { @@ -158,10 +157,9 @@ class ConditionalBlockGradOp : public ConditionalOp { need_run = ScalarCondition(xs); } else { auto xs = this->InputTensors(scope, ConditionalOp::kInputs); - need_run = - std::all_of(xs.begin(), xs.end(), [](const phi::DenseTensor *t) { - return t->numel() != 0; - }); + need_run = std::all_of(xs.begin(), xs.end(), [](const DenseTensor *t) { + return t->numel() != 0; + }); } const auto &inputs = Inputs(ConditionalOp::kInputs); @@ -281,7 +279,7 @@ class ConditionalBlockGradInferShape : public framework::InferShapeBase { class ConditionalBlockGradInferVarType : public framework::VarTypeInference { public: void operator()(framework::InferVarTypeContext *ctx) const override { - // NOTE(Aurelius84): VarType of Output is phi::DenseTensor by default. In + // NOTE(Aurelius84): VarType of Output is DenseTensor by default. In // case of Input is {Tensor, DenseTensorArray}, we need synchronous the // Input's VarType into Input@GRAD to avoid generating {Tensor, Tensor} as // Input@GRAD. diff --git a/paddle/fluid/operators/controlflow/conditional_block_op.h b/paddle/fluid/operators/controlflow/conditional_block_op.h index 73de26d594c755..039cde0f585dcb 100644 --- a/paddle/fluid/operators/controlflow/conditional_block_op.h +++ b/paddle/fluid/operators/controlflow/conditional_block_op.h @@ -41,26 +41,26 @@ class ConditionalOp : public framework::OperatorBase { static const char kSkipEagerDeletionVars[]; protected: - std::vector InputTensors( + std::vector InputTensors( const framework::Scope &scope, const std::string &in_name) const { - std::vector retv; + std::vector retv; auto xs = Inputs(in_name); retv.resize(xs.size(), nullptr); std::transform( xs.begin(), xs.end(), retv.begin(), - [&scope](const std::string &var_name) -> const phi::DenseTensor * { + [&scope](const std::string &var_name) -> const DenseTensor * { auto *var = scope.FindVar(var_name); PADDLE_ENFORCE_NOT_NULL(var, common::errors::InvalidArgument( "Cannot find variable %s", var_name)); - return &var->Get(); + return &var->Get(); }); return retv; } - bool ScalarCondition(const std::vector &ips) const { + bool ScalarCondition(const std::vector &ips) const { PADDLE_ENFORCE_EQ( ips.size() == 1UL && ips[0]->IsInitialized(), true, @@ -78,21 +78,21 @@ class ConditionalOp : public framework::OperatorBase { bool res = false; if (ips[0]->place().GetType() == phi::AllocationType::GPU) { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - phi::DenseTensor cpu_tensor; + DenseTensor cpu_tensor; framework::TensorCopy(*ips[0], phi::CPUPlace(), &cpu_tensor); phi::DeviceContextPool::Instance().Get(ips[0]->place())->Wait(); res = cpu_tensor.data()[0]; #endif } else if (ips[0]->place().GetType() == phi::AllocationType::XPU) { #ifdef PADDLE_WITH_XPU - phi::DenseTensor cpu_tensor; + DenseTensor cpu_tensor; framework::TensorCopy(*ips[0], phi::CPUPlace(), &cpu_tensor); phi::DeviceContextPool::Instance().Get(ips[0]->place())->Wait(); res = cpu_tensor.data()[0]; #endif } else if (ips[0]->place().GetType() == phi::AllocationType::CUSTOM) { #if defined(PADDLE_WITH_CUSTOM_DEVICE) - phi::DenseTensor cpu_tensor; + DenseTensor cpu_tensor; framework::TensorCopy(*ips[0], phi::CPUPlace(), &cpu_tensor); phi::DeviceContextPool::Instance().Get(ips[0]->place())->Wait(); res = cpu_tensor.data()[0]; diff --git a/paddle/fluid/operators/controlflow/control_flow_op_helper.h b/paddle/fluid/operators/controlflow/control_flow_op_helper.h index 52039c1049b958..4e622d6a9db018 100644 --- a/paddle/fluid/operators/controlflow/control_flow_op_helper.h +++ b/paddle/fluid/operators/controlflow/control_flow_op_helper.h @@ -58,8 +58,8 @@ static void BuildScopeForControlFlowOp( static void AssignZeroToOutsideTensor(const phi::Place &place, const framework::Scope &cur_scope, - const phi::DenseTensor &input_tensor, - phi::DenseTensor *outside_tensor) { + const DenseTensor &input_tensor, + DenseTensor *outside_tensor) { if (!input_tensor.IsInitialized() || input_tensor.numel() == 0) { return; } @@ -92,9 +92,9 @@ static void AssignZeroToParentScope( continue; } - if (input_var->IsType()) { + if (input_var->IsType()) { PADDLE_ENFORCE_EQ( - outside_var->IsType(), + outside_var->IsType(), true, common::errors::InvalidArgument( "Type of outside_var %s is NOT phi::DenseTensor, which " @@ -103,8 +103,8 @@ static void AssignZeroToParentScope( input_name)); AssignZeroToOutsideTensor(place, scope, - input_var->Get(), - outside_var->GetMutable()); + input_var->Get(), + outside_var->GetMutable()); } else if (input_var->IsType()) { PADDLE_ENFORCE_EQ(outside_var->IsType(), true, @@ -132,7 +132,7 @@ static void AssignZeroToParentScope( } else { // TODO(huihuangzheng): add support for SelectedRows PADDLE_THROW(common::errors::InvalidArgument( - "Conditional block grad op doesn't support non-phi::DenseTensor " + "Conditional block grad op doesn't support non-DenseTensor " "output " "now.")); } diff --git a/paddle/fluid/operators/controlflow/feed_op.cc b/paddle/fluid/operators/controlflow/feed_op.cc index 780b20f6e3e640..ee1fc14bf811ed 100644 --- a/paddle/fluid/operators/controlflow/feed_op.cc +++ b/paddle/fluid/operators/controlflow/feed_op.cc @@ -70,7 +70,7 @@ class FeedOp : public framework::OperatorWithKernel { const auto& feed_item = CheckAndGetFeedItem(x, col); auto& feed_tensor = feed_item; - phi::DenseTensor* out_tensor = out_var->GetMutable(); + phi::DenseTensor* out_tensor = out_var->GetMutable(); phi::DenseTensorMeta meta = out_tensor->meta(); meta.dims = feed_tensor.dims(); meta.dtype = feed_tensor.dtype(); @@ -103,11 +103,11 @@ class FeedOpInfoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(vector) " + "(vector) " "A feeding list of phi::DenseTensor, which may have " "different dimension and data type."); AddOutput("Out", - "(phi::DenseTensor) The phi::DenseTensor which is a copy " + "(phi::DenseTensor) The DenseTensor which is a copy " "of the col-th feeding " "object."); AddAttr("col", "(int) The column index of current feeding object."); diff --git a/paddle/fluid/operators/controlflow/fetch_op.cc b/paddle/fluid/operators/controlflow/fetch_op.cc index 237c7328836b50..e76270ce4f0b9d 100644 --- a/paddle/fluid/operators/controlflow/fetch_op.cc +++ b/paddle/fluid/operators/controlflow/fetch_op.cc @@ -23,14 +23,14 @@ namespace operators { // FIXME(yuyang18): Should we assume the fetch operator always generate // CPU outputs? -static void DataCopy(const phi::DenseTensor &src_item, +static void DataCopy(const DenseTensor &src_item, const std::string &fetch_var_name, - phi::DenseTensor *dst_item) { + DenseTensor *dst_item) { if (src_item.IsInitialized() && src_item.numel() > 0) { #ifdef PADDLE_WITH_DNNL // Conversion from MKL-DNN to Paddle if (src_item.layout() == phi::DataLayout::ONEDNN) { - phi::DenseTensor out; + DenseTensor out; // Convert to desired Paddle layout, apart from grads of filter // as params are not a subject to paddle's data_format VLOG(4) << "TransDataLayoutFromOneDNN"; @@ -113,8 +113,8 @@ class FetchOp : public framework::OperatorBase { fetch_list->resize(col + 1); } - if (fetch_var->IsType()) { - auto &src_item = fetch_var->Get(); + if (fetch_var->IsType()) { + auto &src_item = fetch_var->Get(); auto *dst_item = &(PADDLE_GET(phi::DenseTensor, fetch_list->at(col))); DataCopy(src_item, fetch_var_name, dst_item); } else if (fetch_var->IsType()) { @@ -140,12 +140,12 @@ class FetchOpInfoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(phi::DenseTensor) The resulted phi::DenseTensor which is " + "(phi::DenseTensor) The resulted DenseTensor which is " "expected to return " "to users."); AddOutput( "Out", - "(vector|unordered_map) A fetching " + "(vector|unordered_map) A fetching " "list" " of phi::DenseTensor|unordered_map which may have " "different dimension, shape and data type."); diff --git a/paddle/fluid/operators/controlflow/fetch_v2_op.cc b/paddle/fluid/operators/controlflow/fetch_v2_op.cc index efc51b38d4d763..7f9a6e97f8584a 100644 --- a/paddle/fluid/operators/controlflow/fetch_v2_op.cc +++ b/paddle/fluid/operators/controlflow/fetch_v2_op.cc @@ -31,14 +31,14 @@ class OpBase; namespace paddle { namespace operators { -static void DeepCopy(const phi::DenseTensor &src_item, +static void DeepCopy(const DenseTensor &src_item, const std::string &fetch_var_name, - phi::DenseTensor *dst_item) { + DenseTensor *dst_item) { if (src_item.IsInitialized()) { #ifdef PADDLE_WITH_DNNL // Conversion from MKL-DNN to Paddle if (src_item.layout() == phi::DataLayout::ONEDNN) { - phi::DenseTensor out; + DenseTensor out; // Convert to desired Paddle layout, apart from grads of filter // as params are not a subject to paddle's data_format phi::funcs::TransDataLayoutFromOneDNN( @@ -71,7 +71,7 @@ class FetchV2Op : public framework::OperatorWithKernel { protected: phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (!tensor.IsInitialized()) { return phi::KernelKey(phi::Backend::ALL_BACKEND, @@ -89,8 +89,8 @@ class FetchV2Op : public framework::OperatorWithKernel { return phi::KernelKey(framework::proto::VarType::FP32, phi::CPUPlace()); } - if (fetch_var->IsType()) { - auto &src_item = fetch_var->Get(); + if (fetch_var->IsType()) { + auto &src_item = fetch_var->Get(); if (!src_item.IsInitialized()) { return phi::KernelKey(framework::proto::VarType::FP32, phi::CPUPlace()); } @@ -146,8 +146,8 @@ class FetchV2Kernel { bool deepcopy = ctx.Attr("deepcopy"); - if (fetch_var->IsType()) { - auto &src_item = fetch_var->Get(); + if (fetch_var->IsType()) { + auto &src_item = fetch_var->Get(); if (!src_item.IsInitialized()) { return; } @@ -199,11 +199,11 @@ class FetchV2OpProtoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(phi::DenseTensor) The resulted phi::DenseTensor which is " + "(phi::DenseTensor) The resulted DenseTensor which is " "expected to return " "to users."); AddOutput("Out", - "(vector) A fetching list of phi::DenseTensor " + "(vector) A fetching list of DenseTensor " "which may have " "different dimension, shape and data type."); AddAttr("col", "(int) The column index of fetching object."); diff --git a/paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc b/paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc index aacb854ea57e81..a7dbb44688391a 100644 --- a/paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc +++ b/paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc @@ -39,7 +39,7 @@ class WriteToArrayOp : public ArrayOp { const phi::Place &place) const override { auto *x = scope.FindVar(Input("X")); if (x == nullptr) return; - auto &x_tensor = x->Get(); + auto &x_tensor = x->Get(); size_t offset = GetOffset(scope, place); auto *out = scope.FindVar(Output("Out"))->GetMutable(); if (offset >= out->size()) { @@ -75,7 +75,7 @@ class WriteToArrayOpProtoMaker : public framework::OpProtoAndCheckerMaker { AddComment(R"DOC( WriteToArray Operator. -This operator writes a phi::DenseTensor to a phi::DenseTensor array. +This operator writes a DenseTensor to a DenseTensor array. Assume $T$ is phi::DenseTensor, $i$ is the subscript of the array, and $A$ is the array. The equation is @@ -157,7 +157,7 @@ class ReadFromArrayOp : public ArrayOp { "Output(Out) of ReadFromArrayOp is not found.")); size_t offset = GetOffset(scope, place); if (offset < x_array.size()) { - auto *out_tensor = out->GetMutable(); + auto *out_tensor = out->GetMutable(); phi::DeviceContextPool &pool = phi::DeviceContextPool::Instance(); auto &dev_ctx = *pool.Get(place); framework::TensorCopy(x_array[offset], place, dev_ctx, out_tensor); @@ -167,7 +167,7 @@ class ReadFromArrayOp : public ArrayOp { // set grad of the written tensor to 0 when used as write_to_array_grad auto *fw_var = scope.FindVar(Input("X_W")); if (fw_var == nullptr) return; - auto &fw_var_tensor = fw_var->Get(); + auto &fw_var_tensor = fw_var->Get(); framework::AttributeMap attrs; attrs["dtype"] = framework::TransToProtoVarType(fw_var_tensor.dtype()); @@ -177,7 +177,7 @@ class ReadFromArrayOp : public ArrayOp { auto zero_op = framework::OpRegistry::CreateOp( "fill_constant", {}, {{"Out", {Output("Out")}}}, attrs); zero_op->Run(scope, place); - auto *out_tensor = out->GetMutable(); + auto *out_tensor = out->GetMutable(); out_tensor->set_lod(fw_var_tensor.lod()); } } @@ -198,7 +198,7 @@ class ReadFromArrayProtoMaker : public framework::OpProtoAndCheckerMaker { AddComment(R"DOC( ReadFromArray Operator. -Read a phi::DenseTensor from a phi::DenseTensor Array. +Read a DenseTensor from a DenseTensor Array. Assume $T$ is phi::DenseTensor, $i$ is the subscript of the array, and $A$ is the array. The equation is diff --git a/paddle/fluid/operators/controlflow/while_op.cc b/paddle/fluid/operators/controlflow/while_op.cc index b3bce4ec7b2284..fdca1b157cc792 100644 --- a/paddle/fluid/operators/controlflow/while_op.cc +++ b/paddle/fluid/operators/controlflow/while_op.cc @@ -65,7 +65,7 @@ class WhileOp : public framework::OperatorBase { scope.FindVar(Input(kCondition)), common::errors::NotFound("Input(Condition) of WhileOp is not found.")); - auto &cond = scope.FindVar(Input(kCondition))->Get(); + auto &cond = scope.FindVar(Input(kCondition))->Get(); PADDLE_ENFORCE_EQ( cond.numel(), 1, @@ -155,8 +155,7 @@ class WhileOp : public framework::OperatorBase { } if (var->Type() == framework::proto::VarType::DENSE_TENSOR) { - input_var_original_places[in_name] = - (var->Get()).place(); + input_var_original_places[in_name] = (var->Get()).place(); } else { VLOG(10) << "[while op]" << "skip backup input " << in_name << " type:" @@ -200,12 +199,12 @@ class WhileOp : public framework::OperatorBase { no_copy_var_names.end()) { std::string input_var_rename = input_var_name + kSuffix; framework::Variable *input_var = scope.FindVar(input_var_name); - if (input_var->IsType()) { + if (input_var->IsType()) { rename_vars.push_back(input_var_rename); - auto input_var_tensor = input_var->Get(); + auto input_var_tensor = input_var->Get(); auto *rename_input_var_tensor = current_scope.Var(input_var_rename) - ->GetMutable(); + ->GetMutable(); framework::TensorCopy( input_var_tensor, dev_place, rename_input_var_tensor); rename_input_var_tensor->set_lod(input_var_tensor.lod()); @@ -230,8 +229,8 @@ class WhileOp : public framework::OperatorBase { var_rename.substr(0, var_rename.size() - strlen(kSuffix)); current_scope.Rename(var_rename, input_var_name); } - cond_data = GetCondData( - scope.FindVar(Input(kCondition))->Get()); + cond_data = + GetCondData(scope.FindVar(Input(kCondition))->Get()); } } else { framework::Scope *current_scope = nullptr; @@ -251,9 +250,9 @@ class WhileOp : public framework::OperatorBase { while (cond_data) { for (auto &name : current_scope->LocalVarNames()) { auto *var = current_scope->Var(name); - if (var->IsType()) { + if (var->IsType()) { // Clear all lod information for all lod_tensors. - auto *t = var->GetMutable(); + auto *t = var->GetMutable(); phi::LegacyLoD empty_lod; t->set_lod(empty_lod); } else if (var->IsType()) { @@ -265,8 +264,8 @@ class WhileOp : public framework::OperatorBase { core_->Run({}, false); - cond_data = GetCondData( - scope.FindVar(Input(kCondition))->Get()); + cond_data = + GetCondData(scope.FindVar(Input(kCondition))->Get()); } if (!FLAGS_cache_inference_while_scope) { @@ -390,8 +389,8 @@ class WhileGradOp : public framework::OperatorBase { if (cur_scope_iter == step_scopes->rbegin()) { auto &og_outside = *scope.FindVar(outside_og_name); - if (og_outside.IsType() && - !og_outside.GetMutable()->IsInitialized()) { + if (og_outside.IsType() && + !og_outside.GetMutable()->IsInitialized()) { auto *var_desc = parent_block->FindVarRecursive(outside_og_name); PADDLE_ENFORCE_NOT_NULL(var_desc, common::errors::PreconditionNotMet( @@ -419,9 +418,9 @@ class WhileGradOp : public framework::OperatorBase { auto &og_outside = *scope.FindVar(outside_og_name); auto &og_inside = *cur_scope.Var(inside_og_name); - if (og_outside.IsType()) { - auto &outside_tensor = og_outside.Get(); - auto &inside_tensor = *og_inside.GetMutable(); + if (og_outside.IsType()) { + auto &outside_tensor = og_outside.Get(); + auto &inside_tensor = *og_inside.GetMutable(); inside_tensor.set_lod(outside_tensor.lod()); inside_tensor.ShareDataWith(outside_tensor); } else if (og_outside.IsType()) { @@ -453,7 +452,7 @@ class WhileGradOp : public framework::OperatorBase { } } else { PADDLE_THROW(common::errors::Unimplemented( - "Currently only support phi::DenseTensor and " + "Currently only support DenseTensor and " "phi::DenseTensorArray in " "WhileGradOp.")); } @@ -528,8 +527,7 @@ class WhileGradOp : public framework::OperatorBase { common::errors::NotFound("Variable %s is not found.", inside_grad_name)); PADDLE_ENFORCE_EQ( - var->IsType() || - var->IsType(), + var->IsType() || var->IsType(), true, common::errors::InvalidArgument( "Currently the type of var only can be phi::TensorArray, " @@ -537,8 +535,8 @@ class WhileGradOp : public framework::OperatorBase { inside_grad_name, framework::ToTypeName(var->Type()))); - if (!is_var_input_and_output && var->IsType()) { - auto &inside_tensor = var->Get(); + if (!is_var_input_and_output && var->IsType()) { + auto &inside_tensor = var->Get(); framework::AttributeMap attrs; attrs["dtype"] = framework::TransToProtoVarType(inside_tensor.dtype()); @@ -552,7 +550,7 @@ class WhileGradOp : public framework::OperatorBase { {{"Out", {var_name}}}, attrs); zero_op->Run(scope, dev_place); - scope.FindVar(var_name)->GetMutable()->set_lod( + scope.FindVar(var_name)->GetMutable()->set_lod( inside_tensor.lod()); } } @@ -580,10 +578,10 @@ class WhileGradOp : public framework::OperatorBase { std::string name) const { auto from_var = source.FindVar(name); auto to_var = dest.FindVar(name); - if (from_var->IsType()) { - if (from_var->Get().IsInitialized()) { - to_var->GetMutable()->ShareDataWith( - from_var->Get()); + if (from_var->IsType()) { + if (from_var->Get().IsInitialized()) { + to_var->GetMutable()->ShareDataWith( + from_var->Get()); } } else if (from_var->IsType()) { auto from_arr = from_var->GetMutable(); diff --git a/paddle/fluid/operators/controlflow/while_op_helper.cc b/paddle/fluid/operators/controlflow/while_op_helper.cc index e56eb0848b2b53..62edc67789a588 100644 --- a/paddle/fluid/operators/controlflow/while_op_helper.cc +++ b/paddle/fluid/operators/controlflow/while_op_helper.cc @@ -217,13 +217,13 @@ void PrepareSafeEagerDeletionOnWhileOpAndWhileGradOp( } // Make while_op could run on GPU place -bool GetCondData(const phi::DenseTensor &cond) { +bool GetCondData(const DenseTensor &cond) { if (cond.place().GetType() == phi::AllocationType::CPU) { return cond.data()[0]; } // when cond.place().GetType() == phi::AllocationType::GPU or // cond.place().GetType() == phi::AllocationType::XPU is true - std::unique_ptr cpu_cond{new phi::DenseTensor()}; + std::unique_ptr cpu_cond{new phi::DenseTensor()}; #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) || \ defined(PADDLE_WITH_XPU) || defined(PADDLE_WITH_CUSTOM_DEVICE) framework::TensorCopySync(cond, phi::CPUPlace(), cpu_cond.get()); @@ -262,14 +262,14 @@ void TransferVariablePlace(const framework::Scope *scope, << phi::TransToPhiDataType(framework::ToVarType(var->Type())); return; } - phi::DenseTensor *t = var->GetMutable(); + DenseTensor *t = var->GetMutable(); if (t->place() == dst_place) { VLOG(10) << "[TransferVariablePlace]" << "no need transfer: " << var_name; return; } - phi::DenseTensor *new_t = new phi::DenseTensor; + DenseTensor *new_t = new phi::DenseTensor; framework::TensorCopy(*t, dst_place, new_t); dev_ctx.Wait(); diff --git a/paddle/fluid/operators/controlflow/while_op_helper.h b/paddle/fluid/operators/controlflow/while_op_helper.h index df43f64260c27f..cbf35b5b6a16c3 100644 --- a/paddle/fluid/operators/controlflow/while_op_helper.h +++ b/paddle/fluid/operators/controlflow/while_op_helper.h @@ -54,7 +54,7 @@ void PrepareSafeEagerDeletionOnWhileOpAndWhileGradOp( const std::vector &while_ops, const std::vector &while_grad_ops); -bool GetCondData(const phi::DenseTensor &cond); +bool GetCondData(const DenseTensor &cond); bool StrInVariableNameMap(const std::string &, const framework::VariableNameMap &); diff --git a/paddle/fluid/operators/elementwise/elementwise_add_op.cc b/paddle/fluid/operators/elementwise/elementwise_add_op.cc index dd693c720c203d..06206c50f1f9d8 100644 --- a/paddle/fluid/operators/elementwise/elementwise_add_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_add_op.cc @@ -33,17 +33,15 @@ class ElementwiseAddOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X + Y"; } void AddInputX() override { - AddInput( - "X", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("X", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput( - "Y", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("Y", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFunctionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_div_op.cc b/paddle/fluid/operators/elementwise/elementwise_div_op.cc index a888c30109963d..784965b3ba45d2 100644 --- a/paddle/fluid/operators/elementwise/elementwise_div_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_div_op.cc @@ -31,17 +31,15 @@ class ElementwiseDivOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X / Y"; } void AddInputX() override { - AddInput( - "X", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("X", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput( - "Y", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("Y", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFunctionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc index a3570f5a2a1606..0a55e5619b9a4d 100644 --- a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc @@ -31,17 +31,15 @@ class ElementwiseMulOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X \\\\odot Y"; } void AddInputX() override { - AddInput( - "X", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("X", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput( - "Y", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("Y", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFunctionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_op.h b/paddle/fluid/operators/elementwise/elementwise_op.h index 86fbc9a76c1a11..8ca9f6fb92590c 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op.h +++ b/paddle/fluid/operators/elementwise/elementwise_op.h @@ -158,7 +158,7 @@ class ElementwiseOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name UNUSED, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (framework::IsComplexType(expected_kernel_type.dtype())) { // only promote inputs's types when contains complex input @@ -304,7 +304,7 @@ class ElementwiseOpGrad : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name UNUSED, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (framework::IsComplexType(expected_kernel_type.dtype())) { // only promote inputs's types when contains complex input @@ -345,7 +345,7 @@ class ElementwiseOpDoubleGrad : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name UNUSED, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (framework::IsComplexType(expected_kernel_type.dtype())) { // only promote inputs's types when contains complex input @@ -393,7 +393,7 @@ class ElementwiseOpDoubleGradWithoutDXDY phi::KernelKey GetKernelTypeForVar( const std::string &var_name UNUSED, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (framework::IsComplexType(expected_kernel_type.dtype())) { // only promote inputs's types when contains complex input @@ -441,7 +441,7 @@ class ElementwiseOpTripleGrad : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name UNUSED, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (framework::IsComplexType(expected_kernel_type.dtype())) { // only promote inputs's types when contains complex input @@ -457,9 +457,8 @@ template class ElemwiseGradKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &context) const override { - auto *dx = context.Output(framework::GradVarName("X")); - auto &dout = - *context.Input(framework::GradVarName("Out")); + auto *dx = context.Output(framework::GradVarName("X")); + auto &dout = *context.Input(framework::GradVarName("Out")); phi::funcs::ElementwiseGradPreProcess(dout, dx); } }; diff --git a/paddle/fluid/operators/elementwise/elementwise_sub_op.cc b/paddle/fluid/operators/elementwise/elementwise_sub_op.cc index e2126db86e7e3d..9f6a26317a4453 100644 --- a/paddle/fluid/operators/elementwise/elementwise_sub_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_sub_op.cc @@ -36,17 +36,15 @@ class ElementwiseSubOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X - Y"; } void AddInputX() override { - AddInput( - "X", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("X", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput( - "Y", - "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput("Y", + "(Variable), Tensor or DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFunctionality() const override { diff --git a/paddle/fluid/operators/fill_constant_op.cc b/paddle/fluid/operators/fill_constant_op.cc index 0afc198cf7c191..080ca6fbb476b4 100644 --- a/paddle/fluid/operators/fill_constant_op.cc +++ b/paddle/fluid/operators/fill_constant_op.cc @@ -58,7 +58,7 @@ class FillConstantOp : public framework::OperatorWithKernel { protected: phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "ShapeTensor" || var_name == "ShapeTensorList") { return phi::KernelKey(phi::Backend::ALL_BACKEND, diff --git a/paddle/fluid/operators/fused/fused_adam_op.cc b/paddle/fluid/operators/fused/fused_adam_op.cc index 7a890e3e961503..dab097f2c4eaa8 100644 --- a/paddle/fluid/operators/fused/fused_adam_op.cc +++ b/paddle/fluid/operators/fused/fused_adam_op.cc @@ -35,7 +35,7 @@ class FusedAdamOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "Beta1Pows" || var_name == "Beta2Pows" || var_name == "SkipUpdate") { diff --git a/paddle/fluid/operators/fused/fused_attention_op.cc b/paddle/fluid/operators/fused/fused_attention_op.cc index fc58a32ef7c0aa..1b1c2c46c5a79e 100644 --- a/paddle/fluid/operators/fused/fused_attention_op.cc +++ b/paddle/fluid/operators/fused/fused_attention_op.cc @@ -323,7 +323,7 @@ class FusedAttentionOp : public framework::OperatorWithKernel { protected: phi::KernelKey GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { - auto input = ctx.Input("X"); + auto input = ctx.Input("X"); auto input_data_type = framework::TransToProtoVarType(input->dtype()); return phi::KernelKey(input_data_type, ctx.GetPlace()); } @@ -663,7 +663,7 @@ class FusedAttentionGradOp : public framework::OperatorWithKernel { protected: phi::KernelKey GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { - auto input = ctx.Input("X"); + auto input = ctx.Input("X"); auto input_data_type = framework::TransToProtoVarType(input->dtype()); return phi::KernelKey(input_data_type, ctx.GetPlace()); } diff --git a/paddle/fluid/operators/fused/fused_bn_activation_op.cc b/paddle/fluid/operators/fused/fused_bn_activation_op.cc index a1c48ce1208f22..7f686ec5327be6 100644 --- a/paddle/fluid/operators/fused/fused_bn_activation_op.cc +++ b/paddle/fluid/operators/fused/fused_bn_activation_op.cc @@ -165,24 +165,22 @@ phi::KernelKey FusedBatchNormActOp::GetExpectedKernelType( if (input_data_type == framework::proto::VarType::FP64) { bn_param_type = framework::proto::VarType::FP64; } - PADDLE_ENFORCE_EQ(bn_param_type, - framework::TransToProtoVarType( - ctx.Input("Scale")->dtype()), - common::errors::PreconditionNotMet( - "Scale input should be of float type")); PADDLE_ENFORCE_EQ( bn_param_type, - framework::TransToProtoVarType( - ctx.Input("Bias")->dtype()), + framework::TransToProtoVarType(ctx.Input("Scale")->dtype()), + common::errors::PreconditionNotMet( + "Scale input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Bias")->dtype()), common::errors::PreconditionNotMet("Bias input should be of float type")); PADDLE_ENFORCE_EQ( bn_param_type, - framework::TransToProtoVarType( - ctx.Input("Mean")->dtype()), + framework::TransToProtoVarType(ctx.Input("Mean")->dtype()), common::errors::PreconditionNotMet("Mean input should be of float type")); PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Variance")->dtype()), + ctx.Input("Variance")->dtype()), common::errors::PreconditionNotMet( "Variance input should be of float type")); @@ -299,9 +297,9 @@ phi::KernelKey FusedBatchNormActGradOp::GetExpectedKernelType( PADDLE_THROW(common::errors::NotFound( "Can not find Y@GRAD in the execution context.")); } - const phi::DenseTensor *t = nullptr; - if (var->IsType()) { - t = &var->Get(); + const DenseTensor *t = nullptr; + if (var->IsType()) { + t = &var->Get(); } if (t == nullptr) { PADDLE_THROW( diff --git a/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc b/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc index 744d70fec3329a..b88f43112cc2ac 100644 --- a/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc +++ b/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc @@ -143,13 +143,11 @@ phi::KernelKey FusedBatchNormAddActOp::GetExpectedKernelType( PADDLE_ENFORCE_EQ( bn_param_type, - framework::TransToProtoVarType( - ctx.Input("Scale")->dtype()), + framework::TransToProtoVarType(ctx.Input("Scale")->dtype()), common::errors::InvalidArgument("Scale input should be of float type")); PADDLE_ENFORCE_EQ( bn_param_type, - framework::TransToProtoVarType( - ctx.Input("Bias")->dtype()), + framework::TransToProtoVarType(ctx.Input("Bias")->dtype()), common::errors::InvalidArgument("Bias input should be of float type")); return phi::KernelKey(input_data_type, ctx.GetPlace()); @@ -264,9 +262,9 @@ phi::KernelKey FusedBatchNormAddActGradOp::GetExpectedKernelType( PADDLE_THROW(common::errors::NotFound( "Can not find Y@GRAD in the execution context.")); } - const phi::DenseTensor *t = nullptr; - if (var->IsType()) { - t = &var->Get(); + const DenseTensor *t = nullptr; + if (var->IsType()) { + t = &var->Get(); } if (t == nullptr) { PADDLE_THROW( diff --git a/paddle/fluid/operators/fused/fused_feedforward_op.cc b/paddle/fluid/operators/fused/fused_feedforward_op.cc index 974d4b743c1ec8..b5cd5cf709f921 100644 --- a/paddle/fluid/operators/fused/fused_feedforward_op.cc +++ b/paddle/fluid/operators/fused/fused_feedforward_op.cc @@ -355,7 +355,7 @@ class FusedFeedForwardOpGrad : public framework::OperatorWithKernel { phi::KernelKey GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { - auto input = ctx.Input("X"); + auto input = ctx.Input("X"); auto input_data_type = framework::TransToProtoVarType(input->dtype()); return phi::KernelKey(input_data_type, ctx.GetPlace()); } diff --git a/paddle/fluid/operators/fused/fused_gate_attention_op.cc b/paddle/fluid/operators/fused/fused_gate_attention_op.cc index 717eb990f49f3b..b90873ee248727 100644 --- a/paddle/fluid/operators/fused/fused_gate_attention_op.cc +++ b/paddle/fluid/operators/fused/fused_gate_attention_op.cc @@ -270,7 +270,7 @@ class FusedGateAttentionGradOp : public framework::OperatorWithKernel { protected: phi::KernelKey GetExpectedKernelType( const framework::ExecutionContext& ctx) const override { - auto input = ctx.Input("Query"); + auto input = ctx.Input("Query"); auto input_data_type = framework::TransToProtoVarType(input->dtype()); return phi::KernelKey(input_data_type, ctx.GetPlace()); } diff --git a/paddle/fluid/operators/fused/fused_multi_transformer_int8_op.cc b/paddle/fluid/operators/fused/fused_multi_transformer_int8_op.cc index c4a1ce652c905d..5fa185744d571c 100644 --- a/paddle/fluid/operators/fused/fused_multi_transformer_int8_op.cc +++ b/paddle/fluid/operators/fused/fused_multi_transformer_int8_op.cc @@ -173,7 +173,7 @@ class FusedMultiTransformerINT8Op : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "TimeStep") { VLOG(10) << "var_name:" << var_name << " need not to transform"; diff --git a/paddle/fluid/operators/fused/multi_gru_op.cc b/paddle/fluid/operators/fused/multi_gru_op.cc index d2a262e2bac763..27c4f49e1bbd80 100644 --- a/paddle/fluid/operators/fused/multi_gru_op.cc +++ b/paddle/fluid/operators/fused/multi_gru_op.cc @@ -161,12 +161,11 @@ phi::KernelKey MultiGRUOp::GetExpectedKernelType( } void MultiGRUOpMaker::Make() { - AddInput( - "X", - "(phi::DenseTensor) the input is an DenseTensor, which support " - "variable-time length input sequence. The underlying tensor in " - "this phi::DenseTensor is a matrix with shape (T X M), where T is the " - "total time steps in this mini-batch, M is the dim size of x."); + AddInput("X", + "(phi::DenseTensor) the input is an DenseTensor, which support " + "variable-time length input sequence. The underlying tensor in " + "this DenseTensor is a matrix with shape (T X M), where T is the " + "total time steps in this mini-batch, M is the dim size of x."); AddInput("WeightX", "(MultiTensor) The FC weight with shape (M x 3D)," "where M is the dim size of x, D is the hidden size. ") diff --git a/paddle/fluid/operators/generator/get_expected_kernel_func.cc b/paddle/fluid/operators/generator/get_expected_kernel_func.cc index 4089772637abf0..70bbcf35536565 100644 --- a/paddle/fluid/operators/generator/get_expected_kernel_func.cc +++ b/paddle/fluid/operators/generator/get_expected_kernel_func.cc @@ -31,7 +31,7 @@ static bool ReduceOpHasOptimizedOneDNNKernel( const framework::ExecutionContext& ctx) { // native reduce kernels don't support bf16 // so oneDNN kernel is enforced in that case - if (ctx.Input("X")->dtype() == phi::DataType::BFLOAT16) + if (ctx.Input("X")->dtype() == phi::DataType::BFLOAT16) return true; if (!ctx.HasAttr("dim") || !ctx.HasAttr("reduce_all")) { @@ -40,7 +40,7 @@ static bool ReduceOpHasOptimizedOneDNNKernel( auto reduce_dims = ctx.Attr>("dim"); const bool reduce_all = ctx.Attr("reduce_all"); - int ndims = ctx.Input("X")->dims().size(); + int ndims = ctx.Input("X")->dims().size(); if (reduce_all) { return true; @@ -64,7 +64,7 @@ static bool ReduceOpHasOptimizedOneDNNKernel( bool CanONEDNNSupportPool(const framework::ExecutionContext& ctx) { if (ctx.Attr("adaptive") == false) return true; // oneDNN is supporting only unchangeable in size pool window - auto src_tz = common::vectorize(ctx.Input("X")->dims()); + auto src_tz = common::vectorize(ctx.Input("X")->dims()); if (!ctx.HasAttr("ksize")) { return false; } @@ -88,7 +88,7 @@ phi::KernelKey GetConcatExpectedKernelType( const framework::ExecutionContext& ctx, const framework::OperatorWithKernel* op_ptr) { (void)op_ptr; - auto inputs = ctx.MultiInput("X"); + auto inputs = ctx.MultiInput("X"); auto input_data_type = framework::proto::VarType::Type(0); bool flag = false; for (auto* input : inputs) { @@ -116,7 +116,7 @@ phi::KernelKey GetReduceExpectedKernelType( // choose cudnn kernel if the runtime supported. auto input_data_type = op_ptr->IndicateVarDataType(ctx, "X"); - if (ctx.Input("X")->dims().size() > 5 || + if (ctx.Input("X")->dims().size() > 5 || !ReduceOpHasOptimizedOneDNNKernel(ctx)) { op_ptr->SetDnnFallback(true); } @@ -141,7 +141,7 @@ phi::KernelKey GetReduceGradExpectedKernelType( (out_dtype >= 0) ? static_cast(out_dtype) : op_ptr->IndicateVarDataType(ctx, framework::GradVarName("Out")); - if (ctx.Input("X")->dims().size() > 5) { + if (ctx.Input("X")->dims().size() > 5) { op_ptr->SetDnnFallback(true); } @@ -152,8 +152,7 @@ phi::KernelKey GetReduceOpUseInputPlaceExpectedKernelType( const framework::ExecutionContext& ctx, const framework::OperatorWithKernel* op_ptr) { phi::KernelKey kt = op_ptr->OperatorWithKernel::GetExpectedKernelType(ctx); - kt.set_backend( - phi::TransToPhiBackend(ctx.Input("X")->place())); + kt.set_backend(phi::TransToPhiBackend(ctx.Input("X")->place())); return kt; } @@ -210,10 +209,10 @@ phi::KernelKey GetSgdExpectedKernelType( const auto* grad_var = ctx.InputVar("Grad"); // supported cases - bool dense_param_sparse_grad = param_var->IsType() && - grad_var->IsType(); - bool dense_param_and_grad = param_var->IsType() && - grad_var->IsType(); + bool dense_param_sparse_grad = + param_var->IsType() && grad_var->IsType(); + bool dense_param_and_grad = + param_var->IsType() && grad_var->IsType(); if (!(dense_param_sparse_grad || dense_param_and_grad)) { op_ptr->SetDnnFallback(true); } @@ -284,7 +283,7 @@ phi::KernelKey GetStridedSliceExpectedKernelType( ctx.GetPlace()); } // NOTE: cuda pinned tensor need to copy its data to target place - auto in_tensor = ctx.Input("Input"); + auto in_tensor = ctx.Input("Input"); if (in_tensor->place().GetType() == phi::AllocationType::GPUPINNED) { return phi::KernelKey(framework::TransToProtoVarType(in_tensor->dtype()), ctx.GetPlace()); @@ -326,7 +325,7 @@ phi::KernelKey GetPad3dExpectedKernelType( // only constant mode and non-blocked layouts are supported for oneDNN if (op_ptr->CanONEDNNBeUsed(ctx, input_data_type) && ctx.Attr("mode") == "constant" && - ctx.Input("X")->mem_desc().get_inner_nblks() == 0) { + ctx.Input("X")->mem_desc().get_inner_nblks() == 0) { return phi::KernelKey(phi::Backend::ONEDNN, phi::DataLayout::ONEDNN, phi::TransToPhiDataType(input_data_type)); @@ -375,14 +374,13 @@ phi::KernelKey GetInstanceNormExpectedKernelType( PADDLE_ENFORCE_EQ( in_param_type, framework::TransToProtoVarType( - ctx.Input("Scale")->dtype()), + ctx.Input("Scale")->dtype()), common::errors::InvalidArgument("Scale input should be of float type")); } if (ctx.HasInput("Bias")) { PADDLE_ENFORCE_EQ( in_param_type, - framework::TransToProtoVarType( - ctx.Input("Bias")->dtype()), + framework::TransToProtoVarType(ctx.Input("Bias")->dtype()), common::errors::InvalidArgument("Bias input should be of float type")); } @@ -397,7 +395,7 @@ phi::KernelKey GetLayerNormExpectedKernelType( // NOTE(jiahongyu): Below codes originally enclosed by PADDLE_WITH_DNNL int begin_norm_axis = ctx.Attr("begin_norm_axis"); - if (begin_norm_axis != ctx.Input("X")->dims().size() - 1) { + if (begin_norm_axis != ctx.Input("X")->dims().size() - 1) { op_ptr->SetDnnFallback(true); } // NOTE(jiahongyu): Above codes originally enclosed by PADDLE_WITH_DNNL @@ -416,7 +414,7 @@ phi::KernelKey GetConvExpectedKernelType( input_data_type != framework::proto::VarType::UINT8 && input_data_type != framework::proto::VarType::BF16) { auto filter_data_type = framework::TransToProtoVarType( - ctx.Input("Filter")->dtype()); + ctx.Input("Filter")->dtype()); PADDLE_ENFORCE_EQ( input_data_type, filter_data_type, diff --git a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 index 3bf084807aefae..367cfec3c73401 100644 --- a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 +++ b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 @@ -352,7 +352,7 @@ phi::KernelKey GetExpectedKernelType( kt = OperatorWithKernel::GetExpectedKernelType(ctx); {% endif %} kt.set_backend( - phi::TransToPhiBackend(ctx.Input("{{kernel["backend"]["candidates"][0]}}")->place())); + phi::TransToPhiBackend(ctx.Input("{{kernel["backend"]["candidates"][0]}}")->place())); {% endif %} {% if "force_backend" in op["kernel"] and op["kernel"]["force_backend"] == "force_cpu" %} {% if kernel["backend"] is none and kernel["data_type"] is none %} {# only force_cpu#} diff --git a/paddle/fluid/operators/generator/type_mapping.py b/paddle/fluid/operators/generator/type_mapping.py index a259540f902eba..0b3c65544b5ac6 100644 --- a/paddle/fluid/operators/generator/type_mapping.py +++ b/paddle/fluid/operators/generator/type_mapping.py @@ -113,7 +113,7 @@ dense_optional_input_types_map = { 'Tensor': 'paddle::optional', - 'Tensor[]': 'paddle::optional&>', + 'Tensor[]': 'paddle::optional&>', } dense_output_types_map = { diff --git a/paddle/fluid/operators/get_tensor_from_selected_rows_op.cc b/paddle/fluid/operators/get_tensor_from_selected_rows_op.cc index 4e7a5f5c9ed8eb..ec742be8018254 100644 --- a/paddle/fluid/operators/get_tensor_from_selected_rows_op.cc +++ b/paddle/fluid/operators/get_tensor_from_selected_rows_op.cc @@ -59,7 +59,7 @@ class GetTensorFromSelectedRowsKernel { public: void operator()(const framework::ExecutionContext &ctx) const { auto *x = ctx.Input("X"); - auto *out = ctx.Output("Out"); + auto *out = ctx.Output("Out"); out->Resize(x->value().dims()); out->mutable_data(ctx.GetPlace(), x->value().type()); diff --git a/paddle/fluid/operators/increment_op.cc b/paddle/fluid/operators/increment_op.cc index 5fbde4f449bc47..9394b5f16cff1e 100644 --- a/paddle/fluid/operators/increment_op.cc +++ b/paddle/fluid/operators/increment_op.cc @@ -44,7 +44,7 @@ class IncrementOp : public framework::OperatorWithKernel { phi::KernelKey kt = OperatorWithKernel::GetExpectedKernelType(ctx); // IncrementOp kernel's device type is decided by input tensor place kt.set_backend( - phi::TransToPhiBackend(ctx.Input("X")->place())); + phi::TransToPhiBackend(ctx.Input("X")->place())); return kt; } }; diff --git a/paddle/fluid/operators/ipu/ipu_runtime_op.cc b/paddle/fluid/operators/ipu/ipu_runtime_op.cc index 8776442a6b09e7..656d5ca04b890d 100644 --- a/paddle/fluid/operators/ipu/ipu_runtime_op.cc +++ b/paddle/fluid/operators/ipu/ipu_runtime_op.cc @@ -34,8 +34,8 @@ class IpuRuntimeOp : public framework::OperatorBase { auto* dev_ctx = phi::DeviceContextPool::Instance().Get(place); framework::RuntimeContext runtime_ctx(inputs_, outputs_, scope); framework::ExecutionContext ctx(*this, scope, *dev_ctx, runtime_ctx); - auto inputs = ctx.MultiInput("FeedList"); - auto outputs = ctx.MultiOutput("FetchList"); + auto inputs = ctx.MultiInput("FeedList"); + auto outputs = ctx.MultiOutput("FetchList"); auto output_names = ctx.OutputNames("FetchList"); VLOG(4) << "IpuRuntime Kernel, begin to run graph"; ipu_backend->Run(inputs, outputs, ctx); diff --git a/paddle/fluid/operators/isfinite_op.h b/paddle/fluid/operators/isfinite_op.h index d0d94f1a3d0595..f932651bcebdca 100644 --- a/paddle/fluid/operators/isfinite_op.h +++ b/paddle/fluid/operators/isfinite_op.h @@ -51,7 +51,7 @@ bool TensorIsfinite(const phi::DenseTensor& tensor); auto place = in_.place(); \ auto* ctx = static_cast( \ phi::DeviceContextPool::Instance().Get(place)); \ - phi::DenseTensor tmp; \ + DenseTensor tmp; \ tmp.Resize(in_.dims()); \ out_->Resize({1}); \ std::vector dims(tmp.dims().size()); \ @@ -128,17 +128,17 @@ inline void TensorIsfinite(const phi::DenseTensor& tensor, // copy the result bool to cpu inline bool TensorContainsNAN(const phi::DenseTensor& tensor) { - phi::DenseTensor out; + DenseTensor out; TensorContainsNAN(tensor, &out); return paddle::framework::GetValue(&out); } inline bool TensorContainsInf(const phi::DenseTensor& tensor) { - phi::DenseTensor out; + DenseTensor out; TensorContainsInf(tensor, &out); return paddle::framework::GetValue(&out); } inline bool TensorIsfinite(const phi::DenseTensor& tensor) { - phi::DenseTensor out; + DenseTensor out; TensorIsfinite(tensor, &out); return paddle::framework::GetValue(&out); } @@ -161,11 +161,11 @@ class OverflowKernel : public framework::OpKernel { public: virtual void Compute(const framework::ExecutionContext& ctx) const { auto* x = ctx.InputVar("X"); - auto* out = ctx.Output("Out"); + auto* out = ctx.Output("Out"); out->template mutable_data(ctx.GetPlace()); Functor functor; - if (x->IsType()) { - auto* in = ctx.Input("X"); + if (x->IsType()) { + auto* in = ctx.Input("X"); functor(*in, out); } else if (x->IsType()) { auto& in = ctx.Input("X")->value(); @@ -175,7 +175,7 @@ class OverflowKernel : public framework::OpKernel { false, common::errors::InvalidArgument( "The input type mismatch, the type of Input(X) " - "must be phi::DenseTensor or " + "must be DenseTensor or " "SelectedRows, please check your input.")); } } diff --git a/paddle/fluid/operators/load_combine_op.cc b/paddle/fluid/operators/load_combine_op.cc index 8900ab47fc2585..74059616a2b9fc 100644 --- a/paddle/fluid/operators/load_combine_op.cc +++ b/paddle/fluid/operators/load_combine_op.cc @@ -59,7 +59,7 @@ class LoadCombineOpProtoMaker : public framework::OpProtoAndCheckerMaker { AddComment(R"DOC( LoadCombine Operator. -LoadCombine operator loads phi::DenseTensor variables from a file, which could be +LoadCombine operator loads DenseTensor variables from a file, which could be loaded in memory already. The file should contain one or more DenseTensors serialized using the SaveCombine operator. The LoadCombine operator applies a deserialization strategy to appropriately load diff --git a/paddle/fluid/operators/load_combine_op.h b/paddle/fluid/operators/load_combine_op.h index 28fd2db174e445..276eb64acb35a7 100644 --- a/paddle/fluid/operators/load_combine_op.h +++ b/paddle/fluid/operators/load_combine_op.h @@ -111,7 +111,7 @@ class LoadCombineOpKernel : public framework::OpKernel { tensor->emplace(token, it->second); } } else { - auto *tensor = out_vars[i]->GetMutable(); + auto *tensor = out_vars[i]->GetMutable(); // Get data from fin to tensor phi::DeserializeFromStream(*buffer, tensor, dev_ctx); @@ -125,7 +125,7 @@ class LoadCombineOpKernel : public framework::OpKernel { phi::KernelKey(place, phi::DataLayout::ALL_LAYOUT, in_dtype); auto out_kernel_type = phi::KernelKey(place, phi::DataLayout::ALL_LAYOUT, out_dtype); - phi::DenseTensor fp16_tensor; + DenseTensor fp16_tensor; // copy LoD info to the new tensor fp16_tensor.set_lod(tensor->lod()); framework::TransDataType( @@ -133,7 +133,7 @@ class LoadCombineOpKernel : public framework::OpKernel { // reset output tensor out_vars[i]->Clear(); - tensor = out_vars[i]->GetMutable(); + tensor = out_vars[i]->GetMutable(); tensor->set_lod(fp16_tensor.lod()); tensor->ShareDataWith(fp16_tensor); } diff --git a/paddle/fluid/operators/load_op.cc b/paddle/fluid/operators/load_op.cc index ffafbd8316a4f4..cdf0204409041f 100644 --- a/paddle/fluid/operators/load_op.cc +++ b/paddle/fluid/operators/load_op.cc @@ -37,7 +37,7 @@ class LoadOp : public framework::OperatorWithKernel { class LoadOpProtoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { - AddOutput("Out", "The phi::DenseTensor / SelectedRows need to be loaded"); + AddOutput("Out", "The DenseTensor / SelectedRows need to be loaded"); AddAttr( "load_as_fp16", "If true, the tensor will be first loaded and then " @@ -54,7 +54,7 @@ class LoadOpProtoMaker : public framework::OpProtoAndCheckerMaker { "(vector) The shape of the output") .SetDefault({}); AddComment( - "Load operator will load a phi::DenseTensor / SelectedRows variable " + "Load operator will load a DenseTensor / SelectedRows variable " "from " "disk " "file."); diff --git a/paddle/fluid/operators/lod_array_length_op.cc b/paddle/fluid/operators/lod_array_length_op.cc index 402cf26a66ef7d..ef8afee74b2e1d 100644 --- a/paddle/fluid/operators/lod_array_length_op.cc +++ b/paddle/fluid/operators/lod_array_length_op.cc @@ -42,7 +42,7 @@ class LoDArrayLengthOp : public framework::OperatorBase { void RunImpl(const framework::Scope &scope, const phi::Place &place) const override { auto &x = scope.FindVar(Input("X"))->Get(); - auto &out = *scope.FindVar(Output("Out"))->GetMutable(); + auto &out = *scope.FindVar(Output("Out"))->GetMutable(); out.Resize({1}); auto cpu = phi::CPUPlace(); *out.mutable_data(cpu) = static_cast(x.size()); diff --git a/paddle/fluid/operators/lod_reset_op.cc b/paddle/fluid/operators/lod_reset_op.cc index bc7f9e8947ed58..1ccd326d518534 100644 --- a/paddle/fluid/operators/lod_reset_op.cc +++ b/paddle/fluid/operators/lod_reset_op.cc @@ -70,7 +70,7 @@ class LoDResetOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { return phi::KernelKey(phi::Backend::ALL_BACKEND, tensor.layout(), @@ -133,7 +133,7 @@ is supported. Example 1: -Given a 1-level phi::DenseTensor input(X): +Given a 1-level DenseTensor input(X): X.lod = [[ 0, 2, 5 6 ]] X.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]] X.dims = [6, 1] @@ -147,7 +147,7 @@ then we get a 1-level DenseTensor: Example 2: -Given a 1-level phi::DenseTensor input(X): +Given a 1-level DenseTensor input(X): X.lod = [[ 0, 2, 5 6 ]] X.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]] X.dims = [6, 1] @@ -163,7 +163,7 @@ then we get a 1-level DenseTensor: Example 3: -Given a 1-level phi::DenseTensor input(X): +Given a 1-level DenseTensor input(X): X.lod = [[ 0, 2, 5 6 ]] X.data = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]] X.dims = [6, 1] diff --git a/paddle/fluid/operators/lod_reset_op.h b/paddle/fluid/operators/lod_reset_op.h index 6b6d73520d1578..23160b3180fabe 100644 --- a/paddle/fluid/operators/lod_reset_op.h +++ b/paddle/fluid/operators/lod_reset_op.h @@ -39,9 +39,9 @@ template class LoDResetKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const { - auto* out = ctx.Output("Out"); - auto* in = ctx.Input("X"); - auto* lod_t = ctx.Input("Y"); + auto* out = ctx.Output("Out"); + auto* in = ctx.Input("X"); + auto* lod_t = ctx.Input("Y"); bool append = ctx.Attr("append"); framework::TensorCopy(*in, in->place(), out); @@ -65,7 +65,7 @@ class LoDResetKernel : public framework::OpKernel { return; // early return, since lod already set } else { auto* lod = lod_t->data(); - phi::DenseTensor lod_cpu; + DenseTensor lod_cpu; if (lod_t->place().GetType() == phi::AllocationType::GPU) { framework::TensorCopySync(*lod_t, phi::CPUPlace(), &lod_cpu); lod = lod_cpu.data(); @@ -127,8 +127,8 @@ template class LoDResetGradKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const { - auto* d_out = ctx.Input(framework::GradVarName("Out")); - auto* d_x = ctx.Output(framework::GradVarName("X")); + auto* d_out = ctx.Input(framework::GradVarName("Out")); + auto* d_x = ctx.Output(framework::GradVarName("X")); framework::TensorCopy(*d_out, d_out->place(), d_x); } diff --git a/paddle/fluid/operators/matmul_op.cc b/paddle/fluid/operators/matmul_op.cc index 987589a0364674..a684cdb372edd6 100644 --- a/paddle/fluid/operators/matmul_op.cc +++ b/paddle/fluid/operators/matmul_op.cc @@ -186,7 +186,7 @@ class MatMulOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (framework::IsComplexType(expected_kernel_type.dtype())) { // only promote inputs's types when contains complex input diff --git a/paddle/fluid/operators/memcpy_d2h_op.cc b/paddle/fluid/operators/memcpy_d2h_op.cc index 771c0ff19ce2c8..efede5210e306f 100644 --- a/paddle/fluid/operators/memcpy_d2h_op.cc +++ b/paddle/fluid/operators/memcpy_d2h_op.cc @@ -34,7 +34,7 @@ class MemcpyD2HOp : public framework::OperatorWithKernel { protected: phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { return phi::KernelKey(phi::Backend::ALL_BACKEND, tensor.layout(), diff --git a/paddle/fluid/operators/memcpy_h2d_op.cc b/paddle/fluid/operators/memcpy_h2d_op.cc index 5a01de461429a2..3a361847946497 100644 --- a/paddle/fluid/operators/memcpy_h2d_op.cc +++ b/paddle/fluid/operators/memcpy_h2d_op.cc @@ -34,7 +34,7 @@ class MemcpyH2DOp : public framework::OperatorWithKernel { protected: phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { return phi::KernelKey(phi::Backend::ALL_BACKEND, tensor.layout(), diff --git a/paddle/fluid/operators/memcpy_op.cc b/paddle/fluid/operators/memcpy_op.cc index 351dbd09c2a906..623e609aa7bf54 100644 --- a/paddle/fluid/operators/memcpy_op.cc +++ b/paddle/fluid/operators/memcpy_op.cc @@ -56,7 +56,7 @@ class MemcpyOp : public framework::OperatorWithKernel { protected: phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { return phi::KernelKey(phi::Backend::ALL_BACKEND, tensor.layout(), diff --git a/paddle/fluid/operators/openvino/openvino_engine_op.h b/paddle/fluid/operators/openvino/openvino_engine_op.h index c83fcab913c418..cde5c91efc7849 100644 --- a/paddle/fluid/operators/openvino/openvino_engine_op.h +++ b/paddle/fluid/operators/openvino/openvino_engine_op.h @@ -112,7 +112,7 @@ class OpenVINOEngineOp : public framework::OperatorBase { OpenVINOEngine *engine) const { for (size_t i = 0; i < runtime_input_names_.size(); ++i) { auto x = runtime_input_names_[i]; - auto &t = inference::analysis::GetFromScope(scope, x); + auto &t = inference::analysis::GetFromScope(scope, x); auto t_shape = common::vectorize(t.dims()); if (t_shape.empty()) { PADDLE_ENFORCE_EQ( @@ -213,7 +213,7 @@ class OpenVINOEngineOp : public framework::OperatorBase { fluid_v, common::errors::NotFound( "Output variable %s is not found in Openvino subgraph.", y)); - auto *fluid_t = fluid_v->GetMutable(); + auto *fluid_t = fluid_v->GetMutable(); auto ov_output_shape = engine->GetOutputShape(output_names_[i], i); auto phi_type = engine->GetOutputType( output_names_[i], diff --git a/paddle/fluid/operators/print_op.cc b/paddle/fluid/operators/print_op.cc index a6ca37714ec868..67c31ae7f73af7 100644 --- a/paddle/fluid/operators/print_op.cc +++ b/paddle/fluid/operators/print_op.cc @@ -65,8 +65,8 @@ class PrintOp : public framework::OperatorBase { common::errors::NotFound("The output:%s not found in scope", Output("Out"))); - auto &in_tensor = in_var->Get(); - phi::DenseTensor *out_tensor = out_var->GetMutable(); + auto &in_tensor = in_var->Get(); + DenseTensor *out_tensor = out_var->GetMutable(); PrintValue(place, Inputs("In").front(), in_tensor); framework::TensorCopy(in_tensor, place, out_tensor); @@ -75,7 +75,7 @@ class PrintOp : public framework::OperatorBase { void PrintValue(const phi::Place &place, const std::string &printed_var_name, - const phi::DenseTensor &in_tensor) const { + const DenseTensor &in_tensor) const { std::string print_phase = Attr("print_phase"); bool is_forward = Attr("is_forward"); diff --git a/paddle/fluid/operators/py_func_op.cc b/paddle/fluid/operators/py_func_op.cc index 7ab97c59bdfe2e..8b9b570613524f 100644 --- a/paddle/fluid/operators/py_func_op.cc +++ b/paddle/fluid/operators/py_func_op.cc @@ -63,8 +63,8 @@ static std::string PythonFuncDebugString(const py::object &py_callable) { } static void CallPythonFunc(py::object *callable, - const std::vector &ins, - std::vector *outs) { + const std::vector &ins, + std::vector *outs) { py::gil_scoped_acquire guard; py::tuple in_args(ins.size()); for (size_t i = 0; i < ins.size(); ++i) { @@ -97,7 +97,7 @@ static void CallPythonFunc(py::object *callable, out_num)); PADDLE_ENFORCE_EQ( - py::cast(ret_tuple[0]) == nullptr, + py::cast(ret_tuple[0]) == nullptr, true, common::errors::InvalidArgument( "Python function has no return values or returns None. In " @@ -111,7 +111,7 @@ static void CallPythonFunc(py::object *callable, continue; } try { - auto *py_out_tensor = py::cast(ret_tuple[i]); + auto *py_out_tensor = py::cast(ret_tuple[i]); PADDLE_ENFORCE_NOT_NULL(py_out_tensor, common::errors::InvalidArgument( "Output tensor %d should not be nullptr", i)); @@ -119,7 +119,7 @@ static void CallPythonFunc(py::object *callable, out->ShareDataWith(*py_out_tensor); } catch (py::cast_error &) { PADDLE_THROW(common::errors::InvalidArgument( - "py::cast to phi::DenseTensor error. The %d-th output exception is " + "py::cast to DenseTensor error. The %d-th output exception is " "phi::DenseTensor", i)); } @@ -314,14 +314,14 @@ class PyFuncOp : public framework::OperatorBase { auto &in_arg_names = Inputs("X"); auto &out_arg_names = Outputs("Out"); - std::vector inputs(in_arg_names.size()); + std::vector inputs(in_arg_names.size()); for (size_t i = 0; i < in_arg_names.size(); ++i) { auto in_var = scope.FindVar(in_arg_names[i]); // When py_func op is called in backward, in_var may be null if (in_var == nullptr) { continue; } - auto &in_tensor = in_var->Get(); + auto &in_tensor = in_var->Get(); if (!in_tensor.IsInitialized()) { continue; } @@ -333,10 +333,10 @@ class PyFuncOp : public framework::OperatorBase { inputs[i].set_lod(in_tensor.lod()); } - std::vector outputs(out_arg_names.size()); + std::vector outputs(out_arg_names.size()); for (size_t i = 0; i < out_arg_names.size(); ++i) { auto *out_var = scope.FindVar(out_arg_names[i]); - outputs[i] = out_var ? out_var->GetMutable() : nullptr; + outputs[i] = out_var ? out_var->GetMutable() : nullptr; } auto callable_id = diff --git a/paddle/fluid/operators/reader/create_py_reader_op.cc b/paddle/fluid/operators/reader/create_py_reader_op.cc index 7d52ea56d7889e..4db093fb6171b4 100644 --- a/paddle/fluid/operators/reader/create_py_reader_op.cc +++ b/paddle/fluid/operators/reader/create_py_reader_op.cc @@ -109,7 +109,7 @@ class CreatePyReaderOpMaker : public FileReaderMakerBase { .SetDefault(1); AddComment(R"DOC( - Create PyReader to support phi::DenseTensor data feeding in Python side. + Create PyReader to support DenseTensor data feeding in Python side. )DOC"); } }; diff --git a/paddle/fluid/operators/reader/read_op.cc b/paddle/fluid/operators/reader/read_op.cc index 4f9c3bbd336ae5..215db3d97915a7 100644 --- a/paddle/fluid/operators/reader/read_op.cc +++ b/paddle/fluid/operators/reader/read_op.cc @@ -137,8 +137,7 @@ class ReadOp : public framework::OperatorBase { need_check_feed.size())); for (size_t i = 0; i < out_arg_names.size(); ++i) { - auto* out = - scope.FindVar(out_arg_names[i])->GetMutable(); + auto* out = scope.FindVar(out_arg_names[i])->GetMutable(); if (need_check_feed[i]) { auto in_dims = ins[i].dims(); PADDLE_ENFORCE_EQ( diff --git a/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc b/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc index 05d7904ee4019e..ae94005afeaf19 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc @@ -107,7 +107,7 @@ class ReduceBaseOp : public framework::OperatorWithKernel { static bool HasOptimizedOneDNNKernel(const framework::ExecutionContext& ctx) { // native reduce kernels don't support bf16 // so oneDNN kernel is enforced in that case - if (ctx.Input("X")->dtype() == phi::DataType::BFLOAT16) + if (ctx.Input("X")->dtype() == phi::DataType::BFLOAT16) return true; if (!ctx.HasAttr("dim") || !ctx.HasAttr("reduce_all")) { @@ -116,7 +116,7 @@ class ReduceBaseOp : public framework::OperatorWithKernel { auto reduce_dims = ctx.Attr>("dim"); const bool reduce_all = ctx.Attr("reduce_all"); - int ndims = ctx.Input("X")->dims().size(); + int ndims = ctx.Input("X")->dims().size(); if (reduce_all) { return true; @@ -142,7 +142,7 @@ class ReduceBaseOp : public framework::OperatorWithKernel { auto input_data_type = OperatorWithKernel::IndicateVarDataType(ctx, "X"); // NOTE(jiahongyu): Below codes originally enclosed by PADDLE_WITH_DNNL - if (ctx.Input("X")->dims().size() > 5 || + if (ctx.Input("X")->dims().size() > 5 || !HasOptimizedOneDNNKernel(ctx)) { this->SetDnnFallback(true); } @@ -212,7 +212,7 @@ class ReduceGradOp : public framework::OperatorWithKernel { // NOTE(jiahongyu): Below codes originally enclosed by PADDLE_WITH_DNNL // max 5D tensor is supported - if (ctx.Input("X")->dims().size() > 5) { + if (ctx.Input("X")->dims().size() > 5) { dnn_fallback_ = true; } // NOTE(jiahongyu): Above codes originally enclosed by PADDLE_WITH_DNNL diff --git a/paddle/fluid/operators/reshape_op.cc b/paddle/fluid/operators/reshape_op.cc index 200d2da35d098b..c619bf2d3aaed4 100644 --- a/paddle/fluid/operators/reshape_op.cc +++ b/paddle/fluid/operators/reshape_op.cc @@ -266,7 +266,7 @@ class ReshapeOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "ShapeTensor") { return phi::KernelKey(phi::Backend::ALL_BACKEND, @@ -512,7 +512,7 @@ class Reshape2GradOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "ShapeTensor") { return phi::KernelKey(phi::Backend::ALL_BACKEND, @@ -541,7 +541,7 @@ class Reshape2DoubleGradOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "ShapeTensor") { return phi::KernelKey(phi::Backend::ALL_BACKEND, diff --git a/paddle/fluid/operators/run_program_op.cc b/paddle/fluid/operators/run_program_op.cc index 526a1ced5a502b..348562245c33c2 100644 --- a/paddle/fluid/operators/run_program_op.cc +++ b/paddle/fluid/operators/run_program_op.cc @@ -67,18 +67,18 @@ class RunProgramOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(vector)" + "(vector)" "The input tensors of RunProgram operator, also the feed targets " "of loaded program.") .AsDuplicable(); AddInput("Params", - "(vector)" + "(vector)" "The input parameter of RunProgram operator, also the parameters " "of the loaded program.") .AsDuplicable() .AsDispensable(); AddOutput("Out", - "(vector)" + "(vector)" "The output tensors of RunProgram operator, also the fetch " "targets of the loaded program.") .AsDuplicable(); @@ -89,7 +89,7 @@ class RunProgramOpMaker : public framework::OpProtoAndCheckerMaker { "NOTE: Do not use Scope directly because Scope output is not " "currently supported."); AddOutput("DOut", - "(vector)" + "(vector)" "The output tensors for GRAD Tensors in RunProgram forward " "operator, the forward operator contains GRAD Tensors when it " "computes double grad.") diff --git a/paddle/fluid/operators/save_combine_op.cc b/paddle/fluid/operators/save_combine_op.cc index ebcfa0026b3d10..960ac0b9e265e6 100644 --- a/paddle/fluid/operators/save_combine_op.cc +++ b/paddle/fluid/operators/save_combine_op.cc @@ -55,7 +55,7 @@ class SaveCombineOpProtoMaker : public framework::OpProtoAndCheckerMaker { AddComment(R"DOC( SaveCombine operator -This operator will serialize and write a list of input phi::DenseTensor variables +This operator will serialize and write a list of input DenseTensor variables to a file on disk. )DOC"); AddAttr("overwrite", @@ -71,7 +71,7 @@ to a file on disk. AddAttr( "file_path", "(string)" - "The \"file_path\" where the phi::DenseTensor variables will be saved.") + "The \"file_path\" where the DenseTensor variables will be saved.") .AddCustomChecker( [](const std::string& path) { return !path.empty(); }); AddAttr("save_to_memory", diff --git a/paddle/fluid/operators/save_combine_op.h b/paddle/fluid/operators/save_combine_op.h index 48d0589ab77612..621fb35fa504ff 100644 --- a/paddle/fluid/operators/save_combine_op.h +++ b/paddle/fluid/operators/save_combine_op.h @@ -106,7 +106,7 @@ void SaveCombineTensorKernel(const Context& dev_ctx, phi::KernelKey(place, phi::DataLayout::ALL_LAYOUT, in_dtype); auto out_kernel_type = phi::KernelKey(place, phi::DataLayout::ALL_LAYOUT, out_dtype); - phi::DenseTensor out; + DenseTensor out; framework::TransDataType(in_kernel_type, out_kernel_type, tensor, &out); // copy LoD info to the new tensor out.set_lod(tensor.lod()); @@ -194,7 +194,7 @@ class SaveCombineOpKernel : public framework::OpKernel { phi::DeviceContextPool& pool = phi::DeviceContextPool::Instance(); auto& dev_ctx = *pool.Get(place); - if (inp_vars.size() > 0 && inp_vars[0]->IsType()) { + if (inp_vars.size() > 0 && inp_vars[0]->IsType()) { std::vector x(inp_vars.size()); for (size_t i = 0; i < inp_vars.size(); i++) { PADDLE_ENFORCE_NOT_NULL( @@ -202,13 +202,13 @@ class SaveCombineOpKernel : public framework::OpKernel { common::errors::InvalidArgument("Cannot find variable %s to save.", inp_var_names[i])); PADDLE_ENFORCE_EQ( - inp_vars[i]->IsType(), + inp_vars[i]->IsType(), true, common::errors::InvalidArgument( "SaveCombine operator only supports saving " - "phi::DenseTensor or Vocab variable, %s has wrong type.", + "DenseTensor or Vocab variable, %s has wrong type.", inp_var_names[i])); - x[i] = (&(inp_vars[i]->Get())); + x[i] = (&(inp_vars[i]->Get())); } SaveCombineTensorKernel(dev_ctx, x, @@ -229,7 +229,7 @@ class SaveCombineOpKernel : public framework::OpKernel { true, common::errors::InvalidArgument( "SaveCombine operator only supports saving " - "phi::DenseTensor or Vocab variable, %s has wrong type.", + "DenseTensor or Vocab variable, %s has wrong type.", inp_var_names[i])); x[i] = (&(inp_vars[i]->Get())); } diff --git a/paddle/fluid/operators/save_op.cc b/paddle/fluid/operators/save_op.cc index b2931fead7c612..b9e9fb8bf64429 100644 --- a/paddle/fluid/operators/save_op.cc +++ b/paddle/fluid/operators/save_op.cc @@ -45,12 +45,11 @@ class SaveOp : public framework::OperatorWithKernel { class SaveOpProtoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { - AddInput("X", - "(Tensor ) Input phi::DenseTensor and SelectedRows to be saved"); + AddInput("X", "(Tensor ) Input DenseTensor and SelectedRows to be saved"); AddComment(R"DOC( Save operator -This operator will serialize and write phi::DenseTensor / SelectedRows variable to file on disk. +This operator will serialize and write DenseTensor / SelectedRows variable to file on disk. )DOC"); AddAttr("overwrite", "(boolean, default true)" diff --git a/paddle/fluid/operators/select_input_op.cc b/paddle/fluid/operators/select_input_op.cc index 5d8ed7b65eb2c6..24f56ab02fbcab 100644 --- a/paddle/fluid/operators/select_input_op.cc +++ b/paddle/fluid/operators/select_input_op.cc @@ -36,7 +36,7 @@ class SelectInputOp : public framework::OperatorBase { phi::DeviceContextPool &pool = phi::DeviceContextPool::Instance(); auto &dev_ctx = *pool.Get(dev_place); - auto &mask = scope.FindVar(Input("Mask"))->Get(); + auto &mask = scope.FindVar(Input("Mask"))->Get(); size_t output_branch = static_cast(GetBranchNumber(mask)); const std::vector &x_names = Inputs("X"); @@ -73,7 +73,7 @@ class SelectInputOpProtoMaker : public framework::OpProtoAndCheckerMaker { // Because this op is blocking whole control flow. I am implementing MVP // (minimal viable product) here. AddComment(R"DOC( -Merge branches of phi::DenseTensor into a single Output with a mask integer +Merge branches of DenseTensor into a single Output with a mask integer specifying the output branchi. )DOC"); } diff --git a/paddle/fluid/operators/select_op_helper.h b/paddle/fluid/operators/select_op_helper.h index edfd8338d1b93d..540c5df4a2623d 100644 --- a/paddle/fluid/operators/select_op_helper.h +++ b/paddle/fluid/operators/select_op_helper.h @@ -25,7 +25,7 @@ namespace operators { // Returns the integer in mask whose numel must be 1. The integer means the // selected branch number. -inline int GetBranchNumber(const phi::DenseTensor &mask) { +inline int GetBranchNumber(const DenseTensor &mask) { PADDLE_ENFORCE_EQ(mask.numel(), 1, common::errors::InvalidArgument( @@ -38,7 +38,7 @@ inline int GetBranchNumber(const phi::DenseTensor &mask) { return mask.data()[0]; } // when mask.place().GetType() == phi::AllocationType::GPU is true - std::unique_ptr cpu_mask{new phi::DenseTensor()}; + std::unique_ptr cpu_mask{new phi::DenseTensor()}; #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) || \ defined(PADDLE_WITH_CUSTOM_DEVICE) || defined(PADDLE_WITH_XPU) framework::TensorCopySync(mask, phi::CPUPlace(), cpu_mask.get()); diff --git a/paddle/fluid/operators/select_output_op.cc b/paddle/fluid/operators/select_output_op.cc index 77d94bc6af419f..4f46448ca8fe3e 100644 --- a/paddle/fluid/operators/select_output_op.cc +++ b/paddle/fluid/operators/select_output_op.cc @@ -48,7 +48,7 @@ class SelectOutputOp : public framework::OperatorBase { phi::DeviceContextPool &pool = phi::DeviceContextPool::Instance(); auto &dev_ctx = *pool.Get(dev_place); - auto &mask = scope.FindVar(Input("Mask"))->Get(); + auto &mask = scope.FindVar(Input("Mask"))->Get(); size_t output_branch = static_cast(GetBranchNumber(mask)); const std::vector &out_names = Outputs("Out"); @@ -73,9 +73,8 @@ class SelectOutputOp : public framework::OperatorBase { class SelectOutputOpProtoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { - AddInput( - "X", - "The input phi::DenseTensor or phi::DenseTensorArray or SelectedRows."); + AddInput("X", + "The input DenseTensor or phi::DenseTensorArray or SelectedRows."); AddInput("Mask", "Tensor with numel 1 specifying which branch to output"); AddOutput("Out", "The output can contains multiple variables. The output of " diff --git a/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc b/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc index cef735b1fdac82..301d1da01fb979 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc @@ -69,7 +69,7 @@ class SequenceMaskOpMaker : public framework::OpProtoAndCheckerMaker { SequenceMask Operator This operator outputs a Mask according to Input(X) and Attr(maxlen). -Supposing Input(X) is a phi::DenseTensor with shape [d_1, d_2, ..., d_n], the +Supposing Input(X) is a DenseTensor with shape [d_1, d_2, ..., d_n], the Output(Y) is a mask with shape [d_1, d_2, ..., d_n, maxlen], where: Y(i_1, i_2, ..., i_n, j) = (j < X(i_1, i_2, ..., i_n)) diff --git a/paddle/fluid/operators/set_value_op.cc b/paddle/fluid/operators/set_value_op.cc index f20f5bb50e4905..5b6d34f1ba2df4 100644 --- a/paddle/fluid/operators/set_value_op.cc +++ b/paddle/fluid/operators/set_value_op.cc @@ -51,7 +51,7 @@ class SetValue : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "StartsTensorList" || var_name == "EndsTensorList" || var_name == "StepsTensorList") { @@ -99,7 +99,7 @@ class SetValueMaker : public framework::OpProtoAndCheckerMaker { AddOutput("Out", "(phi::DenseTensor) Output tensor of set_value operator. The " "output is the " - "same phi::DenseTensor as input"); + "same DenseTensor as input"); // Attr AddAttr("dtype", "data type of input.") @@ -138,7 +138,7 @@ class SetValueMaker : public framework::OpProtoAndCheckerMaker { AddAttr>("shape", "(vector) Shape of values.") .SetDefault({}); AddComment(R"DOC(SetValue operator. -Assignment to a phi::DenseTensor in static graph mode. +Assignment to a DenseTensor in static graph mode. )DOC"); } }; @@ -203,14 +203,14 @@ class SetValueGrad : public framework::OperatorWithKernel { protected: phi::KernelKey GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { - auto in_tensor = ctx.Input(framework::GradVarName("Out")); + auto in_tensor = ctx.Input(framework::GradVarName("Out")); return phi::KernelKey(OperatorWithKernel::IndicateVarDataType( ctx, framework::GradVarName("Out")), in_tensor->place()); } phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "StartsTensorList" || var_name == "EndsTensorList" || var_name == "StepsTensorList") { diff --git a/paddle/fluid/operators/slice_op.cc b/paddle/fluid/operators/slice_op.cc index 15a76f90c21132..3085c606de6442 100644 --- a/paddle/fluid/operators/slice_op.cc +++ b/paddle/fluid/operators/slice_op.cc @@ -138,8 +138,8 @@ class SliceOp : public framework::OperatorWithKernel { phi::KernelKey GetExpectedKernelType( const framework::ExecutionContext &ctx) const override { auto *in_var = ctx.InputVar("Input"); - if (in_var->IsType()) { - auto &in_tensor = in_var->Get(); + if (in_var->IsType()) { + auto &in_tensor = in_var->Get(); PADDLE_ENFORCE_EQ( in_tensor.IsInitialized(), true, @@ -162,9 +162,8 @@ class SliceOp : public framework::OperatorWithKernel { // reorders, because if blocked dimension is not divisible by 8 or // 16(depending on which blocking format is used) submemory cannot be // created, so in that scenario a fallback is needed - if (ctx.Input("Input") - ->mem_desc() - .get_inner_nblks() == 0) { + if (ctx.Input("Input")->mem_desc().get_inner_nblks() == + 0) { return phi::KernelKey(phi::Backend::ONEDNN, phi::DataLayout::ONEDNN, phi::TransToPhiDataType(input_data_type)); @@ -181,7 +180,7 @@ class SliceOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "StartsTensor" || var_name == "EndsTensor") { return phi::KernelKey(phi::Backend::ALL_BACKEND, @@ -338,7 +337,7 @@ class SliceOpGrad : public framework::OperatorWithKernel { // reorders, because if blocked dimension is not divisible by 8 or // 16(depending on which blocking format is used) submemory cannot be // created, so in that scenario a fallback is needed - if (ctx.Input(framework::GradVarName("Out")) + if (ctx.Input(framework::GradVarName("Out")) ->mem_desc() .get_inner_nblks() == 0) { return phi::KernelKey(phi::Backend::ONEDNN, @@ -352,7 +351,7 @@ class SliceOpGrad : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "StartsTensor" || var_name == "EndsTensor") { return phi::KernelKey(phi::Backend::ALL_BACKEND, @@ -377,7 +376,7 @@ class SliceOpGradVarTypeInference : public framework::VarTypeInference { auto out = framework::GradVarName("Input"); // The types of grad_input and input should always be the same. // The default type of out is phi::DenseTensor, but the type of input can be - // phi::DenseTensor or phi::DenseTensorArray, + // DenseTensor or phi::DenseTensorArray, // so set the type of both to be the same. ctx->SetOutputType(out, ctx->GetInputType(x)); ctx->SetOutputDataType(out, ctx->GetInputDataType(d_out)); diff --git a/paddle/fluid/operators/split_op.cc b/paddle/fluid/operators/split_op.cc index e90a0aafc6e792..0a1eef57abe699 100644 --- a/paddle/fluid/operators/split_op.cc +++ b/paddle/fluid/operators/split_op.cc @@ -80,11 +80,11 @@ class SplitOp : public framework::OperatorWithKernel { const paddle::small_vector §ions_varptr_list = ctx->GetInputVarPtrs("SectionsTensorList"); - std::vector sections_from_tensor; + std::vector sections_from_tensor; sections_from_tensor.reserve(sections_tensor_list_size); for (const auto §ion_varptr : sections_varptr_list) { Variable *var = PADDLE_GET_CONST(Variable *, section_varptr); - sections_from_tensor.emplace_back(var->Get()); + sections_from_tensor.emplace_back(var->Get()); } sections_final = phi::IntArray(sections_from_tensor); } else if (!ctx->IsRuntime() && ctx->HasInputs("SectionsTensorList")) { @@ -123,7 +123,7 @@ class SplitOp : public framework::OperatorWithKernel { // reorders, because if blocked dimension is not divisible by 8 or // 16(depending on which blocking format is used) submemory cannot be // created, so in that scenario a fallback is needed - const auto x_md = ctx.Input("X")->mem_desc(); + const auto x_md = ctx.Input("X")->mem_desc(); if (x_md.get_inner_nblks() == 0) { return phi::KernelKey(phi::Backend::ONEDNN, phi::DataLayout::ONEDNN, @@ -136,7 +136,7 @@ class SplitOp : public framework::OperatorWithKernel { phi::KernelKey GetKernelTypeForVar( const std::string &var_name, - const phi::DenseTensor &tensor, + const DenseTensor &tensor, const phi::KernelKey &expected_kernel_type) const override { if (var_name == "AxisTensor" || var_name == "SectionsTensorList") { return phi::KernelKey(phi::Backend::ALL_BACKEND, diff --git a/paddle/fluid/operators/sum_op.cc b/paddle/fluid/operators/sum_op.cc index 8fde85928e4070..a2d29a8387bde6 100644 --- a/paddle/fluid/operators/sum_op.cc +++ b/paddle/fluid/operators/sum_op.cc @@ -45,7 +45,7 @@ class SumOp : public framework::OperatorWithKernel { common::errors::NotFound("Input var[%s] should not be nullptr", x_vars_name[0])); - if (x_vars[0]->IsType()) { + if (x_vars[0]->IsType()) { int dtype = -1; for (size_t idx = 0; idx < x_vars.size(); ++idx) { PADDLE_ENFORCE_NOT_NULL( @@ -76,12 +76,12 @@ class SumOp : public framework::OperatorWithKernel { // NOTE(jiahongyu): Below codes originally enclosed by PADDLE_WITH_DNNL if (!((data_type == framework::proto::VarType::FP32 || data_type == framework::proto::VarType::BF16) && - ctx.OutputVar("Out")->IsType())) { // NOLINT + ctx.OutputVar("Out")->IsType())) { // NOLINT this->SetDnnFallback(true); } else if (!std::all_of(x_vars.begin(), x_vars.end(), [](const framework::Variable* v) { - return v->IsType(); + return v->IsType(); })) { this->SetDnnFallback(true); } diff --git a/paddle/fluid/operators/tensor_array_to_tensor_op.cc b/paddle/fluid/operators/tensor_array_to_tensor_op.cc index 2e57ffaa22cd09..eaafc82f236b72 100644 --- a/paddle/fluid/operators/tensor_array_to_tensor_op.cc +++ b/paddle/fluid/operators/tensor_array_to_tensor_op.cc @@ -32,7 +32,7 @@ void DenseTensorArray2DenseTensorVector( std::string var_name = base_name + std::to_string(i); framework::Variable *g_feed_value = const_cast(scope).Var(var_name); - auto &feed_input = *(g_feed_value->GetMutable()); + auto &feed_input = *(g_feed_value->GetMutable()); feed_input.ShareDataWith(inx[i]); res_names->push_back(var_name); } @@ -48,7 +48,7 @@ void DenseTensorVectorResizeFromDenseTensorArray( std::string var_name = base_name + std::to_string(i); framework::Variable *g_feed_value = const_cast(scope).Var(var_name); - auto &feed_input = *(g_feed_value->GetMutable()); + auto &feed_input = *(g_feed_value->GetMutable()); auto dims = inx[i].dims(); feed_input.Resize(dims); res_names->push_back(var_name); @@ -68,7 +68,7 @@ void DenseTensorArrayCreateFromDenseTensorArray( std::string var_name = output_lod_tensor_array_name + std::to_string(i); framework::Variable *g_feed_value = const_cast(scope).Var(var_name); - auto &feed_input = *(g_feed_value->GetMutable()); + auto &feed_input = *(g_feed_value->GetMutable()); grad_inx.push_back(feed_input); } } @@ -86,7 +86,7 @@ class DenseTensorArray2TensorOp : public framework::OperatorBase { attrs["axis"] = axis; auto &inx = scope.FindVar(Input("X"))->Get(); - auto &out = *scope.FindVar(Output("Out"))->GetMutable(); + auto &out = *scope.FindVar(Output("Out"))->GetMutable(); const size_t n = inx.size(); PADDLE_ENFORCE_GT( @@ -271,7 +271,7 @@ class DenseTensorArray2TensorGradOp : public framework::OperatorBase { for (size_t i = 0; i < grad_names.size(); i++) { std::string var_name = grad_names[i]; - auto &feed_input = scope.FindVar(var_name)->Get(); + auto &feed_input = scope.FindVar(var_name)->Get(); grad_inx[i].ShareDataWith(feed_input); } } diff --git a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h index 7a3a9c2914fcc1..c4056a8e23378b 100644 --- a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h +++ b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h @@ -282,8 +282,8 @@ class TensorRTEngineOp : public framework::OperatorBase { auto idx = name.find("_cast_auto_mixed.tmp_"); name = name.substr(0, idx); - auto &t = inference::analysis::GetFromScope( - scope, name_real); + auto &t = + inference::analysis::GetFromScope(scope, name_real); VLOG(4) << "trt engine runtime input name(" << name << "), dims(" << t.dims() << ")"; auto t_shape = common::vectorize(t.dims()); @@ -448,7 +448,7 @@ class TensorRTEngineOp : public framework::OperatorBase { std::unordered_map calib_buffers; for (auto &x : input_names_) { if (param_names_.count(x)) continue; - auto &t = inference::analysis::GetFromScope(scope, x); + auto &t = inference::analysis::GetFromScope(scope, x); calib_buffers[x] = t.memory_size(); auto t_shape = common::vectorize(t.dims()); runtime_batch = t_shape[0]; @@ -530,7 +530,7 @@ class TensorRTEngineOp : public framework::OperatorBase { for (auto &x : Inputs("Xs")) { if (param_names_.count(x)) continue; - auto &t = inference::analysis::GetFromScope(scope, x); + auto &t = inference::analysis::GetFromScope(scope, x); calib_data.emplace(x, t.data()); } temp_calibrator->setBatch(calib_data); @@ -581,8 +581,7 @@ class TensorRTEngineOp : public framework::OperatorBase { #endif // convert input and copy to TRT engine's buffer - auto &t = - inference::analysis::GetFromScope(scope, x_real); + auto &t = inference::analysis::GetFromScope(scope, x_real); PADDLE_ENFORCE_GT( t.numel(), 0, @@ -597,7 +596,7 @@ class TensorRTEngineOp : public framework::OperatorBase { // check the input_tensor if (!(t.place().GetType() == phi::AllocationType::GPU)) { - phi::DenseTensor out; + DenseTensor out; phi::Copy(dev_ctx, t, dev_place, false, &out); t.ShareDataWith(out); } @@ -684,8 +683,7 @@ class TensorRTEngineOp : public framework::OperatorBase { if (scope.FindVar(x_t) == nullptr) { const_cast(&scope)->Var(x_t); } - auto int32_tensor = - scope.FindVar(x_t)->GetMutable(); + auto int32_tensor = scope.FindVar(x_t)->GetMutable(); *int32_tensor = phi::Cast( reinterpret_cast(dev_ctx), t, @@ -721,8 +719,7 @@ class TensorRTEngineOp : public framework::OperatorBase { if (scope.FindVar(x_t) == nullptr) { const_cast(&scope)->Var(x_t); } - auto int32_tensor = - scope.FindVar(x_t)->GetMutable(); + auto int32_tensor = scope.FindVar(x_t)->GetMutable(); *int32_tensor = phi::Cast( reinterpret_cast(dev_ctx), t, @@ -763,7 +760,7 @@ class TensorRTEngineOp : public framework::OperatorBase { if (scope.FindVar(x_t) == nullptr) { const_cast(&scope)->Var(x_t); } - auto fp32_tensor = scope.FindVar(x_t)->GetMutable(); + auto fp32_tensor = scope.FindVar(x_t)->GetMutable(); *fp32_tensor = phi::Cast( reinterpret_cast(dev_ctx), t, @@ -774,7 +771,7 @@ class TensorRTEngineOp : public framework::OperatorBase { if (scope.FindVar(x_t) == nullptr) { const_cast(&scope)->Var(x_t); } - auto int32_tensor = scope.FindVar(x_t)->GetMutable(); + auto int32_tensor = scope.FindVar(x_t)->GetMutable(); *int32_tensor = phi::Cast( reinterpret_cast(dev_ctx), t, @@ -856,7 +853,7 @@ class TensorRTEngineOp : public framework::OperatorBase { fluid_v, common::errors::NotFound( "Output variable %s is not found in TensorRT subgraph.", y)); - auto *fluid_t = fluid_v->GetMutable(); + auto *fluid_t = fluid_v->GetMutable(); fluid_t->Resize(common::make_ddim(ddim)); PADDLE_ENFORCE_LT(bind_index, @@ -918,12 +915,12 @@ class TensorRTEngineOp : public framework::OperatorBase { if (type == framework::proto::VarType::INT64) { auto y = Outputs("Ys")[i]; auto *fluid_v = scope.FindVar(y); - auto *fluid_t = fluid_v->GetMutable(); + auto *fluid_t = fluid_v->GetMutable(); std::string y_t = y + "_cast_to_INT64"; if (scope.FindVar(y_t) == nullptr) { const_cast(&scope)->Var(y_t); } - auto int32_tensor = scope.FindVar(y_t)->GetMutable(); + auto int32_tensor = scope.FindVar(y_t)->GetMutable(); int32_tensor->Resize(fluid_t->dims()); dev_ctx.Alloc(int32_tensor); phi::Copy(dev_ctx, *fluid_t, dev_place, false, int32_tensor); @@ -934,12 +931,12 @@ class TensorRTEngineOp : public framework::OperatorBase { } else if (type == framework::proto::VarType::FP64) { auto y = Outputs("Ys")[i]; auto *fluid_v = scope.FindVar(y); - auto *fluid_t = fluid_v->GetMutable(); + auto *fluid_t = fluid_v->GetMutable(); std::string y_t = y + "_cast_to_FP64"; if (scope.FindVar(y_t) == nullptr) { const_cast(&scope)->Var(y_t); } - auto fp32_tensor = scope.FindVar(y_t)->GetMutable(); + auto fp32_tensor = scope.FindVar(y_t)->GetMutable(); fp32_tensor->Resize(fluid_t->dims()); dev_ctx.Alloc(fp32_tensor); phi::Copy(dev_ctx, *fluid_t, dev_place, false, fp32_tensor);