diff --git a/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc b/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc index f02946bddcc625c24fb090489df6701470c1b765..c0dafd8534468829c52a746e1d2ad704dc296549 100644 --- a/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc +++ b/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc @@ -68,11 +68,11 @@ class CinnInstructionRunOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput(kX, - "(vector)" + "(vector)" "which are the input arguments of this cinn instruction") .AsDuplicable(); AddOutput(kOutputs, - "(vector)" + "(vector)" "which are the output arguments of this cinn instruction") .AsDuplicable(); AddAttr( diff --git a/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc b/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc index 47f8973514913a7e6a5caa8de43ab5bea41a41b9..6469ac3ab212c0f8ff84058141b6bce6133ba3ec 100644 --- a/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc +++ b/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc @@ -74,7 +74,7 @@ class TestCinnInstructionRunOp : public ::testing::Test { // so a cinn_instruction_run_op will throw an error framework::Scope scope; InitVariablesWithRandomValue({"x", "y"}, {10, 20}, place, &scope); - scope.Var(test_op_out_name)->GetMutable(); + scope.Var(test_op_out_name)->GetMutable(); ASSERT_THROW(cinn_instruction_run_op->Run(scope, place), paddle::platform::EnforceNotMet); @@ -83,7 +83,7 @@ class TestCinnInstructionRunOp : public ::testing::Test { // of both type float and int cinn_launch_op->Run(scope, place); scope.EraseVars({"x", "y", test_op_out_name}); - scope.Var(test_op_out_name)->GetMutable(); + scope.Var(test_op_out_name)->GetMutable(); InitVariablesWithRandomValue({"x", "y"}, {30, 40}, place, &scope); cinn_launch_op->Run(scope, place); } @@ -92,8 +92,8 @@ class TestCinnInstructionRunOp : public ::testing::Test { // Run ops and check the computation results framework::Scope scope; InitVariablesWithRandomValue({"x", "y"}, {10, 20}, place, &scope); - scope.Var(test_op_out_name)->GetMutable(); - scope.Var(add_op_out_name)->GetMutable(); + scope.Var(test_op_out_name)->GetMutable(); + scope.Var(add_op_out_name)->GetMutable(); elementwise_add_op->Run(scope, place); cinn_launch_op->Run(scope, place); CompareOpResult(scope.GetVar(test_op_out_name), diff --git a/paddle/fluid/operators/cinn/cinn_launch_context.cc b/paddle/fluid/operators/cinn/cinn_launch_context.cc index cc439e44866ac88380d6d6a59c09bfe2e4232c2f..3b9d7d00edad4db9ca3dd98b8af7ac08d087b399 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_context.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_context.cc @@ -45,7 +45,6 @@ namespace paddle { namespace operators::details { -using LoDTensor = phi::DenseTensor; using framework::ParallelExecutor; using framework::Scope; using CinnInstruction = ::cinn::hlir::framework::Instruction; @@ -268,7 +267,8 @@ void CinnLaunchContext::AssignExternalVariable(const std::string& var_name) { // assign external malloc/free callbacks of cinn_buffer_t cinn_buffer->external_malloc = new std::function( [this, var_name](void* ctx, cinn_buffer_t* buffer) { - auto* tensor = cached_scope_->GetVar(var_name)->GetMutable(); + auto* tensor = + cached_scope_->GetVar(var_name)->GetMutable(); tensor->Resize(framework::DDim(buffer->dims, buffer->dimensions)); buffer->memory = reinterpret_cast(tensor->mutable_data( *cached_place_, @@ -294,7 +294,7 @@ void CinnLaunchContext::AssignInternalVariable(const std::string& var_name) { cinn_buffer->external_malloc = new std::function( [this, var_name](void* ctx, cinn_buffer_t* buffer) { auto* tensor = - cached_temp_scope_->Var(var_name)->GetMutable(); + cached_temp_scope_->Var(var_name)->GetMutable(); tensor->Resize(framework::DDim(buffer->dims, buffer->dimensions)); buffer->memory = reinterpret_cast(tensor->mutable_data( *cached_place_, @@ -306,8 +306,8 @@ void CinnLaunchContext::AssignInternalVariable(const std::string& var_name) { // if no instruction use it cinn_buffer->external_free = new std::function( [this, var_name](void* ctx, cinn_buffer_t* buffer) { - auto* tensor = - cached_temp_scope_->GetVar(var_name)->GetMutable(); + auto* tensor = cached_temp_scope_->GetVar(var_name) + ->GetMutable(); tensor->clear(); return 0; }); @@ -438,8 +438,8 @@ ParallelExecutor* CinnLaunchContext::InitializePE(const platform::Place& place, auto* var = scope->GetVar(var_name); auto* buffer = GetCinnBufferOfVar(var_name); auto dim = framework::DDim(buffer->dims, buffer->dimensions); - var->GetMutable()->Resize(dim); - var->GetMutable()->mutable_data( + var->GetMutable()->Resize(dim); + var->GetMutable()->mutable_data( place, framework::paddle2cinn::TransToPaddleDataType(buffer->type)); } return parallel_executor_.get(); diff --git a/paddle/fluid/operators/cinn/cinn_launch_context_test.cc b/paddle/fluid/operators/cinn/cinn_launch_context_test.cc index 34f182d57a36738304111df70dda8b18aa062354..2b4bc9acf12844e9310106a703c13ba7d21ccb85 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_context_test.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_context_test.cc @@ -40,7 +40,6 @@ USE_OP(cinn_instruction_run); namespace paddle { namespace operators::details { -using LoDTensor = phi::DenseTensor; using framework::OpDesc; using framework::ParallelExecutor; using framework::ProgramDesc; @@ -203,8 +202,8 @@ TEST_F(CinnLaunchContextTest, TestConstructResult) { TEST_F(CinnLaunchContextTest, TestCheckTensorEquivalent) { platform::CPUPlace place; framework::Scope scope; - auto* tensor1 = scope.Var("var1")->GetMutable(); - auto* tensor2 = scope.Var("var2")->GetMutable(); + auto* tensor1 = scope.Var("var1")->GetMutable(); + auto* tensor2 = scope.Var("var2")->GetMutable(); // dimension not equivalent tensor1->mutable_data(phi::make_ddim({3, 5}), place); @@ -264,7 +263,7 @@ TEST_F(CinnLaunchContextTest, TestCallbackAssignment) { launch_context->UpdateCapturedEnv(scope, place); // assign external variables - auto* tensor1 = scope.Var("var1")->GetMutable(); + auto* tensor1 = scope.Var("var1")->GetMutable(); float* data1 = tensor1->mutable_data(phi::make_ddim({3, 4}), place); data1[0] = 9.99f; data1[10] = 19.99f; diff --git a/paddle/fluid/operators/cinn/cinn_launch_op.cc b/paddle/fluid/operators/cinn/cinn_launch_op.cc index cd0a31dc0cddd67f0d79b8c5961c4130574e360d..8147541cbaa932777689e8207d57d15100c17e42 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_op.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_op.cc @@ -128,18 +128,18 @@ class CinnLaunchOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput(kX, - "(vector)" + "(vector)" "which are the input of graph inside the CinnLaunchOp" "excluding kNoNeedBufferX.") .AsDuplicable(); AddInput(kNoNeedBufferX, - "(vector)" + "(vector)" "which are the input of graph inside the CinnLaunchOp but" "their buffer are not needed.") .AsDuplicable() .AsDispensable(); AddOutput(kOutputs, - "(vector)" + "(vector)" "which are the output of graph inside the CinnLaunchOp.") .AsDuplicable(); AddAttr( diff --git a/paddle/fluid/operators/cinn/cinn_launch_op.h b/paddle/fluid/operators/cinn/cinn_launch_op.h index 8efe623064badf5b317468bf33e3e795a582d21e..e27ef6079174bec73746b293c6dcd73c0835ba87 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_op.h +++ b/paddle/fluid/operators/cinn/cinn_launch_op.h @@ -34,7 +34,6 @@ DECLARE_bool(enable_pe_launch_cinn); namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using CinnCompiler = framework::paddle2cinn::CinnCompiler; using CinnCompiledObject = framework::paddle2cinn::CinnCompiledObject; @@ -76,29 +75,30 @@ class CinnLaunchOpKernel : public framework::OpKernel { << "value:\n" << CinnCompiler::GetInstance()->ReadableKey(compilation_key); - std::map inputs_name2tensor; + std::map inputs_name2tensor; std::vector input_x_variable_names; std::vector input_no_need_buffer_variable_names; auto add_name2tensor_fn = - [&inputs_name2tensor](const std::vector& variable_names, - const std::vector& tensors) { + [&inputs_name2tensor]( + const std::vector& variable_names, + const std::vector& tensors) { std::transform( variable_names.begin(), variable_names.end(), tensors.begin(), std::inserter(inputs_name2tensor, inputs_name2tensor.end()), - [](const std::string& name, const LoDTensor* tensor) { + [](const std::string& name, const phi::DenseTensor* tensor) { return std::make_pair(name, tensor); }); }; - auto input_x_tensors = ctx.MultiInput(kX); + auto input_x_tensors = ctx.MultiInput(kX); if (!input_x_tensors.empty()) { input_x_variable_names = std::move(ctx.InputNames(kX)); add_name2tensor_fn(input_x_variable_names, input_x_tensors); } auto input_no_need_buffer_tensors = - ctx.MultiInput(kNoNeedBufferX); + ctx.MultiInput(kNoNeedBufferX); if (!input_no_need_buffer_tensors.empty()) { input_no_need_buffer_variable_names = std::move(ctx.InputNames(kNoNeedBufferX)); diff --git a/paddle/fluid/operators/cinn/cinn_launch_op_test.cc b/paddle/fluid/operators/cinn/cinn_launch_op_test.cc index b26c97dda182e797434a54f5c7f7719e7b46e549..dad26dc637400ca80b727e35b41b03ff7a3faf05 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_op_test.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_op_test.cc @@ -78,8 +78,8 @@ class TestCinnLaunchOp : public ::testing::Test { // Run ops and check the computation results framework::Scope scope; InitVariablesWithRandomValue({"x", "y"}, {10, 20}, place, &scope); - scope.Var(test_op_out_name)->GetMutable(); - scope.Var(add_op_out_name)->GetMutable(); + scope.Var(test_op_out_name)->GetMutable(); + scope.Var(add_op_out_name)->GetMutable(); elementwise_add_op->Run(scope, place); cinn_launch_op->Run(scope, place); CompareOpResult(scope.GetVar(test_op_out_name), diff --git a/paddle/fluid/operators/cinn/test_helper.h b/paddle/fluid/operators/cinn/test_helper.h index eed1b72420bfdf199f2bd2e1682816e5196368cb..d35996771b4d9ae3b5794dfd7c4a98197e9be302 100644 --- a/paddle/fluid/operators/cinn/test_helper.h +++ b/paddle/fluid/operators/cinn/test_helper.h @@ -29,7 +29,6 @@ limitations under the License. */ namespace paddle::operators { -using LoDTensor = phi::DenseTensor; using Variable = framework::Variable; using Graph = framework::ir::Graph; using Node = framework::ir::Node; @@ -97,11 +96,11 @@ void InitVariablesWithRandomValue(const std::vector& var_names, std::default_random_engine engine(seed()); std::uniform_real_distribution dist(0, 100); - LoDTensor tmp_tensor; + phi::DenseTensor tmp_tensor; auto* tmp_data = tmp_tensor.mutable_data(common_ddim, platform::CPUPlace()); for (const auto& var_name : var_names) { - auto* tensor = scope->Var(var_name)->GetMutable(); + auto* tensor = scope->Var(var_name)->GetMutable(); tensor->mutable_data(common_ddim, place); for (auto i = 0; i < tensor->numel(); ++i) { tmp_data[i] = static_cast(dist(engine)); @@ -112,11 +111,12 @@ void InitVariablesWithRandomValue(const std::vector& var_names, template void CompareOpResult(Variable* test_out, Variable* expected_out) { - LoDTensor test_tensor, expected_tensor; + phi::DenseTensor test_tensor, expected_tensor; paddle::framework::TensorCopySync( - test_out->Get(), platform::CPUPlace(), &test_tensor); - paddle::framework::TensorCopySync( - expected_out->Get(), platform::CPUPlace(), &expected_tensor); + test_out->Get(), platform::CPUPlace(), &test_tensor); + paddle::framework::TensorCopySync(expected_out->Get(), + platform::CPUPlace(), + &expected_tensor); ASSERT_TRUE(test_tensor.IsInitialized()); ASSERT_TRUE(expected_tensor.IsInitialized()); diff --git a/paddle/fluid/operators/collective/c_embedding_op.cc b/paddle/fluid/operators/collective/c_embedding_op.cc index c11ac829932c15858d475cf5bbbf80f99be4b8af..caea70c223bd349b5a5983253bf7557f579b9f09 100644 --- a/paddle/fluid/operators/collective/c_embedding_op.cc +++ b/paddle/fluid/operators/collective/c_embedding_op.cc @@ -162,7 +162,7 @@ class CEmbeddingOpGradVarTypeInference : public framework::VarTypeInference { void operator()(framework::InferVarTypeContext* ctx) const override { auto out_var_name = framework::GradVarName("W"); VLOG(3) << "c_embedding_grad op " << framework::GradVarName("W") - << " is set to LoDTensor"; + << " is set to phi::DenseTensor"; ctx->SetOutputType(out_var_name, framework::proto::VarType::LOD_TENSOR); ctx->SetOutputDataType(out_var_name, ctx->GetInputDataType("W")); } diff --git a/paddle/fluid/operators/collective/c_embedding_op.cu b/paddle/fluid/operators/collective/c_embedding_op.cu index e1fa8795d420e5892f3fb705962b4398b37508b8..3a8294f52fced927ac052253daa82dcf2545322a 100644 --- a/paddle/fluid/operators/collective/c_embedding_op.cu +++ b/paddle/fluid/operators/collective/c_embedding_op.cu @@ -86,9 +86,9 @@ template class CEmbeddingCUDAKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &context) const override { - auto *table_t = context.Input("W"); - auto *ids_t = context.Input("Ids"); - auto *output_t = context.Output("Out"); + auto *table_t = context.Input("W"); + auto *ids_t = context.Input("Ids"); + auto *output_t = context.Output("Out"); const auto &dev_ctx = context.template device_context(); const int64_t start_idx = context.Attr("start_index"); @@ -142,9 +142,11 @@ class CEmbeddingGradCUDAKernel : public framework::OpKernel { void Compute(const framework::ExecutionContext &context) const override { const auto &dev_ctx = context.template device_context(); const int64_t start_idx = context.Attr("start_index"); - auto ids_t = context.Input("Ids"); - auto d_output_t = context.Input(framework::GradVarName("Out")); - auto d_table_t = context.Output(framework::GradVarName("W")); + auto ids_t = context.Input("Ids"); + auto d_output_t = + context.Input(framework::GradVarName("Out")); + auto d_table_t = + context.Output(framework::GradVarName("W")); int N = d_table_t->dims()[0]; int D = d_table_t->dims()[1]; diff --git a/paddle/fluid/operators/collective/c_embedding_op.h b/paddle/fluid/operators/collective/c_embedding_op.h index 55fd021a7cde3b1508f93bde392026d2571c4d1c..1245d1bafd27c032d3e83328822e323fe661570b 100644 --- a/paddle/fluid/operators/collective/c_embedding_op.h +++ b/paddle/fluid/operators/collective/c_embedding_op.h @@ -25,8 +25,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; - inline void CheckTableValid() {} template @@ -57,9 +55,9 @@ template class CEmbeddingOpCPUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { - auto* table_t = ctx.Input("W"); - auto* ids_t = ctx.Input("Ids"); - auto* output_t = ctx.Output("Out"); + auto* table_t = ctx.Input("W"); + auto* ids_t = ctx.Input("Ids"); + auto* output_t = ctx.Output("Out"); const int64_t start_idx = ctx.Attr("start_index"); VLOG(10) << "table_dims:" << table_t->dims(); @@ -119,10 +117,12 @@ class CEmbeddingGradOpCPUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& context) const override { const int64_t start_idx = context.Attr("start_index"); - auto ids_t = context.Input("Ids"); - auto d_output_t = context.Input(framework::GradVarName("Out")); - auto table_t = context.Input("W"); - auto table_grad_t = context.Output(framework::GradVarName("W")); + auto ids_t = context.Input("Ids"); + auto d_output_t = + context.Input(framework::GradVarName("Out")); + auto table_t = context.Input("W"); + auto table_grad_t = + context.Output(framework::GradVarName("W")); T* table_grad_data = table_grad_t->mutable_data(table_t->dims(), context.GetPlace()); diff --git a/paddle/fluid/operators/collective/c_embedding_op_npu.cc b/paddle/fluid/operators/collective/c_embedding_op_npu.cc index f7fd7fbd83eab41cfdd9c2d42cd9749cfea62db0..c52d6bbe025cb7a08adb89b5cc8e8a18258018b4 100644 --- a/paddle/fluid/operators/collective/c_embedding_op_npu.cc +++ b/paddle/fluid/operators/collective/c_embedding_op_npu.cc @@ -111,9 +111,9 @@ void shard_index(const Tensor &table_t, template void NPUGetIdsEmbedding(const framework::ExecutionContext &context) { - auto *table_t = context.Input("W"); - auto *ids_t = context.Input("Ids"); - auto *output_t = context.Output("Out"); + auto *table_t = context.Input("W"); + auto *ids_t = context.Input("Ids"); + auto *output_t = context.Output("Out"); const int64_t start_idx = context.Attr("start_index"); auto stream = @@ -165,7 +165,7 @@ template class CEmbeddingNPUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &context) const override { - auto *ids_t = context.Input("Ids"); + auto *ids_t = context.Input("Ids"); const auto &index_type = framework::TransToProtoVarType(ids_t->dtype()); if (index_type == framework::proto::VarType::INT32) { @@ -181,10 +181,12 @@ template void NPUUpdateEmbedding(const framework::ExecutionContext &context) { // get inputs const int64_t start_idx = context.Attr("start_index"); - auto ids_t = context.Input("Ids"); - auto d_output_t = context.Input(framework::GradVarName("Out")); + auto ids_t = context.Input("Ids"); + auto d_output_t = + context.Input(framework::GradVarName("Out")); auto table_t = context.Input("W"); - auto table_grad_t = context.Output(framework::GradVarName("W")); + auto table_grad_t = + context.Output(framework::GradVarName("W")); VLOG(10) << "ids_t:" << ids_t << ", d_output_t:" << d_output_t << ", table_t:" << table_t << ", table_grad_t" << table_grad_t; @@ -243,7 +245,7 @@ template class CEmbeddingGradNPUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &context) const override { - auto *ids_t = context.Input("Ids"); + auto *ids_t = context.Input("Ids"); const auto &index_type = framework::TransToProtoVarType(ids_t->dtype()); if (index_type == framework::proto::VarType::INT32) { diff --git a/paddle/fluid/operators/collective/c_embedding_op_xpu.cc b/paddle/fluid/operators/collective/c_embedding_op_xpu.cc index d70da7e3a7d2f7a9daf5d83680c131e89ba9d418..c966ed3354ab15df3b9a73670a0acf8aa43fd693 100644 --- a/paddle/fluid/operators/collective/c_embedding_op_xpu.cc +++ b/paddle/fluid/operators/collective/c_embedding_op_xpu.cc @@ -18,15 +18,13 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; - template class CEmbeddingOpXPUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { - auto* table_t = ctx.Input("W"); - auto* ids_t = ctx.Input("Ids"); - auto* output_t = ctx.Output("Out"); + auto* table_t = ctx.Input("W"); + auto* ids_t = ctx.Input("Ids"); + auto* output_t = ctx.Output("Out"); const int64_t start_index = ctx.Attr("start_index"); const T* table_data = table_t->data(); T* output_data = output_t->mutable_data(ctx.GetPlace()); diff --git a/paddle/fluid/operators/controlflow/conditional_block_op.cc b/paddle/fluid/operators/controlflow/conditional_block_op.cc index d441a84bc638747a99fb2aa40758333defd16586..6425c3519e94c42cff88d13d82e26d38e0a1fca0 100644 --- a/paddle/fluid/operators/controlflow/conditional_block_op.cc +++ b/paddle/fluid/operators/controlflow/conditional_block_op.cc @@ -363,13 +363,14 @@ class ConditionalBlockGradOp : public ConditionalOp { } if (input_var->IsType()) { - PADDLE_ENFORCE_EQ(outside_var->IsType(), - true, - platform::errors::InvalidArgument( - "Type of outside_var %s is NOT LoDTensor, which " - "doesn't match input_var %s.", - outside_grad_name, - input_name)); + PADDLE_ENFORCE_EQ( + outside_var->IsType(), + true, + platform::errors::InvalidArgument( + "Type of outside_var %s is NOT phi::DenseTensor, which " + "doesn't match input_var %s.", + outside_grad_name, + input_name)); AssignZeroToOutsideTensor(place, scope, input_var->Get(), @@ -402,7 +403,8 @@ class ConditionalBlockGradOp : public ConditionalOp { } else { // TODO(huihuangzheng): add support for SelectedRows PADDLE_THROW(platform::errors::InvalidArgument( - "Conditional block grad op doesn't support non-LoDTensor output " + "Conditional block grad op doesn't support non-phi::DenseTensor " + "output " "now.")); } } @@ -475,9 +477,9 @@ class ConditionalBlockGradInferShape : public framework::InferShapeBase { class ConditionalBlockGradInferVarType : public framework::VarTypeInference { public: void operator()(framework::InferVarTypeContext *ctx) const override { - // NOTE(Aurelius84): VarType of Output is LoDTensor by default. In case of - // Input is {Tensor, LoDTensorArray}, we need synchronous the Input's - // VarType into Input@GRAD to avoid generating {Tensor, Tensor} as + // NOTE(Aurelius84): VarType of Output is phi::DenseTensor by default. In + // case of Input is {Tensor, LoDTensorArray}, we need synchronous the + // Input's VarType into Input@GRAD to avoid generating {Tensor, Tensor} as // Input@GRAD. auto input_size = ctx->InputSize(ConditionalOp::kInputs); auto output_size = diff --git a/paddle/fluid/operators/controlflow/conditional_block_op_test.cc b/paddle/fluid/operators/controlflow/conditional_block_op_test.cc index 93947cb52464e508243c8dc6b96f7a5cf1b51b4e..62552dc1fc8ad7f7f42ba99566f02b8a70be855c 100644 --- a/paddle/fluid/operators/controlflow/conditional_block_op_test.cc +++ b/paddle/fluid/operators/controlflow/conditional_block_op_test.cc @@ -21,7 +21,6 @@ limitations under the License. */ USE_NO_KERNEL_OP(conditional_block); USE_NO_KERNEL_OP(conditional_block_grad); -using LoDTensor = phi::DenseTensor; using LoDTensorArray = paddle::framework::LoDTensorArray; using Scope = paddle::framework::Scope; using Variable = paddle::framework::Variable; @@ -32,7 +31,7 @@ TEST(ConditionalBlockGrad, NoNeedRunLoDTensorArray) { Scope scope; Variable* cond_var = scope.Var("condition"); - LoDTensor* cond_tensor = cond_var->GetMutable(); + phi::DenseTensor* cond_tensor = cond_var->GetMutable(); paddle::framework::DDim cond_dims = phi::make_ddim({1}); bool* cond_data = cond_tensor->mutable_data(cond_dims, place); cond_data[0] = false; @@ -41,7 +40,7 @@ TEST(ConditionalBlockGrad, NoNeedRunLoDTensorArray) { LoDTensorArray* input_tensors = input_var->GetMutable(); for (int i = 0; i < 5; ++i) { paddle::framework::DDim in_dims = phi::make_ddim({i + 1, i + 2}); - LoDTensor lod_tensor; + phi::DenseTensor lod_tensor; float* in_data = lod_tensor.mutable_data(in_dims, place); for (int j = 0; j < (i + 1) * (i + 2); ++j) { in_data[j] = static_cast(j); diff --git a/paddle/fluid/operators/controlflow/feed_op.cc b/paddle/fluid/operators/controlflow/feed_op.cc index 65735cfb0c78c60ab73123e7b1f8064b42cdf15b..e076ead891419c00292958fe170a16053b327164 100644 --- a/paddle/fluid/operators/controlflow/feed_op.cc +++ b/paddle/fluid/operators/controlflow/feed_op.cc @@ -29,7 +29,7 @@ namespace paddle { namespace operators { // FeedVariableVisitor is to feed the variable data -// according to data type (LoDTensor or Strings). +// according to data type (phi::DenseTensor or Strings). class FeedVariableVisitor { public: explicit FeedVariableVisitor(framework::Variable *out_var, @@ -146,11 +146,11 @@ class FeedOpInfoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(vector) " - "A feeding list of LoDTensor, which may have " + "(vector) " + "A feeding list of phi::DenseTensor, which may have " "different dimension and data type."); AddOutput("Out", - "(LoDTensor) The LoDTensor which is a copy " + "(phi::DenseTensor) The phi::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 a84c5cf04e2743bb18546b33384bd983bbe0bb85..17b0f577f1468705bc00bf3f810abfd57face975 100644 --- a/paddle/fluid/operators/controlflow/fetch_op.cc +++ b/paddle/fluid/operators/controlflow/fetch_op.cc @@ -143,12 +143,14 @@ class FetchOpInfoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(LoDTensor) The resulted LoDTensor which is expected to return " + "(phi::DenseTensor) The resulted phi::DenseTensor which is " + "expected to return " "to users."); AddOutput( "Out", - "(vector|unordered_map) A fetching list" - " of LoDTensor|unordered_map which may have " + "(vector|unordered_map) A fetching " + "list" + " of phi::DenseTensor|unordered_map which may have " "different dimension, shape and data type."); AddAttr("col", "(int) The column index of fetching object."); AddComment(R"DOC( diff --git a/paddle/fluid/operators/controlflow/fetch_v2_op.cc b/paddle/fluid/operators/controlflow/fetch_v2_op.cc index 4daec3a6f92463a163b4af386883da9a952a6e19..939e58ebbb39cf5341e9f65226857ddc5325f427 100644 --- a/paddle/fluid/operators/controlflow/fetch_v2_op.cc +++ b/paddle/fluid/operators/controlflow/fetch_v2_op.cc @@ -201,10 +201,12 @@ class FetchV2OpProtoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(LoDTensor) The resulted LoDTensor which is expected to return " + "(phi::DenseTensor) The resulted phi::DenseTensor which is " + "expected to return " "to users."); AddOutput("Out", - "(vector) A fetching list of LoDTensor which may have " + "(vector) A fetching list of phi::DenseTensor " + "which may have " "different dimension, shape and data type."); AddAttr("col", "(int) The column index of fetching object."); AddAttr("deepcopy", "(bool) Whether deep copy is required.") diff --git a/paddle/fluid/operators/controlflow/logical_op.cc b/paddle/fluid/operators/controlflow/logical_op.cc index 7e1d6fbdca809f13dbff5d5067a2f0a8873dcdef..c6dde6f4ba53aaf7bd73d802505c4a200068742a 100644 --- a/paddle/fluid/operators/controlflow/logical_op.cc +++ b/paddle/fluid/operators/controlflow/logical_op.cc @@ -35,7 +35,7 @@ class BinaryLogicalOpProtoMaker : public framework::OpProtoAndCheckerMaker { comment.type)); AddOutput("Out", string::Sprintf("n-dim bool Variable")); AddComment(string::Sprintf(R"DOC(%s Operator -It operates element-wise on X and Y, and returns the Out. X, Y and Out are N-dim LoDTensor or Tensor. +It operates element-wise on X and Y, and returns the Out. X, Y and Out are N-dim phi::DenseTensor or Tensor. Each element of Out is calculated by %s )DOC", comment.type, @@ -49,13 +49,14 @@ class UnaryLogicalOpProtoMaker : public framework::OpProtoAndCheckerMaker { void Make() override { OpComment comment; AddInput("X", - string::Sprintf("Operand of %s operator. Must be " - "a LoDTensor or Tensor of type being one of bool, " - "int8, int16, int32, int64, float32, float64.", - comment.type)); - AddOutput("Out", string::Sprintf("n-dim bool LoDTensor or Tensor.")); + string::Sprintf( + "Operand of %s operator. Must be " + "a phi::DenseTensor or Tensor of type being one of bool, " + "int8, int16, int32, int64, float32, float64.", + comment.type)); + AddOutput("Out", string::Sprintf("n-dim bool phi::DenseTensor or Tensor.")); AddComment(string::Sprintf(R"DOC(%s Operator -It operates element-wise on X, and returns the Out. X and Out are N-dim LoDTensor or Tensor. +It operates element-wise on X, and returns the Out. X and Out are N-dim phi::DenseTensor or Tensor. Each element of Out is calculated by %s )DOC", comment.type, 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 f7b7e62279b59b99a402cfa4f7fce523ee02be8d..b9aff315444f52955c9c65b90395a061bb43314a 100644 --- a/paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc +++ b/paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc @@ -67,7 +67,8 @@ class WriteToArrayOp : public ArrayOp { class WriteToArrayOpProtoMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { - AddInput("X", "(LoDTensor) the tensor will be written to tensor array"); + AddInput("X", + "(phi::DenseTensor) the tensor will be written to tensor array"); AddInput( "I", "(Tensor) the subscript index in tensor array. The number of element " @@ -76,9 +77,9 @@ class WriteToArrayOpProtoMaker : public framework::OpProtoAndCheckerMaker { AddComment(R"DOC( WriteToArray Operator. -This operator writes a LoDTensor to a LoDTensor array. +This operator writes a phi::DenseTensor to a phi::DenseTensor array. -Assume $T$ is LoDTensor, $i$ is the subscript of the array, and $A$ is the array. The +Assume $T$ is phi::DenseTensor, $i$ is the subscript of the array, and $A$ is the array. The equation is $$A[i] = T$$ @@ -196,13 +197,13 @@ class ReadFromArrayProtoMaker : public framework::OpProtoAndCheckerMaker { "(Tensor) the writed tensor when used as the grad op of " "write_to_array. We use this to fill zero gradient.") .AsDispensable(); - AddOutput("Out", "(LoDTensor) the tensor will be read from."); + AddOutput("Out", "(phi::DenseTensor) the tensor will be read from."); AddComment(R"DOC( ReadFromArray Operator. -Read a LoDTensor from a LoDTensor Array. +Read a phi::DenseTensor from a phi::DenseTensor Array. -Assume $T$ is LoDTensor, $i$ is the subscript of the array, and $A$ is the array. The +Assume $T$ is phi::DenseTensor, $i$ is the subscript of the array, and $A$ is the array. The equation is $$T = A[i]$$ diff --git a/paddle/fluid/operators/controlflow/while_op.cc b/paddle/fluid/operators/controlflow/while_op.cc index b5e30d8aaf05c71181864d968b9badb858afdb41..cc6bb72324e57ca94bb5bd9a4eecfcfacf683c84 100644 --- a/paddle/fluid/operators/controlflow/while_op.cc +++ b/paddle/fluid/operators/controlflow/while_op.cc @@ -32,7 +32,6 @@ namespace paddle { namespace operators { using StepScopeVar = std::vector; -using LoDTensor = phi::DenseTensor; namespace { // NOLINT static std::string GetSkipEagerDeletionVarsDebugString( @@ -62,7 +61,7 @@ class WhileOp : public framework::OperatorBase { platform::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.dims(), phi::make_ddim({1}), @@ -149,9 +148,10 @@ class WhileOp : public framework::OperatorBase { framework::Variable *input_var = scope.FindVar(input_var_name); 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(); + current_scope.Var(input_var_rename) + ->GetMutable(); framework::TensorCopy( input_var_tensor, dev_place, rename_input_var_tensor); rename_input_var_tensor->set_lod(input_var_tensor.lod()); @@ -166,8 +166,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 { auto ¤t_scope = scope.NewScope(); @@ -188,8 +188,8 @@ class WhileOp : public framework::OperatorBase { } executor.RunPreparedContext( ctx.get(), ¤t_scope, false, false, false); - cond_data = - GetCondData(scope.FindVar(Input(kCondition))->Get()); + cond_data = GetCondData( + scope.FindVar(Input(kCondition))->Get()); } scope.DeleteScope(¤t_scope); } @@ -325,7 +325,8 @@ class WhileGradOp : public framework::OperatorBase { } } else { PADDLE_THROW(platform::errors::Unimplemented( - "Currently only support LoDTensor and LoDTensorArray in " + "Currently only support phi::DenseTensor and " + "phi::DenseTensorArray in " "WhileGradOp.")); } } @@ -398,16 +399,16 @@ class WhileGradOp : public framework::OperatorBase { inside_grad_name)); PADDLE_ENFORCE_EQ( var->IsType() || - var->IsType(), + var->IsType(), true, platform::errors::InvalidArgument( "Currently the type of var only can be LoDTensorArray, " - "or LoDTensor, but the received var[%s] is %s.", + "or phi::DenseTensor, but the received var[%s] is %s.", inside_grad_name, framework::ToTypeName(var->Type()))); if ((var_iter == outside_og_names.end()) && - var->IsType()) { + var->IsType()) { auto &inside_tensor = var->Get(); framework::AttributeMap attrs; attrs["dtype"] = diff --git a/paddle/fluid/operators/detection/bbox_util.cu.h b/paddle/fluid/operators/detection/bbox_util.cu.h index 5e946877e01988903ffb199348b5ae37e6b65355..a9ad6cdfb659df02c9670264002d6652a18bd111 100644 --- a/paddle/fluid/operators/detection/bbox_util.cu.h +++ b/paddle/fluid/operators/detection/bbox_util.cu.h @@ -31,7 +31,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; #define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0)) diff --git a/paddle/fluid/operators/detection/bipartite_match_op.cc b/paddle/fluid/operators/detection/bipartite_match_op.cc index 4eb7584973ab3df5bbc18c9338953b72c941acd1..35368d0034221378a5e542b8c097c97adbb97a28 100644 --- a/paddle/fluid/operators/detection/bipartite_match_op.cc +++ b/paddle/fluid/operators/detection/bipartite_match_op.cc @@ -19,7 +19,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; class BipartiteMatchOp : public framework::OperatorWithKernel { public: @@ -196,7 +195,7 @@ class BipartiteMatchKernel : public framework::OpKernel { } void Compute(const framework::ExecutionContext& context) const override { - auto* dist_mat = context.Input("DistMat"); + auto* dist_mat = context.Input("DistMat"); auto* match_indices = context.Output("ColToRowMatchIndices"); auto* match_dist = context.Output("ColToRowMatchDist"); @@ -251,7 +250,8 @@ class BipartiteMatchOpMaker : public framework::OpProtoAndCheckerMaker { void Make() override { AddInput( "DistMat", - "(LoDTensor or Tensor) this input is a 2-D LoDTensor with shape " + "(phi::DenseTensor or Tensor) this input is a 2-D phi::DenseTensor " + "with shape " "[K, M]. It is pair-wise distance matrix between the entities " "represented by each row and each column. For example, assumed one " "entity is A with shape [K], another entity is B with shape [M]. The " @@ -302,8 +302,8 @@ row entity to the column entity and the matched indices are not duplicated in each row of ColToRowMatchIndices. If the column entity is not matched any row entity, set -1 in ColToRowMatchIndices. -Please note that the input DistMat can be LoDTensor (with LoD) or Tensor. -If LoDTensor with LoD, the height of ColToRowMatchIndices is batch size. +Please note that the input DistMat can be phi::DenseTensor (with LoD) or Tensor. +If phi::DenseTensor with LoD, the height of ColToRowMatchIndices is batch size. If Tensor, the height of ColToRowMatchIndices is 1. )DOC"); diff --git a/paddle/fluid/operators/detection/box_clip_op.cc b/paddle/fluid/operators/detection/box_clip_op.cc index 89650d62351f0295b942b5e95d2b039557c65fa7..46363ceb5355ea5bb19e4b1964b6a1758e209b42 100644 --- a/paddle/fluid/operators/detection/box_clip_op.cc +++ b/paddle/fluid/operators/detection/box_clip_op.cc @@ -66,15 +66,15 @@ class BoxClipOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("Input", - "(LoDTensor) " - "Input is a LoDTensor with shape [..., 4] holds 4 points" + "(phi::DenseTensor) " + "Input is a phi::DenseTensor with shape [..., 4] holds 4 points" "in last dimension in format [xmin, ymin, xmax, ymax]"); AddInput("ImInfo", "(Tensor) Information for image reshape is in shape (N, 3), " "in format (height, width, im_scale)"); AddOutput("Output", - "(LoDTensor) " - "Output is a LoDTensor with the same shape as Input" + "(phi::DenseTensor) " + "Output is a phi::DenseTensor with the same shape as Input" "and it is the result after clip"); AddComment(R"DOC( This operator clips input boxes to original input images. diff --git a/paddle/fluid/operators/detection/box_clip_op.cu b/paddle/fluid/operators/detection/box_clip_op.cu index 8fc8ec221f3e82fc32bb22202567af639b04c364..089f2f556923473851aa261b60e76377ca2b0eb6 100644 --- a/paddle/fluid/operators/detection/box_clip_op.cu +++ b/paddle/fluid/operators/detection/box_clip_op.cu @@ -49,9 +49,9 @@ template class GPUBoxClipKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &context) const override { - auto *input = context.Input("Input"); + auto *input = context.Input("Input"); auto *im_info = context.Input("ImInfo"); - auto *output = context.Output("Output"); + auto *output = context.Output("Output"); const int64_t num = input->dims()[0]; const int64_t bbox_width = input->numel() / num; auto lod = input->lod(); diff --git a/paddle/fluid/operators/detection/box_clip_op.h b/paddle/fluid/operators/detection/box_clip_op.h index 544cb3c0331bf0b7b8af687d50ad2e7956d2ed70..bb72ca194b54c8855a08a5fe520044ab2158212b 100644 --- a/paddle/fluid/operators/detection/box_clip_op.h +++ b/paddle/fluid/operators/detection/box_clip_op.h @@ -20,15 +20,14 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; template class BoxClipKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& context) const override { - auto* input_box = context.Input("Input"); - auto* im_info = context.Input("ImInfo"); - auto* output_box = context.Output("Output"); + auto* input_box = context.Input("Input"); + auto* im_info = context.Input("ImInfo"); + auto* output_box = context.Output("Output"); auto& dev_ctx = context.template device_context(); output_box->mutable_data(context.GetPlace()); if (input_box->lod().size()) { diff --git a/paddle/fluid/operators/detection/box_coder_op.cc b/paddle/fluid/operators/detection/box_coder_op.cc index 5120f687dee0ebcdbf44550fdbc95c2ae196595e..aafe040991ea070ffca469859daf69a733272932 100644 --- a/paddle/fluid/operators/detection/box_coder_op.cc +++ b/paddle/fluid/operators/detection/box_coder_op.cc @@ -44,7 +44,8 @@ class BoxCoderOpMaker : public framework::OpProtoAndCheckerMaker { .AsDispensable(); AddInput( "TargetBox", - "(LoDTensor or Tensor) This input can be a 2-D LoDTensor with shape " + "(phi::DenseTensor or Tensor) This input can be a 2-D phi::DenseTensor " + "with shape " "[N, 4] when code_type is 'encode_center_size'. This input also can " "be a 3-D Tensor with shape [N, M, 4] when code_type is " "'decode_center_size'. [N, 4], each box is represented as " @@ -79,7 +80,7 @@ class BoxCoderOpMaker : public framework::OpProtoAndCheckerMaker { "not be provided at the same time.") .SetDefault(std::vector{}); AddOutput("OutputBox", - "(LoDTensor or Tensor) " + "(phi::DenseTensor or Tensor) " "When code_type is 'encode_center_size', the output tensor of " "box_coder_op with shape [N, M, 4] representing the result of N " "target boxes encoded with M Prior boxes and variances. When " diff --git a/paddle/fluid/operators/detection/box_decoder_and_assign_op.cc b/paddle/fluid/operators/detection/box_decoder_and_assign_op.cc index 62f5523ebc6ae423c64afda4dd4edee4080344a7..7de0f05e0d3ba48cc4f0ddad3e67dfea828f0c22 100644 --- a/paddle/fluid/operators/detection/box_decoder_and_assign_op.cc +++ b/paddle/fluid/operators/detection/box_decoder_and_assign_op.cc @@ -14,8 +14,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; - class BoxDecoderAndAssignOp : public framework::OperatorWithKernel { public: using framework::OperatorWithKernel::OperatorWithKernel; @@ -157,12 +155,12 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker { "default.") .AsDispensable(); AddInput("TargetBox", - "(LoDTensor or Tensor) " - "This input can be a 2-D LoDTensor with shape " + "(phi::DenseTensor or Tensor) " + "This input can be a 2-D phi::DenseTensor with shape " "[N, classnum*4]. It holds N targets for N boxes."); AddInput("BoxScore", - "(LoDTensor or Tensor) " - "This input can be a 2-D LoDTensor with shape " + "(phi::DenseTensor or Tensor) " + "This input can be a 2-D phi::DenseTensor with shape " "[N, classnum], each box is represented as [classnum] which is " "the classification probabilities."); AddAttr("box_clip", @@ -170,12 +168,12 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker { "clip box to prevent overflowing") .SetDefault(4.135f); AddOutput("DecodeBox", - "(LoDTensor or Tensor) " + "(phi::DenseTensor or Tensor) " "the output tensor of op with shape [N, classnum * 4] " "representing the result of N target boxes decoded with " "M Prior boxes and variances for each class."); AddOutput("OutputAssignBox", - "(LoDTensor or Tensor) " + "(phi::DenseTensor or Tensor) " "the output tensor of op with shape [N, 4] " "representing the result of N target boxes decoded with " "M Prior boxes and variances with the best non-background class " diff --git a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc index 2af8521a2db9a582e6b8b0d659a3ec6ee3f03bd7..37dc10df7292a99a9c1cc4f960e6bdf76e023268 100644 --- a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc +++ b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc @@ -17,7 +17,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; class CollectFpnProposalsOp : public framework::OperatorWithKernel { public: using framework::OperatorWithKernel::OperatorWithKernel; @@ -76,8 +75,8 @@ class CollectFpnProposalsOp : public framework::OperatorWithKernel { PADDLE_GET(framework::Variable *, roi_inputs[i]); framework::Variable *score_var = PADDLE_GET(framework::Variable *, score_inputs[i]); - auto &roi_lod = roi_var->Get().lod(); - auto &score_lod = score_var->Get().lod(); + auto &roi_lod = roi_var->Get().lod(); + auto &score_lod = score_var->Get().lod(); PADDLE_ENFORCE_EQ( roi_lod, score_lod, @@ -101,11 +100,13 @@ class CollectFpnProposalsOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("MultiLevelRois", - "(LoDTensor) Multiple roi LoDTensors from each level in shape " + "(phi::DenseTensor) Multiple roi phi::DenseTensors from each " + "level in shape " "(N, 4), N is the number of RoIs") .AsDuplicable(); AddInput("MultiLevelScores", - "(LoDTensor) Multiple score LoDTensors from each level in shape" + "(phi::DenseTensor) Multiple score phi::DenseTensors from each " + "level in shape" " (N, 1), N is the number of RoIs.") .AsDuplicable(); AddInput( @@ -115,7 +116,8 @@ class CollectFpnProposalsOpMaker : public framework::OpProtoAndCheckerMaker { "images.") .AsDuplicable() .AsDispensable(); - AddOutput("FpnRois", "(LoDTensor) All selected RoIs with highest scores"); + AddOutput("FpnRois", + "(phi::DenseTensor) All selected RoIs with highest scores"); AddOutput("RoisNum", "(Tensor), Number of RoIs in each images.") .AsDispensable(); AddAttr("post_nms_topN", diff --git a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu index 18e52957d1acb7117dc4400fff64de11506f971f..b517f2ec1fdd33c2a376ef87730347f08b59d2f5 100644 --- a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu +++ b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu @@ -34,7 +34,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; static constexpr int kNumCUDAThreads = 64; static constexpr int kNumMaxinumNumBlocks = 4096; @@ -58,9 +57,9 @@ template class GPUCollectFpnProposalsOpKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { - const auto roi_ins = ctx.MultiInput("MultiLevelRois"); - const auto score_ins = ctx.MultiInput("MultiLevelScores"); - auto fpn_rois = ctx.Output("FpnRois"); + const auto roi_ins = ctx.MultiInput("MultiLevelRois"); + const auto score_ins = ctx.MultiInput("MultiLevelScores"); + auto fpn_rois = ctx.Output("FpnRois"); auto& dev_ctx = ctx.template device_context(); const int post_nms_topN = ctx.Attr("post_nms_topN"); diff --git a/paddle/fluid/operators/detection/collect_fpn_proposals_op.h b/paddle/fluid/operators/detection/collect_fpn_proposals_op.h index f055de53d5c5c52d98e300ed64bece7ea54fdd6a..1495b880d3ed571329bb47401ee58b6cd21ac178 100644 --- a/paddle/fluid/operators/detection/collect_fpn_proposals_op.h +++ b/paddle/fluid/operators/detection/collect_fpn_proposals_op.h @@ -91,7 +91,7 @@ class CollectFpnProposalsOpKernel : public framework::OpKernel { "is %d", multi_layer_rois.size(), multi_layer_scores.size())); - // Check if the lod information of two LoDTensor is same + // Check if the lod information of two phi::DenseTensor is same const int num_fpn_level = multi_layer_rois.size(); std::vector integral_of_all_rois(num_fpn_level + 1, 0); for (int i = 0; i < num_fpn_level; ++i) { diff --git a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc index 91aeaf3df2f5f242957a25326dde17f5b478c212..20b8846bc4cc6cec908354a1a866b9c8096aa623 100644 --- a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc +++ b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc @@ -37,12 +37,14 @@ class DistributeFpnProposalsOp : public framework::OperatorWithKernel { class DistributeFpnProposalsOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { - AddInput("FpnRois", "(LoDTensor) The RoIs at all levels in shape (-1, 4)"); + AddInput("FpnRois", + "(phi::DenseTensor) The RoIs at all levels in shape (-1, 4)"); AddInput("RoisNum", "(Tensor) The number of RoIs in shape (B)," "B is the number of images") .AsDispensable(); - AddOutput("MultiFpnRois", "(LoDTensor) Output with distribute operator") + AddOutput("MultiFpnRois", + "(phi::DenseTensor) Output with distribute operator") .AsDuplicable(); AddOutput("RestoreIndex", "(Tensor) An array of positive number which is " diff --git a/paddle/fluid/operators/detection/generate_mask_labels_op.cc b/paddle/fluid/operators/detection/generate_mask_labels_op.cc index 9f6d7cc43ab5937851971591db399c69e3832167..f14768168a42597e791e02ae4847886bd3587127 100644 --- a/paddle/fluid/operators/detection/generate_mask_labels_op.cc +++ b/paddle/fluid/operators/detection/generate_mask_labels_op.cc @@ -26,11 +26,12 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; const int kBoxDim = 4; template -void AppendMask(LoDTensor* out, int64_t offset, phi::DenseTensor* to_add) { +void AppendMask(phi::DenseTensor* out, + int64_t offset, + phi::DenseTensor* to_add) { auto* out_data = out->data(); auto* to_add_data = to_add->data(); memcpy(out_data + offset, to_add_data, to_add->numel() * sizeof(T)); @@ -331,16 +332,16 @@ template class GenerateMaskLabelsKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { - auto* im_info = ctx.Input("ImInfo"); - auto* gt_classes = ctx.Input("GtClasses"); - auto* is_crowd = ctx.Input("IsCrowd"); - auto* gt_segms = ctx.Input("GtSegms"); - auto* rois = ctx.Input("Rois"); - auto* label_int32 = ctx.Input("LabelsInt32"); + auto* im_info = ctx.Input("ImInfo"); + auto* gt_classes = ctx.Input("GtClasses"); + auto* is_crowd = ctx.Input("IsCrowd"); + auto* gt_segms = ctx.Input("GtSegms"); + auto* rois = ctx.Input("Rois"); + auto* label_int32 = ctx.Input("LabelsInt32"); - auto* mask_rois = ctx.Output("MaskRois"); - auto* roi_has_mask_int32 = ctx.Output("RoiHasMaskInt32"); - auto* mask_int32 = ctx.Output("MaskInt32"); + auto* mask_rois = ctx.Output("MaskRois"); + auto* roi_has_mask_int32 = ctx.Output("RoiHasMaskInt32"); + auto* mask_int32 = ctx.Output("MaskInt32"); int num_classes = ctx.Attr("num_classes"); int resolution = ctx.Attr("resolution"); @@ -463,17 +464,20 @@ class GenerateMaskLabelsOpMaker : public framework::OpProtoAndCheckerMaker { "B is the number of input images, " "each element consists of im_height, im_width, im_scale."); AddInput("GtClasses", - "(LoDTensor), This input is a 2D LoDTensor with shape [M, 1]. " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with " + "shape [M, 1]. " "M is the number of groundtruth, " "each element is a class label of groundtruth."); AddInput( "IsCrowd", - "(LoDTensor), This input is a 2D LoDTensor with shape [M, 1]. " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with shape " + "[M, 1]. " "M is the number of groundtruth, " "each element is a flag indicates whether a groundtruth is crowd."); AddInput( "GtSegms", - "(LoDTensor), This input is a 2D LoDTensor with shape [S, 2], it's LoD " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with shape " + "[S, 2], it's LoD " "level is 3. The LoD[0] represents the gt objects number of each " "instance. LoD[1] represents the segmentation counts of each objects. " "LoD[2] represents the polygons number of each segmentation. S the " @@ -481,24 +485,29 @@ class GenerateMaskLabelsOpMaker : public framework::OpProtoAndCheckerMaker { "coordinate points."); AddInput( "Rois", - "(LoDTensor), This input is a 2D LoDTensor with shape [R, 4]. " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with shape " + "[R, 4]. " "R is the number of rois which is the output of " "generate_proposal_labels, " "each element is a bounding box with (xmin, ymin, xmax, ymax) format."); AddInput("LabelsInt32", - "(LoDTensor), This intput is a 2D LoDTensor with shape [R, 1], " + "(phi::DenseTensor), This intput is a 2D phi::DenseTensor with " + "shape [R, 1], " "each element represents a class label of a roi"); AddOutput( "MaskRois", - "(LoDTensor), This output is a 2D LoDTensor with shape [P, 4]. " + "(phi::DenseTensor), This output is a 2D phi::DenseTensor with shape " + "[P, 4]. " "P is the number of mask, " "each element is a bounding box with [xmin, ymin, xmax, ymax] format."); AddOutput("RoiHasMaskInt32", - "(LoDTensor), This output is a 2D LoDTensor with shape [P, 1], " + "(phi::DenseTensor), This output is a 2D phi::DenseTensor with " + "shape [P, 1], " "each element represents the output mask rois index with regard " "to input rois"); AddOutput("MaskInt32", - "(LoDTensor), This output is a 4D LoDTensor with shape [P, Q], " + "(phi::DenseTensor), This output is a 4D phi::DenseTensor with " + "shape [P, Q], " "Q equal to num_classes * resolution * resolution"); AddAttr("num_classes", "Class number."); diff --git a/paddle/fluid/operators/detection/generate_proposal_labels_op.cc b/paddle/fluid/operators/detection/generate_proposal_labels_op.cc index d3ae86e234ca94ae54768f99c8c98ada10a2f6b3..1071641b6bc606de8fa50ff69507bb4ad081db60 100644 --- a/paddle/fluid/operators/detection/generate_proposal_labels_op.cc +++ b/paddle/fluid/operators/detection/generate_proposal_labels_op.cc @@ -26,11 +26,12 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; const int kBoxDim = 4; template -void AppendRois(LoDTensor* out, int64_t offset, phi::DenseTensor* to_add) { +void AppendRois(phi::DenseTensor* out, + int64_t offset, + phi::DenseTensor* to_add) { auto* out_data = out->data(); auto* to_add_data = to_add->data(); memcpy(out_data + offset, to_add_data, to_add->numel() * sizeof(T)); @@ -513,19 +514,21 @@ template class GenerateProposalLabelsKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& context) const override { - auto* rpn_rois = context.Input("RpnRois"); - auto* gt_classes = context.Input("GtClasses"); - auto* is_crowd = context.Input("IsCrowd"); - auto* gt_boxes = context.Input("GtBoxes"); - auto* im_info = context.Input("ImInfo"); - - auto* rois = context.Output("Rois"); - auto* labels_int32 = context.Output("LabelsInt32"); - auto* bbox_targets = context.Output("BboxTargets"); - auto* bbox_inside_weights = context.Output("BboxInsideWeights"); + auto* rpn_rois = context.Input("RpnRois"); + auto* gt_classes = context.Input("GtClasses"); + auto* is_crowd = context.Input("IsCrowd"); + auto* gt_boxes = context.Input("GtBoxes"); + auto* im_info = context.Input("ImInfo"); + + auto* rois = context.Output("Rois"); + auto* labels_int32 = context.Output("LabelsInt32"); + auto* bbox_targets = context.Output("BboxTargets"); + auto* bbox_inside_weights = + context.Output("BboxInsideWeights"); auto* bbox_outside_weights = - context.Output("BboxOutsideWeights"); - auto* max_overlap_with_gt = context.Output("MaxOverlapWithGT"); + context.Output("BboxOutsideWeights"); + auto* max_overlap_with_gt = + context.Output("MaxOverlapWithGT"); int batch_size_per_im = context.Attr("batch_size_per_im"); float fg_fraction = context.Attr("fg_fraction"); @@ -685,21 +688,25 @@ class GenerateProposalLabelsOpMaker : public framework::OpProtoAndCheckerMaker { void Make() override { AddInput( "RpnRois", - "(LoDTensor), This input is a 2D LoDTensor with shape [N, 4]. " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with shape " + "[N, 4]. " "N is the number of the GenerateProposalOp's output, " "each element is a bounding box with [xmin, ymin, xmax, ymax] format."); AddInput("GtClasses", - "(LoDTensor), This input is a 2D LoDTensor with shape [M, 1]. " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with " + "shape [M, 1]. " "M is the number of groundtruth, " "each element is a class label of groundtruth."); AddInput( "IsCrowd", - "(LoDTensor), This input is a 2D LoDTensor with shape [M, 1]. " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with shape " + "[M, 1]. " "M is the number of groundtruth, " "each element is a flag indicates whether a groundtruth is crowd."); AddInput( "GtBoxes", - "(LoDTensor), This input is a 2D LoDTensor with shape [M, 4]. " + "(phi::DenseTensor), This input is a 2D phi::DenseTensor with shape " + "[M, 4]. " "M is the number of groundtruth, " "each element is a bounding box with [xmin, ymin, xmax, ymax] format."); AddInput("ImInfo", @@ -707,7 +714,8 @@ class GenerateProposalLabelsOpMaker : public framework::OpProtoAndCheckerMaker { "B is the number of input images, " "each element consists of im_height, im_width, im_scale."); AddInput("MaxOverlap", - "(LoDTensor), This input is a 1D LoDTensor with shape [N]." + "(phi::DenseTensor), This input is a 1D phi::DenseTensor with " + "shape [N]." "N is the number of Input(RpnRois), " "each element is the maximum overlap between " "the proposal RoI and ground-truth.") @@ -715,28 +723,34 @@ class GenerateProposalLabelsOpMaker : public framework::OpProtoAndCheckerMaker { AddOutput( "Rois", - "(LoDTensor), This output is a 2D LoDTensor with shape [P, 4]. " + "(phi::DenseTensor), This output is a 2D phi::DenseTensor with shape " + "[P, 4]. " "P usuall equal to batch_size_per_im * batch_size, " "each element is a bounding box with [xmin, ymin, xmax, ymax] format."); AddOutput("LabelsInt32", - "(LoDTensor), This output is a 2D LoDTensor with shape [P, 1], " + "(phi::DenseTensor), This output is a 2D phi::DenseTensor with " + "shape [P, 1], " "each element represents a class label of a roi"); AddOutput("BboxTargets", - "(LoDTensor), This output is a 2D LoDTensor with shape [P, 4 * " + "(phi::DenseTensor), This output is a 2D phi::DenseTensor with " + "shape [P, 4 * " "class_nums], " "each element represents a box label of a roi"); AddOutput( "BboxInsideWeights", - "(LoDTensor), This output is a 2D LoDTensor with shape [P, 4 * " + "(phi::DenseTensor), This output is a 2D phi::DenseTensor with shape " + "[P, 4 * " "class_nums], " "each element indicates whether a box should contribute to loss."); AddOutput( "BboxOutsideWeights", - "(LoDTensor), This output is a 2D LoDTensor with shape [P, 4 * " + "(phi::DenseTensor), This output is a 2D phi::DenseTensor with shape " + "[P, 4 * " "class_nums], " "each element indicates whether a box should contribute to loss."); AddOutput("MaxOverlapWithGT", - "(LoDTensor), This output is a 1D LoDTensor with shape [P], " + "(phi::DenseTensor), This output is a 1D phi::DenseTensor with " + "shape [P], " "each element indicates the maxoverlap " "between output RoIs and ground-truth. " "The output RoIs may include ground-truth " diff --git a/paddle/fluid/operators/detection/generate_proposals_op.cc b/paddle/fluid/operators/detection/generate_proposals_op.cc index ccb7ca690cfe8becdc3e45f6c92f0d685bc4b700..6491c8b8fcece7d1d3f7e76e65064daf1e655a56 100644 --- a/paddle/fluid/operators/detection/generate_proposals_op.cc +++ b/paddle/fluid/operators/detection/generate_proposals_op.cc @@ -28,7 +28,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; class GenerateProposalsOp : public framework::OperatorWithKernel { public: @@ -90,8 +89,8 @@ class GenerateProposalsKernel : public framework::OpKernel { "Variances", "GenerateProposals"); - auto *rpn_rois = context.Output("RpnRois"); - auto *rpn_roi_probs = context.Output("RpnRoiProbs"); + auto *rpn_rois = context.Output("RpnRois"); + auto *rpn_roi_probs = context.Output("RpnRoiProbs"); int pre_nms_top_n = context.Attr("pre_nms_topN"); int post_nms_top_n = context.Attr("post_nms_topN"); @@ -288,9 +287,10 @@ class GenerateProposalsOpMaker : public framework::OpProtoAndCheckerMaker { "(Tensor) Bounding box variances with same shape as `Anchors`."); AddOutput("RpnRois", - "(LoDTensor), Output proposals with shape (rois_num, 4)."); - AddOutput("RpnRoiProbs", - "(LoDTensor) Scores of proposals with shape (rois_num, 1)."); + "(phi::DenseTensor), Output proposals with shape (rois_num, 4)."); + AddOutput( + "RpnRoiProbs", + "(phi::DenseTensor) Scores of proposals with shape (rois_num, 1)."); AddOutput("RpnRoisNum", "(Tensor), The number of Rpn RoIs in each image") .AsDispensable(); AddAttr("pre_nms_topN", diff --git a/paddle/fluid/operators/detection/generate_proposals_op.cu b/paddle/fluid/operators/detection/generate_proposals_op.cu index 665480f6d733e86fb821989211174f3260b6bdda..0890ff493332c70d55360ac05e32053dd20682fd 100644 --- a/paddle/fluid/operators/detection/generate_proposals_op.cu +++ b/paddle/fluid/operators/detection/generate_proposals_op.cu @@ -29,7 +29,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; namespace { template @@ -144,8 +143,8 @@ class CUDAGenerateProposalsKernel : public framework::OpKernel { "Variances", "GenerateProposals"); - auto *rpn_rois = context.Output("RpnRois"); - auto *rpn_roi_probs = context.Output("RpnRoiProbs"); + auto *rpn_rois = context.Output("RpnRois"); + auto *rpn_roi_probs = context.Output("RpnRoiProbs"); int pre_nms_top_n = context.Attr("pre_nms_topN"); int post_nms_top_n = context.Attr("post_nms_topN"); diff --git a/paddle/fluid/operators/detection/generate_proposals_v2_op.cc b/paddle/fluid/operators/detection/generate_proposals_v2_op.cc index a772efd58dd8a0e6de374077bd945ee16b118e88..08c7a649c1e1f7925e4e68a4623554baee638365 100644 --- a/paddle/fluid/operators/detection/generate_proposals_v2_op.cc +++ b/paddle/fluid/operators/detection/generate_proposals_v2_op.cc @@ -30,7 +30,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; class GenerateProposalsV2Op : public framework::OperatorWithKernel { public: @@ -65,9 +64,10 @@ class GenerateProposalsV2OpMaker : public framework::OpProtoAndCheckerMaker { "(Tensor) Bounding box variances with same shape as `Anchors`."); AddOutput("RpnRois", - "(LoDTensor), Output proposals with shape (rois_num, 4)."); - AddOutput("RpnRoiProbs", - "(LoDTensor) Scores of proposals with shape (rois_num, 1)."); + "(phi::DenseTensor), Output proposals with shape (rois_num, 4)."); + AddOutput( + "RpnRoiProbs", + "(phi::DenseTensor) Scores of proposals with shape (rois_num, 1)."); AddOutput("RpnRoisNum", "(Tensor), The number of Rpn RoIs in each image") .AsDispensable(); AddAttr("pre_nms_topN", diff --git a/paddle/fluid/operators/detection/iou_similarity_op.cc b/paddle/fluid/operators/detection/iou_similarity_op.cc index 5f46e9ab51bc27201c08d55738e421e7c75da615..406114c588ab277f1f1cb9af0323c6bb60c8db75 100644 --- a/paddle/fluid/operators/detection/iou_similarity_op.cc +++ b/paddle/fluid/operators/detection/iou_similarity_op.cc @@ -59,17 +59,18 @@ class IOUSimilarityOp : public framework::OperatorWithKernel { class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { - AddInput("X", - "(LoDTensor, default LoDTensor) " - "Box list X is a 2-D LoDTensor with shape [N, 4] holds N boxes, " - "each box is represented as [xmin, ymin, xmax, ymax], " - "the shape of X is [N, 4]. [xmin, ymin] is the left top " - "coordinate of the box if the input is image feature map, they " - "are close to the origin of the coordinate system. " - "[xmax, ymax] is the right bottom coordinate of the box. " - "This tensor can contain LoD information to represent a batch " - "of inputs. One instance of this batch can contain different " - "numbers of entities."); + AddInput( + "X", + "(phi::DenseTensor, default phi::DenseTensor) " + "Box list X is a 2-D phi::DenseTensor with shape [N, 4] holds N boxes, " + "each box is represented as [xmin, ymin, xmax, ymax], " + "the shape of X is [N, 4]. [xmin, ymin] is the left top " + "coordinate of the box if the input is image feature map, they " + "are close to the origin of the coordinate system. " + "[xmax, ymax] is the right bottom coordinate of the box. " + "This tensor can contain LoD information to represent a batch " + "of inputs. One instance of this batch can contain different " + "numbers of entities."); AddInput("Y", "(Tensor, default Tensor) " "Box list Y holds M boxes, each box is represented as " @@ -82,7 +83,7 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker { "whether treat the priorbox as a normalized box") .SetDefault(true); AddOutput("Out", - "(LoDTensor, the lod is same as input X) The output of " + "(phi::DenseTensor, the lod is same as input X) The output of " "iou_similarity op, a tensor with shape [N, M] " "representing pairwise iou scores."); @@ -90,7 +91,7 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker { **IOU Similarity Operator** Computes intersection-over-union (IOU) between two box lists. -Box list 'X' should be a LoDTensor and 'Y' is a common Tensor, +Box list 'X' should be a phi::DenseTensor and 'Y' is a common Tensor, boxes in 'Y' are shared by all instance of the batched inputs of X. Given two boxes A and B, the calculation of IOU is as follows: diff --git a/paddle/fluid/operators/detection/locality_aware_nms_op.cc b/paddle/fluid/operators/detection/locality_aware_nms_op.cc index 5e77ee33a0781bd800820affe4ed2ffaf5f49174..c2b8833bbd96c1e12d5e2be23b41f90a71710413 100644 --- a/paddle/fluid/operators/detection/locality_aware_nms_op.cc +++ b/paddle/fluid/operators/detection/locality_aware_nms_op.cc @@ -20,7 +20,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; class LocalityAwareNMSOp : public framework::OperatorWithKernel { public: @@ -352,15 +351,15 @@ class LocalityAwareNMSKernel : public framework::OpKernel { } void Compute(const framework::ExecutionContext& ctx) const override { - auto* boxes_input = ctx.Input("BBoxes"); - auto* scores_input = ctx.Input("Scores"); - auto* outs = ctx.Output("Out"); + auto* boxes_input = ctx.Input("BBoxes"); + auto* scores_input = ctx.Input("Scores"); + auto* outs = ctx.Output("Out"); auto& score_dims = scores_input->dims(); auto score_size = score_dims.size(); auto& dev_ctx = ctx.template device_context(); - LoDTensor scores; - LoDTensor boxes; + phi::DenseTensor scores; + phi::DenseTensor boxes; paddle::framework::TensorCopySync( *scores_input, platform::CPUPlace(), &scores); paddle::framework::TensorCopySync( @@ -476,10 +475,12 @@ class LocalityAwareNMSOpMaker : public framework::OpProtoAndCheckerMaker { "Whether detections are normalized.") .SetDefault(true); AddOutput("Out", - "(LoDTensor) A 2-D LoDTensor with shape [No, 6] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 6] " + "represents the " "detections. Each row has 6 values: " "[label, confidence, xmin, ymin, xmax, ymax] or " - "(LoDTensor) A 2-D LoDTensor with shape [No, 10] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 10] " + "represents the " "detections. Each row has 10 values: " "[label, confidence, x1, y1, x2, y2, x3, y3, x4, y4]. No is the " "total number of detections in this mini-batch." @@ -501,7 +502,7 @@ Aftern NMS step, at most keep_top_k number of total bboxes are to be kept per image if keep_top_k is larger than -1. This operator support multi-class and batched inputs. It applying NMS independently for each class. The outputs is a 2-D LoDTenosr, for each -image, the offsets in first dimension of LoDTensor are called LoD, the number +image, the offsets in first dimension of phi::DenseTensor are called LoD, the number of offset is N + 1, where N is the batch size. If LoD[i + 1] - LoD[i] == 0, means there is no detected bbox for this image. diff --git a/paddle/fluid/operators/detection/matrix_nms_op.cc b/paddle/fluid/operators/detection/matrix_nms_op.cc index c122e12b299024869aa9e94832e50d5de931b9c9..21e52a39c37ab3f4e63956b64313705c4e83eef3 100644 --- a/paddle/fluid/operators/detection/matrix_nms_op.cc +++ b/paddle/fluid/operators/detection/matrix_nms_op.cc @@ -21,7 +21,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; class MatrixNMSOp : public framework::OperatorWithKernel { public: @@ -89,14 +88,16 @@ class MatrixNMSOpMaker : public framework::OpProtoAndCheckerMaker { "when 'use_gaussian' is enabled.") .SetDefault(2.); AddOutput("Out", - "(LoDTensor) A 2-D LoDTensor with shape [No, 6] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 6] " + "represents the " "detections. Each row has 6 values: " "[label, confidence, xmin, ymin, xmax, ymax]. " "the offsets in first dimension are called LoD, the number of " "offset is N + 1, if LoD[i + 1] - LoD[i] == 0, means there is " "no detected bbox."); AddOutput("Index", - "(LoDTensor) A 2-D LoDTensor with shape [No, 1] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 1] " + "represents the " "index of selected bbox. The index is the absolute index cross " "batches."); AddOutput("RoisNum", "(Tensor), Number of RoIs in each images.") @@ -113,7 +114,7 @@ Aftern NMS step, at most keep_top_k number of total bboxes are to be kept per image if keep_top_k is larger than -1. This operator support multi-class and batched inputs. It applying NMS independently for each class. The outputs is a 2-D LoDTenosr, for each -image, the offsets in first dimension of LoDTensor are called LoD, the number +image, the offsets in first dimension of phi::DenseTensor are called LoD, the number of offset is N + 1, where N is the batch size. If LoD[i + 1] - LoD[i] == 0, means there is no detected bbox for this image. Now this operator has one more output, which is RoisNum. The size of RoisNum is N, RoisNum[i] means the number of diff --git a/paddle/fluid/operators/detection/mine_hard_examples_op.cc b/paddle/fluid/operators/detection/mine_hard_examples_op.cc index 408e1201e64ad7fd395ee0d263c29e780a0c32d7..28099630b8347c54bf2c8aa1e52532192fffdc80 100644 --- a/paddle/fluid/operators/detection/mine_hard_examples_op.cc +++ b/paddle/fluid/operators/detection/mine_hard_examples_op.cc @@ -363,15 +363,15 @@ class MineHardExamplesOpMaker : public framework::OpProtoAndCheckerMaker { .SetDefault("max_negative") .InEnum({"hard_example", "max_negative"}); - AddOutput( - "NegIndices", - "(LoDTensor) The output of negative example indices. a LoDTensor " - "with shape [Neg, 1]. The size of lod[0] minus 1 is batch size, " - "and each element is the prior box index. " - "For example, the batch size is 2, the lod is [[0, 1, 2]], " - "the sample 0's box 1(MatchIndices[0][1]) is selected, " - "and sample 1's box 0 is selected. The output NegIndices is " - "[[1], [0]]."); + AddOutput("NegIndices", + "(phi::DenseTensor) The output of negative example indices. " + "a phi::DenseTensor " + "with shape [Neg, 1]. The size of lod[0] minus 1 is batch size, " + "and each element is the prior box index. " + "For example, the batch size is 2, the lod is [[0, 1, 2]], " + "the sample 0's box 1(MatchIndices[0][1]) is selected, " + "and sample 1's box 0 is selected. The output NegIndices is " + "[[1], [0]]."); AddOutput("UpdatedMatchIndices", "(Tensor) The output of updated MatchIndices, a tensor with " diff --git a/paddle/fluid/operators/detection/multiclass_nms_op.cc b/paddle/fluid/operators/detection/multiclass_nms_op.cc index 2e24fa3fabb8039a2a64e076f72767376d554c77..5af93551d786f7d172b53fdb71fa17063147b27e 100644 --- a/paddle/fluid/operators/detection/multiclass_nms_op.cc +++ b/paddle/fluid/operators/detection/multiclass_nms_op.cc @@ -22,7 +22,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; inline std::vector GetNmsLodFromRoisNum( const phi::DenseTensor* rois_num) { @@ -357,11 +356,11 @@ class MultiClassNMSKernel : public framework::OpKernel { } void Compute(const framework::ExecutionContext& ctx) const override { - auto* boxes = ctx.Input("BBoxes"); - auto* scores = ctx.Input("Scores"); - auto* outs = ctx.Output("Out"); + auto* boxes = ctx.Input("BBoxes"); + auto* scores = ctx.Input("Scores"); + auto* outs = ctx.Output("Out"); bool return_index = ctx.HasOutput("Index") ? true : false; - auto index = ctx.Output("Index"); + auto index = ctx.Output("Index"); bool has_roisnum = ctx.HasInput("RoisNum") ? true : false; auto rois_num = ctx.Input("RoisNum"); auto score_dims = scores->dims(); @@ -496,7 +495,7 @@ class MultiClassNMSOpMaker : public framework::OpProtoAndCheckerMaker { "predicted locations of M bounding bboxes, N is the batch size. " "Each bounding box has four coordinate values and the layout is " "[xmin, ymin, xmax, ymax], when box size equals to 4." - "2. (LoDTensor) A 3-D Tensor with shape [M, C, 4]" + "2. (phi::DenseTensor) A 3-D Tensor with shape [M, C, 4]" "M is the number of bounding boxes, C is the class number"); AddInput("Scores", "Two types of scores are supported:" @@ -505,7 +504,7 @@ class MultiClassNMSOpMaker : public framework::OpProtoAndCheckerMaker { "class number, M is number of bounding boxes. For each category " "there are total M scores which corresponding M bounding boxes. " " Please note, M is equal to the 2nd dimension of BBoxes. " - "2. (LoDTensor) A 2-D LoDTensor with shape [M, C]. " + "2. (phi::DenseTensor) A 2-D phi::DenseTensor with shape [M, C]. " "M is the number of bbox, C is the class number. In this case, " "Input BBoxes should be the second case with shape [M, C, 4]."); AddAttr( @@ -540,10 +539,12 @@ class MultiClassNMSOpMaker : public framework::OpProtoAndCheckerMaker { "Whether detections are normalized.") .SetDefault(true); AddOutput("Out", - "(LoDTensor) A 2-D LoDTensor with shape [No, 6] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 6] " + "represents the " "detections. Each row has 6 values: " "[label, confidence, xmin, ymin, xmax, ymax] or " - "(LoDTensor) A 2-D LoDTensor with shape [No, 10] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 10] " + "represents the " "detections. Each row has 10 values: " "[label, confidence, x1, y1, x2, y2, x3, y3, x4, y4]. No is the " "total number of detections in this mini-batch." @@ -564,7 +565,7 @@ Aftern NMS step, at most keep_top_k number of total bboxes are to be kept per image if keep_top_k is larger than -1. This operator support multi-class and batched inputs. It applying NMS independently for each class. The outputs is a 2-D LoDTenosr, for each -image, the offsets in first dimension of LoDTensor are called LoD, the number +image, the offsets in first dimension of phi::DenseTensor are called LoD, the number of offset is N + 1, where N is the batch size. If LoD[i + 1] - LoD[i] == 0, means there is no detected bbox for this image. )DOC"); @@ -600,7 +601,8 @@ class MultiClassNMS2OpMaker : public MultiClassNMSOpMaker { void Make() override { MultiClassNMSOpMaker::Make(); AddOutput("Index", - "(LoDTensor) A 2-D LoDTensor with shape [No, 1] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 1] " + "represents the " "index of selected bbox. The index is the absolute index cross " "batches.") .AsIntermediate(); diff --git a/paddle/fluid/operators/detection/retinanet_detection_output_op.cc b/paddle/fluid/operators/detection/retinanet_detection_output_op.cc index 4304e6d4d78b479b1d5aea10a4092453a57894f8..a38765e28d7862526266bf1767e5129d5af3f525 100644 --- a/paddle/fluid/operators/detection/retinanet_detection_output_op.cc +++ b/paddle/fluid/operators/detection/retinanet_detection_output_op.cc @@ -19,7 +19,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; class RetinanetDetectionOutputOp : public framework::OperatorWithKernel { public: @@ -490,8 +489,8 @@ class RetinanetDetectionOutputKernel : public framework::OpKernel { auto boxes = ctx.MultiInput("BBoxes"); auto scores = ctx.MultiInput("Scores"); auto anchors = ctx.MultiInput("Anchors"); - auto* im_info = ctx.Input("ImInfo"); - auto* outs = ctx.Output("Out"); + auto* im_info = ctx.Input("ImInfo"); + auto* outs = ctx.Output("Out"); std::vector boxes_list(boxes.size()); std::vector scores_list(scores.size()); @@ -586,7 +585,8 @@ class RetinanetDetectionOutputOpMaker "[xmin, ymin, xmax, ymax].") .AsDuplicable(); AddInput("ImInfo", - "(LoDTensor) A 2-D LoDTensor with shape [N, 3] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [N, 3] " + "represents the " "image information. N is the batch size, each image information " "includes height, width and scale."); AddAttr("score_threshold", @@ -609,7 +609,8 @@ class RetinanetDetectionOutputOpMaker "Number of total bounding boxes to be kept per image after NMS " "step."); AddOutput("Out", - "(LoDTensor) A 2-D LoDTensor with shape [No, 6] represents the " + "(phi::DenseTensor) A 2-D phi::DenseTensor with shape [No, 6] " + "represents the " "detections. Each row has 6 values: " "[label, confidence, xmin, ymin, xmax, ymax]" "No is the total number of detections in this mini-batch." @@ -650,7 +651,7 @@ After NMS step, at most keep_top_k number of total bounding boxes are to be kept per image if keep_top_k is larger than -1. This operator support multi-class and batched inputs. It applying NMS independently for each class. The outputs is a 2-D LoDTenosr, for each -image, the offsets in first dimension of LoDTensor are called LoD, the number +image, the offsets in first dimension of phi::DenseTensor are called LoD, the number of offset is N + 1, where N is the batch size. If LoD[i + 1] - LoD[i] == 0, means there is no detected bounding box for this image. If there is no detected boxes for all images, all the elements in LoD are set to 0, and the output tensor is diff --git a/paddle/fluid/operators/detection/roi_perspective_transform_op.cc b/paddle/fluid/operators/detection/roi_perspective_transform_op.cc index 2ba1b75f0ca38824f7cc40203bab5d43712ebbe7..ff4c1159119e369f4fa401aeaea1d0d211c3b0aa 100644 --- a/paddle/fluid/operators/detection/roi_perspective_transform_op.cc +++ b/paddle/fluid/operators/detection/roi_perspective_transform_op.cc @@ -23,7 +23,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; template bool GT_E(T a, T b) { @@ -504,7 +503,7 @@ class ROIPerspectiveTransformOp : public framework::OperatorWithKernel { rois_dims.size(), 2, platform::errors::InvalidArgument( - "ROIs should be a 2-D LoDTensor of shape (num_rois, 8)" + "ROIs should be a 2-D phi::DenseTensor of shape (num_rois, 8)" "given as [[x0, y0, x1, y1, x2, y2, x3, y3], ...]. But received " "rois dims is %d", rois_dims.size())); @@ -512,7 +511,7 @@ class ROIPerspectiveTransformOp : public framework::OperatorWithKernel { rois_dims[1], 8, platform::errors::InvalidArgument( - "ROIs should be a 2-D LoDTensor of shape (num_rois, 8)" + "ROIs should be a 2-D phi::DenseTensor of shape (num_rois, 8)" "given as [[x0, y0, x1, y1, x2, y2, x3, y3], ...]. But received %d", rois_dims[1])); @@ -608,9 +607,9 @@ class ROIPerspectiveTransformOpMaker "H is the height of the feature, and " "W is the width of the feature."); AddInput("ROIs", - "(LoDTensor), " + "(phi::DenseTensor), " "ROIs (Regions of Interest) to be transformed. " - "should be a 2-D LoDTensor of shape (num_rois, 8)" + "should be a 2-D phi::DenseTensor of shape (num_rois, 8)" "given as [[x1, y1, x2, y2, x3, y3, x4, y4], ...]." "(x1, y1) is the top left coordinates, and " "(x2, y2) is the top right coordinates, and" diff --git a/paddle/fluid/operators/detection/rpn_target_assign_op.cc b/paddle/fluid/operators/detection/rpn_target_assign_op.cc index 05666e4f7ce478f2507bf5541734b99fe0b2879b..f73ddf9a09e6e00d5eb8b019bba5056e250d2865 100644 --- a/paddle/fluid/operators/detection/rpn_target_assign_op.cc +++ b/paddle/fluid/operators/detection/rpn_target_assign_op.cc @@ -22,7 +22,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; template @@ -105,7 +104,9 @@ class RpnTargetAssignOp : public framework::OperatorWithKernel { }; template -void AppendRpns(LoDTensor* out, int64_t offset, phi::DenseTensor* to_add) { +void AppendRpns(phi::DenseTensor* out, + int64_t offset, + phi::DenseTensor* to_add) { auto* out_data = out->data(); auto* to_add_data = to_add->data(); memcpy(out_data + offset, to_add_data, to_add->numel() * sizeof(T)); @@ -395,15 +396,16 @@ class RpnTargetAssignKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& context) const override { auto* anchor = context.Input("Anchor"); // (H*W*A) * 4 - auto* gt_boxes = context.Input("GtBoxes"); - auto* is_crowd = context.Input("IsCrowd"); - auto* im_info = context.Input("ImInfo"); + auto* gt_boxes = context.Input("GtBoxes"); + auto* is_crowd = context.Input("IsCrowd"); + auto* im_info = context.Input("ImInfo"); - auto* loc_index = context.Output("LocationIndex"); - auto* score_index = context.Output("ScoreIndex"); - auto* tgt_bbox = context.Output("TargetBBox"); - auto* tgt_lbl = context.Output("TargetLabel"); - auto* bbox_inside_weight = context.Output("BBoxInsideWeight"); + auto* loc_index = context.Output("LocationIndex"); + auto* score_index = context.Output("ScoreIndex"); + auto* tgt_bbox = context.Output("TargetBBox"); + auto* tgt_lbl = context.Output("TargetLabel"); + auto* bbox_inside_weight = + context.Output("BBoxInsideWeight"); PADDLE_ENFORCE_EQ(gt_boxes->lod().size(), 1UL, @@ -598,11 +600,11 @@ class RpnTargetAssignOpMaker : public framework::OpProtoAndCheckerMaker { AddInput("Anchor", "(Tensor) input anchor is a 2-D Tensor with shape [H*W*A, 4]."); AddInput("GtBoxes", - "(LoDTensor) input ground-truth bbox with shape [K, 4]."); + "(phi::DenseTensor) input ground-truth bbox with shape [K, 4]."); AddInput("IsCrowd", - "(LoDTensor) input which indicates ground-truth is crowd."); + "(phi::DenseTensor) input which indicates ground-truth is crowd."); AddInput("ImInfo", - "(LoDTensor) input image information with shape [N, 3]. " + "(phi::DenseTensor) input image information with shape [N, 3]. " "N is the batch size, each image information includes height, " "width and scale."); AddAttr("rpn_batch_size_per_im", @@ -685,13 +687,13 @@ class RetinanetTargetAssignOpMaker : public framework::OpProtoAndCheckerMaker { AddInput("Anchor", "(Tensor) input anchor is a 2-D Tensor with shape [H*W*A, 4]."); AddInput("GtBoxes", - "(LoDTensor) input ground-truth bbox with shape [K, 4]."); + "(phi::DenseTensor) input ground-truth bbox with shape [K, 4]."); AddInput("GtLabels", - "(LoDTensor) input ground-truth label with shape [K, 1]."); + "(phi::DenseTensor) input ground-truth label with shape [K, 1]."); AddInput("IsCrowd", - "(LoDTensor) input which indicates ground-truth is crowd."); + "(phi::DenseTensor) input which indicates ground-truth is crowd."); AddInput("ImInfo", - "(LoDTensor) input image information with shape [N, 3]. " + "(phi::DenseTensor) input image information with shape [N, 3]. " "N is the batch size, each image information includes height, " "width and scale."); AddAttr( @@ -994,17 +996,18 @@ class RetinanetTargetAssignKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& context) const override { auto* anchor = context.Input("Anchor"); // (H*W*A) * 4 - auto* gt_boxes = context.Input("GtBoxes"); - auto* gt_labels = context.Input("GtLabels"); - auto* is_crowd = context.Input("IsCrowd"); - auto* im_info = context.Input("ImInfo"); - - auto* loc_index = context.Output("LocationIndex"); - auto* score_index = context.Output("ScoreIndex"); - auto* tgt_bbox = context.Output("TargetBBox"); - auto* tgt_lbl = context.Output("TargetLabel"); - auto* bbox_inside_weight = context.Output("BBoxInsideWeight"); - auto* fg_num = context.Output("ForegroundNumber"); + auto* gt_boxes = context.Input("GtBoxes"); + auto* gt_labels = context.Input("GtLabels"); + auto* is_crowd = context.Input("IsCrowd"); + auto* im_info = context.Input("ImInfo"); + + auto* loc_index = context.Output("LocationIndex"); + auto* score_index = context.Output("ScoreIndex"); + auto* tgt_bbox = context.Output("TargetBBox"); + auto* tgt_lbl = context.Output("TargetLabel"); + auto* bbox_inside_weight = + context.Output("BBoxInsideWeight"); + auto* fg_num = context.Output("ForegroundNumber"); PADDLE_ENFORCE_EQ( gt_boxes->lod().size(), diff --git a/paddle/fluid/operators/detection/target_assign_op.cc b/paddle/fluid/operators/detection/target_assign_op.cc index 5b8e6739bfbfdff0df190a45c759e92b2efd21ee..c3d79b0505070cc6858ebf0127286a08882c1973 100644 --- a/paddle/fluid/operators/detection/target_assign_op.cc +++ b/paddle/fluid/operators/detection/target_assign_op.cc @@ -89,7 +89,8 @@ class TargetAssignOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(LoDTensor), This input is a 3D LoDTensor with shape [M, P, K]. " + "(phi::DenseTensor), This input is a 3D phi::DenseTensor with " + "shape [M, P, K]. " "Some elements in X will be assigned to Out based on the " "MatchIndices and NegIndices."); AddInput("MatchIndices", @@ -97,7 +98,8 @@ class TargetAssignOpMaker : public framework::OpProtoAndCheckerMaker { "with shape [N, P], If MatchIndices[i][j] is -1, the j-th entity " "of column is not matched to any entity of row in i-th instance."); AddInput("NegIndices", - "(LoDTensor, default LoDTensor), The input negative example " + "(phi::DenseTensor, default phi::DenseTensor), The input " + "negative example " "indices are an optional input with shape [Neg, 1], where Neg is " "the total number of negative example indices.") .AsDispensable(); diff --git a/paddle/fluid/operators/elementwise/elementwise_add_op.cc b/paddle/fluid/operators/elementwise/elementwise_add_op.cc index 0123df0006f15e901877a76517121a384e7e3efb..b4164846aa4d68ea1693701c38d8a63bc6e9c79c 100644 --- a/paddle/fluid/operators/elementwise/elementwise_add_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_add_op.cc @@ -31,15 +31,17 @@ class ElementwiseAddOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X + Y"; } void AddInputX() override { - AddInput("X", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "X", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput("Y", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "Y", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFuntionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_div_op.cc b/paddle/fluid/operators/elementwise/elementwise_div_op.cc index 506ba07c67c243de8b192ce2e0cb4980d856b659..f7a9b993c09a4ab611af16f8393e7434ca4d45fd 100644 --- a/paddle/fluid/operators/elementwise/elementwise_div_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_div_op.cc @@ -29,15 +29,17 @@ class ElementwiseDivOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X / Y"; } void AddInputX() override { - AddInput("X", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "X", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput("Y", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "Y", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFuntionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_floordiv_op.cc b/paddle/fluid/operators/elementwise/elementwise_floordiv_op.cc index 6a8c986a53c248f648262c9f095092f367c64022..27c12c300bd9f036cb172af5ec493bab30e92a6f 100644 --- a/paddle/fluid/operators/elementwise/elementwise_floordiv_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_floordiv_op.cc @@ -35,15 +35,17 @@ class ElementwiseFloorDivOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X // Y"; } void AddInputX() override { - AddInput("X", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64."); + AddInput( + "X", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64."); } void AddInputY() override { - AddInput("Y", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64."); + AddInput( + "Y", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64."); } std::string GetOpFuntionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc index a36d979df4ad8c375354eda7db9697a788deb0b5..5048a40dddea4a0669291108b32e0441898f53d2 100644 --- a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc @@ -28,15 +28,17 @@ class ElementwiseMulOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X \\\\odot Y"; } void AddInputX() override { - AddInput("X", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "X", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput("Y", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "Y", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFuntionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_op.h b/paddle/fluid/operators/elementwise/elementwise_op.h index c1dacdcef711e83f1ec429bf2b1a7bb0255020d7..6ab782e07fdca1a7fe73203ad2119f3a6cc37022 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op.h +++ b/paddle/fluid/operators/elementwise/elementwise_op.h @@ -43,13 +43,14 @@ class ElementwiseOp : public framework::OperatorWithKernel { OP_INOUT_CHECK(ctx->HasInput("Y"), "Input", "Y", "ElementwiseOp"); OP_INOUT_CHECK(ctx->HasOutput("Out"), "Output", "Out", "ElementwiseOp"); - PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Y").front(), - framework::proto::VarType::LOD_TENSOR, - platform::errors::InvalidArgument( - "The input var's type should be LoDTensor, but the " - "received is %s [%s].", - ctx->GetInputsVarType("Y").front(), - ctx->Inputs("Y").front())); + PADDLE_ENFORCE_EQ( + ctx->GetInputsVarType("Y").front(), + framework::proto::VarType::LOD_TENSOR, + platform::errors::InvalidArgument( + "The input var's type should be phi::DenseTensor, but the " + "received is %s [%s].", + ctx->GetInputsVarType("Y").front(), + ctx->Inputs("Y").front())); if (ctx->GetInputsVarType("X").front() == framework::proto::VarType::SELECTED_ROWS) { diff --git a/paddle/fluid/operators/elementwise/elementwise_op_function.h b/paddle/fluid/operators/elementwise/elementwise_op_function.h index 5f2097f3330507e621a0e56485b9fdc73d880bab..e1c91d43667be277a035ac776a3263b798c7da08 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op_function.h +++ b/paddle/fluid/operators/elementwise/elementwise_op_function.h @@ -61,11 +61,11 @@ namespace operators { /* * Pack input and output tensors into respective vectors with * consideration of varible X`s class type. - * Input variable X is supported to be whether LoDTensor or + * Input variable X is supported to be whether phi::DenseTensor or * SelectedRows class type in this package function, once X * was SelectedRows type, a valid pointer x_for_selectedrows * is excepted to be passed in from op kernel for acquisition - * of the valid address of LoDTensor created ahead in the function. + * of the valid address of phi::DenseTensor created ahead in the function. */ template int PackTensorsIntoVector(const framework::ExecutionContext &ctx, @@ -112,7 +112,7 @@ int PackTensorsIntoVector(const framework::ExecutionContext &ctx, } else { PADDLE_THROW(platform::errors::InvalidArgument( "X's type[%s] is not supported by elementwise_op. X's type should be " - "LoDTensor or SelectedRows.", + "phi::DenseTensor or SelectedRows.", framework::ToTypeName(x_var->Type()))); } z->mutable_data(ctx.GetPlace()); diff --git a/paddle/fluid/operators/elementwise/elementwise_sub_op.cc b/paddle/fluid/operators/elementwise/elementwise_sub_op.cc index 24f0228025f7fe29cdd8874fd19e3e49cf674f95..c73192ae79205f46df2f248960e1fd31273cca2b 100644 --- a/paddle/fluid/operators/elementwise/elementwise_sub_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_sub_op.cc @@ -34,15 +34,17 @@ class ElementwiseSubOpMaker : public ElementwiseOpMaker { std::string GetEquation() const override { return "Out = X - Y"; } void AddInputX() override { - AddInput("X", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "X", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } void AddInputY() override { - AddInput("Y", - "(Variable), Tensor or LoDTensor of any dimensions. Its dtype " - "should be int32, int64, float32, float64."); + AddInput( + "Y", + "(Variable), Tensor or phi::DenseTensor of any dimensions. Its dtype " + "should be int32, int64, float32, float64."); } std::string GetOpFuntionality() const override { diff --git a/paddle/fluid/operators/elementwise/elementwise_xpu.h b/paddle/fluid/operators/elementwise/elementwise_xpu.h index d1d22d947807929fc0b61e9dcb5374d90b4186e0..c78c5cc6a4b6fcaba1fb2679c8f0b49f5672d6f6 100644 --- a/paddle/fluid/operators/elementwise/elementwise_xpu.h +++ b/paddle/fluid/operators/elementwise/elementwise_xpu.h @@ -43,8 +43,8 @@ void XPUElementwise(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( x_var->IsType(), true, - platform::errors::InvalidArgument( - "XPU only support LoDTensor, Input(X) is not LoDTensor")); + platform::errors::InvalidArgument("XPU only support phi::DenseTensor, " + "Input(X) is not phi::DenseTensor")); auto x = x_var->Get(); auto* y = ctx.Input("Y"); diff --git a/paddle/fluid/operators/fused/fused_bn_activation_op.cc b/paddle/fluid/operators/fused/fused_bn_activation_op.cc index 1627f533492373639dec9dac9a8fb0972f1fe3c0..faf4a1aae44b6fde89f17f6c271dccfe0064ddf4 100644 --- a/paddle/fluid/operators/fused/fused_bn_activation_op.cc +++ b/paddle/fluid/operators/fused/fused_bn_activation_op.cc @@ -24,8 +24,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; - void FusedBatchNormActOp::InferShape(framework::InferShapeContext *ctx) const { PADDLE_ENFORCE_EQ(ctx->HasInput("X"), true, @@ -309,8 +307,8 @@ framework::OpKernelType FusedBatchNormActGradOp::GetExpectedKernelType( const Tensor *t = nullptr; if (var->IsType()) { t = &var->Get(); - } else if (var->IsType()) { - t = &var->Get(); + } else 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 2671e878697a55c1fe77bbc1101595c8d1f93ae3..2d51a3efaf6993ca9e9c98cbe8a2d2b58076ee29 100644 --- a/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc +++ b/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc @@ -23,8 +23,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; - void FusedBatchNormAddActOp::InferShape( framework::InferShapeContext *ctx) const { OP_INOUT_CHECK(ctx->HasInput("X"), "Input", "X", "FusedBatchNormAddActOp"); @@ -267,8 +265,8 @@ framework::OpKernelType FusedBatchNormAddActGradOp::GetExpectedKernelType( const Tensor *t = nullptr; if (var->IsType()) { t = &var->Get(); - } else if (var->IsType()) { - t = &var->Get(); + } else if (var->IsType()) { + t = &var->Get(); } if (t == nullptr) { PADDLE_THROW( diff --git a/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc b/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc index af75fa6112e3af9de75d1a1f39138e069d7c066c..9c58c6900959e3b0ccd0a841f534d07824eb9637 100644 --- a/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc +++ b/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc @@ -213,23 +213,25 @@ void FusedEmbeddingFCLSTMOpMaker::Make() { "input. This is a tensor with shape (N x D), where N is the " "batch size. `H0` and `C0` can be NULL but only at the same time.") .AsDispensable(); - AddOutput("Hidden", - "(LoDTensor) (same as LSTMOp) the hidden state of LSTM operator. " - "The shape is (T x D), and lod is the same with the `Input`."); - AddOutput("Cell", - "(LoDTensor) (same as LSTMOp) the cell state of LSTM operator. " - "The shape is (T x D), and lod is the same with the `Input`."); + AddOutput( + "Hidden", + "(phi::DenseTensor) (same as LSTMOp) the hidden state of LSTM operator. " + "The shape is (T x D), and lod is the same with the `Input`."); + AddOutput( + "Cell", + "(phi::DenseTensor) (same as LSTMOp) the cell state of LSTM operator. " + "The shape is (T x D), and lod is the same with the `Input`."); AddOutput("XX", - "(LoDTensor) the result after X * WeightX (size is T x 4D)" + "(phi::DenseTensor) the result after X * WeightX (size is T x 4D)" " or batched_X (size is T x M), this will be automatically chosen," " where T is the total time steps in this mini-batch," " D is the hidden size, M is the dim size of x input.") .AsIntermediate(); - AddOutput("BatchedInput", "(LoDTensor) (T x 4D).").AsIntermediate(); - AddOutput("BatchedHidden", "(LoDTensor) (T x D).").AsIntermediate(); - AddOutput("BatchedCell", "(LoDTensor) (T x D).").AsIntermediate(); - AddOutput("ReorderedH0", "(LoDTensor) (N x D).").AsIntermediate(); - AddOutput("ReorderedC0", "(LoDTensor) (N x D).").AsIntermediate(); + AddOutput("BatchedInput", "(phi::DenseTensor) (T x 4D).").AsIntermediate(); + AddOutput("BatchedHidden", "(phi::DenseTensor) (T x D).").AsIntermediate(); + AddOutput("BatchedCell", "(phi::DenseTensor) (T x D).").AsIntermediate(); + AddOutput("ReorderedH0", "(phi::DenseTensor) (N x D).").AsIntermediate(); + AddOutput("ReorderedC0", "(phi::DenseTensor) (N x D).").AsIntermediate(); AddAttr("use_peepholes", "(bool, default: True) " "whether to enable diagonal/peephole connections.") @@ -286,15 +288,15 @@ class FusedEmbeddingFCLSTMKernel : public framework::OpKernel { } #define INIT_BASE_INPUT_OUTPUT \ - auto* ids = ctx.Input("Ids"); \ + auto* ids = ctx.Input("Ids"); \ auto* h0 = ctx.Input("H0"); \ auto* c0 = ctx.Input("C0"); \ auto* embeddings = ctx.Input("Embeddings"); \ auto* wh = ctx.Input("WeightH"); \ auto* bias = ctx.Input("Bias"); \ - auto* xx = ctx.Output("XX"); \ - auto* hidden_out = ctx.Output("Hidden"); \ - auto* cell_out = ctx.Output("Cell"); \ + auto* xx = ctx.Output("XX"); \ + auto* hidden_out = ctx.Output("Hidden"); \ + auto* cell_out = ctx.Output("Cell"); \ bool is_reverse = ctx.Attr("is_reverse"); \ bool use_peepholes = ctx.Attr("use_peepholes"); @@ -508,9 +510,9 @@ class FusedEmbeddingFCLSTMKernel : public framework::OpKernel { auto* reordered_h0 = ctx.Output("ReorderedH0"); auto* reordered_c0 = ctx.Output("ReorderedC0"); - auto* batched_input = ctx.Output("BatchedInput"); - auto* batched_c_out = ctx.Output("BatchedCell"); - auto* batched_h_out = ctx.Output("BatchedHidden"); + auto* batched_input = ctx.Output("BatchedInput"); + auto* batched_c_out = ctx.Output("BatchedCell"); + auto* batched_h_out = ctx.Output("BatchedHidden"); T* xx_data = xx->mutable_data(place); T* batched_input_data = batched_input->mutable_data(place); T* batched_c_out_data = batched_c_out->mutable_data(place); diff --git a/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.h b/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.h index 7e0500b87b18f4f11c86fe5ff79627361331ecb3..181fa06b02034290e413fcd75b1572edf8972a2b 100644 --- a/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.h +++ b/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.h @@ -18,7 +18,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusedEmbeddingFCLSTMOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc b/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc index d05fbeac00ad80974c87973bad07e041745dbe01..bbb5ce50c90cac85cdd47db28891f61509e35bcc 100644 --- a/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc +++ b/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc @@ -162,7 +162,7 @@ class FusedEmbeddingSeqPoolOpGradVarTypeInference framework::proto::VarType::SELECTED_ROWS); } else { VLOG(3) << "fused_embedding_seq_pool_grad op " - << framework::GradVarName("W") << " is set to LoDTensor"; + << framework::GradVarName("W") << " is set to phi::DenseTensor"; ctx->SetOutputType(out_var_name, framework::proto::VarType::LOD_TENSOR); } ctx->SetOutputDataType(out_var_name, ctx->GetInputDataType("W")); diff --git a/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.h b/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.h index f069c064791c29cf6e650c4446d2fb132242b4ff..0e4134d428094a3980191a31d9a8289ef25c7bf3 100644 --- a/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.h +++ b/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.h @@ -29,7 +29,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; using SelectedRows = phi::SelectedRows; using DDim = framework::DDim; @@ -83,9 +82,9 @@ void prepare_csr_data(const std::vector &offset, template struct EmbeddingVSumFunctor { void operator()(const framework::ExecutionContext &context, - const LoDTensor *table_t, - const LoDTensor *ids_t, - LoDTensor *output_t) { + const phi::DenseTensor *table_t, + const phi::DenseTensor *ids_t, + phi::DenseTensor *output_t) { auto *table = table_t->data(); int64_t table_height = table_t->dims()[0]; int64_t table_width = table_t->dims()[1]; @@ -141,9 +140,11 @@ template class FusedEmbeddingSeqPoolKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &context) const override { - const LoDTensor *ids_t = context.Input("Ids"); // int tensor - LoDTensor *output_t = context.Output("Out"); // float tensor - const LoDTensor *table_var = context.Input("W"); + const phi::DenseTensor *ids_t = + context.Input("Ids"); // int tensor + phi::DenseTensor *output_t = + context.Output("Out"); // float tensor + const phi::DenseTensor *table_var = context.Input("W"); const std::string &combiner_type = context.Attr("combiner"); int64_t last_dim = @@ -228,23 +229,24 @@ class FusedEmbeddingSeqPoolGradKernel : public framework::OpKernel { void Compute(const framework::ExecutionContext &context) const override { auto *table_var = context.InputVar("W"); DDim table_dim; - if (table_var->IsType()) { - table_dim = context.Input("W")->dims(); + if (table_var->IsType()) { + table_dim = context.Input("W")->dims(); } else if (table_var->IsType()) { auto *table_t = context.Input("W"); table_dim = table_t->value().dims(); } else { PADDLE_THROW(platform::errors::PermissionDenied( "The parameter W of a LookupTable " - "must be either LoDTensor or SelectedRows.")); + "must be either phi::DenseTensor or SelectedRows.")); } bool is_sparse = context.Attr("is_sparse"); // Since paddings are not trainable and fixed in forward, the gradient of // paddings makes no sense and we don't deal with it in backward. if (is_sparse) { - auto *ids = context.Input("Ids"); - auto *d_output = context.Input(framework::GradVarName("Out")); + auto *ids = context.Input("Ids"); + auto *d_output = + context.Input(framework::GradVarName("Out")); auto *d_table = context.Output(framework::GradVarName("W")); // runtime shape @@ -276,9 +278,11 @@ class FusedEmbeddingSeqPoolGradKernel : public framework::OpKernel { } else { #if defined(PADDLE_WITH_MKLML) && !defined(_WIN32) && !defined(__APPLE__) && \ !defined(__OSX__) - auto *ids = context.Input("Ids"); - auto *d_output = context.Input(framework::GradVarName("Out")); - auto *d_table = context.Output(framework::GradVarName("W")); + auto *ids = context.Input("Ids"); + auto *d_output = + context.Input(framework::GradVarName("Out")); + auto *d_table = + context.Output(framework::GradVarName("W")); int64_t padding_idx = context.Attr("padding_idx"); d_table->Resize(table_dim); diff --git a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc index f370d15e5d2867cbe712187e0f45c43a18c1cc0d..95c82c72efde154eec69caec3bd1d7f6cd8d471a 100644 --- a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc +++ b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc @@ -95,7 +95,7 @@ class FusedSeqpoolCVMOp : public framework::OperatorWithKernel { protected: framework::OpKernelType GetExpectedKernelType( const framework::ExecutionContext& ctx) const override { - auto inputs = ctx.MultiInput("X"); + auto inputs = ctx.MultiInput("X"); auto input_data_type = framework::proto::VarType::Type(0); bool flag = 0; for (auto* input : inputs) { @@ -121,7 +121,7 @@ class FusedSeqpoolCVMOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("X", - "(vector) The input tensors of" + "(vector) The input tensors of" " operator.") .AsDuplicable(); AddInput("CVM", diff --git a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu index a58a5ea01d02ee4ec2bc37328d6fd616b1bf22a8..98c2fc9896fee0b5569e834b1692d83b0b226bef 100644 --- a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu +++ b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu @@ -424,7 +424,7 @@ template class FusedSeqpoolCVMCUDAKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &ctx) const override { - auto inputs = ctx.MultiInput("X"); + auto inputs = ctx.MultiInput("X"); auto outputs = ctx.MultiOutput("Out"); auto &dev_ctx = ctx.template device_context(); const auto slot_size = inputs.size(); @@ -432,7 +432,7 @@ class FusedSeqpoolCVMCUDAKernel : public framework::OpKernel { std::vector lods_data(slot_size); std::vector output_data(slot_size); - std::vector seqpool_outputs(slot_size); + std::vector seqpool_outputs(slot_size); std::vector seqpool_output_data(slot_size); auto padding_value = ctx.Attr("pad_value"); @@ -509,9 +509,11 @@ template class FusedSeqpoolCVMGradCUDAKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &ctx) const override { - auto out_grads = ctx.MultiInput(framework::GradVarName("Out")); - auto in_grads = ctx.MultiOutput(framework::GradVarName("X")); - auto *cvm = ctx.Input("CVM"); + auto out_grads = + ctx.MultiInput(framework::GradVarName("Out")); + auto in_grads = + ctx.MultiOutput(framework::GradVarName("X")); + auto *cvm = ctx.Input("CVM"); auto &dev_ctx = ctx.template device_context(); std::string pooltype = ctx.Attr("pooltype"); auto use_cvm = ctx.Attr("use_cvm"); diff --git a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h index a454029050e68d29a147c3c90070631e26560f5e..2c0b8efa8f1125e8505d651264622780c978e8a5 100644 --- a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h +++ b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h @@ -23,8 +23,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; - template class FusedSeqpoolCVMOpCPUKernel : public framework::OpKernel { public: diff --git a/paddle/fluid/operators/fused/fusion_group_op.cc b/paddle/fluid/operators/fused/fusion_group_op.cc index eef2479341b19c0f36f368566ade85b29cb37992..36b97ea7b12bc5d1358aba9bb60704f9f02d27ae 100644 --- a/paddle/fluid/operators/fused/fusion_group_op.cc +++ b/paddle/fluid/operators/fused/fusion_group_op.cc @@ -87,10 +87,10 @@ class FusionGroupOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("Inputs", - "(std::vector) The inputs of fusion_group op.") + "(std::vector) The inputs of fusion_group op.") .AsDuplicable(); AddOutput("Outs", - "(std::vector) The outputs of fusion_group op.") + "(std::vector) The outputs of fusion_group op.") .AsDuplicable(); AddAttr>("outs_dtype", "The data type of Outputs in fusion_group op.") diff --git a/paddle/fluid/operators/fused/fusion_gru_op.cc b/paddle/fluid/operators/fused/fusion_gru_op.cc index f44e7afddbdd22887d2b4d06e9b93c8da17edb8b..814631bd87b471819e05466a72be2450994f3534 100644 --- a/paddle/fluid/operators/fused/fusion_gru_op.cc +++ b/paddle/fluid/operators/fused/fusion_gru_op.cc @@ -154,11 +154,12 @@ framework::OpKernelType FusionGRUOp::GetExpectedKernelType( } void FusionGRUOpMaker::Make() { - AddInput("X", - "(LoDTensor) the input is a LodTensor, which support " - "variable-time length input sequence. The underlying tensor in " - "this LoDTensor 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 a LodTensor, 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("H0", "(Tensor, optional) The initial hidden state is an optional " "input. This is a tensor with shape (N x D), where N is the " @@ -181,18 +182,18 @@ void FusionGRUOpMaker::Make() { AddOutput("ReorderedH0", "(Tensor) (N x D), which N is the min-batch size.") .AsIntermediate(); AddOutput("XX", - "(LoDTensor) the result after X * WeightX (size is T x 3D)" + "(phi::DenseTensor) the result after X * WeightX (size is T x 3D)" " or batched_X (size is T x M), this will be automatically chosen," " where T is the total time steps in this mini-batch," " D is the hidden size, M is the dim size of x input.") .AsIntermediate(); AddOutput("BatchedInput", - "(LoDTensor) This is the batched result of input X" + "(phi::DenseTensor) This is the batched result of input X" "or the batched result after fc, shape (T x 3D)") .AsIntermediate(); - AddOutput("BatchedOut", "(LoDTensor) (T X D) save batched hidden.") + AddOutput("BatchedOut", "(phi::DenseTensor) (T X D) save batched hidden.") .AsIntermediate(); - AddOutput("Hidden", "(LoDTensor) (T x D) Same as GRUOp"); + AddOutput("Hidden", "(phi::DenseTensor) (T x D) Same as GRUOp"); AddAttr("activation", "(string, default tanh) " "The activation type used for output candidate {h}_t.") @@ -257,9 +258,9 @@ class FusionGRUKernel : public framework::OpKernel { } #define INIT_BASE_DEFINES \ - auto* x = ctx.Input("X"); \ + auto* x = ctx.Input("X"); \ auto* wh = ctx.Input("WeightH"); \ - auto* xx = ctx.Output("XX"); \ + auto* xx = ctx.Output("XX"); \ auto x_lod = x->lod(); \ auto x_dims = x->dims(); /* T x M*/ \ auto x_mat_dims = (x_dims.size() == 3 && x_dims[1] == 1) \ @@ -273,7 +274,7 @@ class FusionGRUKernel : public framework::OpKernel { auto* h0 = ctx.Input("H0"); \ auto* wx = ctx.Input("WeightX"); \ auto* bias = ctx.Input("Bias"); \ - auto* hidden_out = ctx.Output("Hidden"); \ + auto* hidden_out = ctx.Output("Hidden"); \ bool is_reverse = ctx.Attr("is_reverse"); \ const int M = x_mat_dims[1]; \ const int D = wh_dims[0]; \ @@ -398,8 +399,8 @@ class FusionGRUKernel : public framework::OpKernel { } INIT_OTHER_DEFINES; auto* reordered_h0 = ctx.Output("ReorderedH0"); - auto* batched_input = ctx.Output("BatchedInput"); - auto* batched_out = ctx.Output("BatchedOut"); + auto* batched_input = ctx.Output("BatchedInput"); + auto* batched_out = ctx.Output("BatchedOut"); T* batched_input_data = batched_input->mutable_data(place); T* batched_out_data = batched_out->mutable_data(place); hidden_out->mutable_data(place); diff --git a/paddle/fluid/operators/fused/fusion_gru_op.h b/paddle/fluid/operators/fused/fusion_gru_op.h index 1003d1e0c29c058f3f00deb63d75505bc719b778..4df5042089053d31786ccedd0867d65a8e407707 100644 --- a/paddle/fluid/operators/fused/fusion_gru_op.h +++ b/paddle/fluid/operators/fused/fusion_gru_op.h @@ -18,7 +18,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusionGRUOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fusion_lstm_op.cc b/paddle/fluid/operators/fused/fusion_lstm_op.cc index 3da1cbd8bebb2b6d3cadecf29cb9abeab9b876a2..b612d590ea1d9745c18a9269d7a1ab0f8edeb9c4 100644 --- a/paddle/fluid/operators/fused/fusion_lstm_op.cc +++ b/paddle/fluid/operators/fused/fusion_lstm_op.cc @@ -177,11 +177,12 @@ framework::OpKernelType FusionLSTMOp::GetExpectedKernelType( } void FusionLSTMOpMaker::Make() { - AddInput("X", - "(LoDTensor) the input is a LodTensor, which support " - "variable-time length input sequence. The underlying tensor in " - "this LoDTensor 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 a LodTensor, 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("WeightX", "(Tensor) the learnable weights of X." " - The shape is (M x 4D), where M is the dim size of x, D is the " @@ -214,23 +215,25 @@ void FusionLSTMOpMaker::Make() { "input. This is a tensor with shape (N x D), where N is the " "batch size. `H0` and `C0` can be NULL but only at the same time.") .AsDispensable(); - AddOutput("Hidden", - "(LoDTensor) (same as LSTMOp) the hidden state of LSTM operator. " - "The shape is (T x D), and lod is the same with the `Input`."); - AddOutput("Cell", - "(LoDTensor) (same as LSTMOp) the cell state of LSTM operator. " - "The shape is (T x D), and lod is the same with the `Input`."); + AddOutput( + "Hidden", + "(phi::DenseTensor) (same as LSTMOp) the hidden state of LSTM operator. " + "The shape is (T x D), and lod is the same with the `Input`."); + AddOutput( + "Cell", + "(phi::DenseTensor) (same as LSTMOp) the cell state of LSTM operator. " + "The shape is (T x D), and lod is the same with the `Input`."); AddOutput("XX", - "(LoDTensor) the result after X * WeightX (size is T x 4D)" + "(phi::DenseTensor) the result after X * WeightX (size is T x 4D)" " or batched_X (size is T x M), this will be automatically chosen," " where T is the total time steps in this mini-batch," " D is the hidden size, M is the dim size of x input.") .AsIntermediate(); - AddOutput("BatchedInput", "(LoDTensor) (T x 4D).").AsIntermediate(); - AddOutput("BatchedHidden", "(LoDTensor) (T x D).").AsIntermediate(); - AddOutput("BatchedCell", "(LoDTensor) (T x D).").AsIntermediate(); - AddOutput("ReorderedH0", "(LoDTensor) (N x D).").AsIntermediate(); - AddOutput("ReorderedC0", "(LoDTensor) (N x D).").AsIntermediate(); + AddOutput("BatchedInput", "(phi::DenseTensor) (T x 4D).").AsIntermediate(); + AddOutput("BatchedHidden", "(phi::DenseTensor) (T x D).").AsIntermediate(); + AddOutput("BatchedCell", "(phi::DenseTensor) (T x D).").AsIntermediate(); + AddOutput("ReorderedH0", "(phi::DenseTensor) (N x D).").AsIntermediate(); + AddOutput("ReorderedC0", "(phi::DenseTensor) (N x D).").AsIntermediate(); AddOutput("CheckedCell", "(Tensor) (2 x D) only for peephole.") .AsIntermediate(); AddAttr("use_peepholes", @@ -295,23 +298,23 @@ This operator fuse the X into LSTM, more details can refer to LSTM op. template class FuisonLSTMKernel : public framework::OpKernel { public: -#define INIT_BASE_DEFINES \ - using DeviceContext = phi::CPUContext; \ - auto* x = ctx.Input("X"); \ - auto* h0 = ctx.Input("H0"); \ - auto* c0 = ctx.Input("C0"); \ - auto* wx = ctx.Input("WeightX"); \ - auto* wh = ctx.Input("WeightH"); \ - auto* bias = ctx.Input("Bias"); \ - auto* xx = ctx.Output("XX"); \ - auto* hidden_out = ctx.Output("Hidden"); \ - auto* cell_out = ctx.Output("Cell"); \ - bool is_reverse = ctx.Attr("is_reverse"); \ - bool use_peepholes = ctx.Attr("use_peepholes"); \ - auto x_dims = x->dims(); /* T x M*/ \ - auto wh_dims = wh->dims(); /* D x 4D*/ \ - const int M = x_dims[1]; \ - const int D = wh_dims[0]; \ +#define INIT_BASE_DEFINES \ + using DeviceContext = phi::CPUContext; \ + auto* x = ctx.Input("X"); \ + auto* h0 = ctx.Input("H0"); \ + auto* c0 = ctx.Input("C0"); \ + auto* wx = ctx.Input("WeightX"); \ + auto* wh = ctx.Input("WeightH"); \ + auto* bias = ctx.Input("Bias"); \ + auto* xx = ctx.Output("XX"); \ + auto* hidden_out = ctx.Output("Hidden"); \ + auto* cell_out = ctx.Output("Cell"); \ + bool is_reverse = ctx.Attr("is_reverse"); \ + bool use_peepholes = ctx.Attr("use_peepholes"); \ + auto x_dims = x->dims(); /* T x M*/ \ + auto wh_dims = wh->dims(); /* D x 4D*/ \ + const int M = x_dims[1]; \ + const int D = wh_dims[0]; \ const int D4 = wh_dims[1] #define INIT_OTHER_DEFINES \ @@ -439,9 +442,9 @@ class FuisonLSTMKernel : public framework::OpKernel { auto* reordered_h0 = ctx.Output("ReorderedH0"); auto* reordered_c0 = ctx.Output("ReorderedC0"); - auto* batched_input = ctx.Output("BatchedInput"); - auto* batched_c_out = ctx.Output("BatchedCell"); - auto* batched_h_out = ctx.Output("BatchedHidden"); + auto* batched_input = ctx.Output("BatchedInput"); + auto* batched_c_out = ctx.Output("BatchedCell"); + auto* batched_h_out = ctx.Output("BatchedHidden"); T* xx_data = xx->mutable_data(place); T* batched_input_data = batched_input->mutable_data(place); T* batched_c_out_data = batched_c_out->mutable_data(place); diff --git a/paddle/fluid/operators/fused/fusion_lstm_op.h b/paddle/fluid/operators/fused/fusion_lstm_op.h index ebcc9ec487740f44dbb938e6be70fab6dfbe3585..590d4bd7c2914f7dd5f73bd9e6410e0d28ee259a 100644 --- a/paddle/fluid/operators/fused/fusion_lstm_op.h +++ b/paddle/fluid/operators/fused/fusion_lstm_op.h @@ -18,7 +18,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusionLSTMOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc b/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc index 50291ee6481411abfe8407ed30959523a5343de6..7bad7c78edc7572089643f7e611205af854d4578 100644 --- a/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc +++ b/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc @@ -106,14 +106,14 @@ framework::OpKernelType FusionRepeatedFCReluOp::GetExpectedKernelType( } void FusionRepeatedFCReluOpMaker::Make() { - AddInput("X", "(LoDTensor) Input tensors of this operator."); + AddInput("X", "(phi::DenseTensor) Input tensors of this operator."); AddInput("W", "(Tensor) The weight tensors of this operator.").AsDuplicable(); AddInput("Bias", "(Tensor) The bias tensors of this operator.") .AsDuplicable(); AddOutput("ReluOut", "(Tensor) The output tensor of each relu operator.") .AsDuplicable() .AsIntermediate(); - AddOutput("Out", "(LoDTensor) Output tensor of this operator."); + AddOutput("Out", "(phi::DenseTensor) Output tensor of this operator."); AddComment(R"DOC( Fusion Repeated FC with Relu Operator. )DOC"); diff --git a/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.h b/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.h index 86342a84b8d9a73615f307274eaa402475573322..2cfb404913c42eb03f30fcb7a3e57b18917f0fe7 100644 --- a/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.h +++ b/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.h @@ -18,7 +18,6 @@ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusionRepeatedFCReluOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc b/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc index 64cc22224d385bb249871fcac1a8fe42e93ec4ef..cb08e4fbff258faa1e94ebdd18749fdcff65e246 100644 --- a/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc @@ -95,11 +95,12 @@ framework::OpKernelType FusionSeqConvEltAddReluOp::GetExpectedKernelType( } void FusionSeqConvEltAddReluOpMaker::Make() { - AddInput("X", - "(LoDTensor) the input is a LodTensor, which support " - "variable-time length input sequence. The underlying tensor in " - "this LoDTensor 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 a LodTensor, 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."); // PaddingData only support false yet, should be ensured at pass. AddInput("Filter", "(Tensor) same as the input(Filter) of sequence conv op is an " @@ -111,9 +112,9 @@ void FusionSeqConvEltAddReluOpMaker::Make() { "output feature size"); AddOutput( "Out", - "(LoDTensor) the output(Out) is a LodTensor, which support " + "(phi::DenseTensor) the output(Out) is a LodTensor, which support " "variable-time length output sequence. The underlying tensor in " - "this LoDTensor is a matrix with shape (T, N), where, T is the " + "this phi::DenseTensor is a matrix with shape (T, N), where, T is the " "total time steps in this mini-batch, N is the output feature size."); AddOutput("ColMat", "(Tensor) (T, K), where T is where T is the " @@ -150,10 +151,10 @@ class FusionSeqConvEltAddReluKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { using DeviceContext = phi::CPUContext; - auto* x = ctx.Input("X"); + auto* x = ctx.Input("X"); auto* w = ctx.Input("Filter"); auto* b = ctx.Input("Bias"); - auto* y = ctx.Output("Out"); + auto* y = ctx.Output("Out"); auto* col = ctx.Output("ColMat"); auto x_lod = x->lod(); diff --git a/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.h b/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.h index e47726b8b85d71bb396c04b79a85bedf25922de4..d1b7ae835821f9cdf85461efbf7c2d874c7b50dd 100644 --- a/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.h +++ b/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.h @@ -18,7 +18,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusionSeqConvEltAddReluOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc b/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc index 095a1c1deb1531384a57b06104ade14d59b52e3d..bcc8ee894543f0b4d1f44ebdd1be8eeaf23d3b35 100644 --- a/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc @@ -110,12 +110,13 @@ framework::OpKernelType FusionSeqExpandConcatFCOp::GetExpectedKernelType( void FusionSeqExpandConcatFCOpMaker::Make() { AddInput("X", - "(LoDTensor) input LodDTensors, the first one must be have ref lod " + "(phi::DenseTensor) input LodDTensors, the first one must be have " + "ref lod " "for sequence expand, and the rest input should have same lod.") .AsDuplicable(); AddInput("FCWeight", "(Tensor) the weights of fc."); AddInput("FCBias", "(Tensor, optional) the bias of fc.").AsDispensable(); - AddOutput("Out", "(LoDTensor) Output LodTensor."); + AddOutput("Out", "(phi::DenseTensor) Output LodTensor."); AddOutput( "FCOut", "(Tensor) the intermediate tensor to keep the result of fc." @@ -150,10 +151,10 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { using DeviceContext = phi::CPUContext; - auto ins = ctx.MultiInput("X"); + auto ins = ctx.MultiInput("X"); auto* w = ctx.Input("FCWeight"); auto* b = ctx.Input("FCBias"); - auto* out = ctx.Output("Out"); + auto* out = ctx.Output("Out"); auto* fc_out = ctx.Output("FCOut"); auto* ref_in = ins[0]; diff --git a/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.h b/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.h index 064fdd7ceb8e855d47b305f335d6cdf163884dbe..9c611025351e8670258207c4d6652a88f7ab324a 100644 --- a/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.h +++ b/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.h @@ -18,7 +18,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusionSeqExpandConcatFCOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc b/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc index d33da7375cdac564d20e859e679cf46df6a04c76..f2f7801d7c2c5c029859be16c7c05fe7803ef426 100644 --- a/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc @@ -75,8 +75,9 @@ framework::OpKernelType FusionSeqPoolConcatOp::GetExpectedKernelType( } void FusionSeqPoolConcatOpMaker::Make() { - AddInput("X", "(LoDTensor) Input tensors of this operator.").AsDuplicable(); - AddOutput("Out", "(LoDTensor) Output tensor of concat operator."); + AddInput("X", "(phi::DenseTensor) Input tensors of this operator.") + .AsDuplicable(); + AddOutput("Out", "(phi::DenseTensor) Output tensor of concat operator."); AddAttr("pooltype", "(string, default 'SUM') some of the pooling " "pooltype of SequencePoolOp.") @@ -95,8 +96,8 @@ template class FusionSeqPoolConcatKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { - auto ins = ctx.MultiInput("X"); - auto* out = ctx.Output("Out"); + auto ins = ctx.MultiInput("X"); + auto* out = ctx.Output("Out"); std::string pooltype = ctx.Attr("pooltype"); auto x0_lod = ins[0]->lod(); const auto& x0_dims = ins[0]->dims(); diff --git a/paddle/fluid/operators/fused/fusion_seqpool_concat_op.h b/paddle/fluid/operators/fused/fusion_seqpool_concat_op.h index e076cfa51bf1ec0d6609fa248dba31bc31618d65..6dc29b23cbb89b1cd2e61483760fe9251b287a73 100644 --- a/paddle/fluid/operators/fused/fusion_seqpool_concat_op.h +++ b/paddle/fluid/operators/fused/fusion_seqpool_concat_op.h @@ -18,7 +18,6 @@ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusionSeqPoolConcatOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc b/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc index b97ceeecb5907cbf53606b7e6f2c25106471f319..41944f4bc095f59d01763994c0b404edcf4b6764 100644 --- a/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc @@ -74,11 +74,12 @@ framework::OpKernelType FusionSeqPoolCVMConcatOp::GetExpectedKernelType( } void FusionSeqPoolCVMConcatOpMaker::Make() { - AddInput("X", "(LoDTensor) Input tensors of this operator.").AsDuplicable(); + AddInput("X", "(phi::DenseTensor) Input tensors of this operator.") + .AsDuplicable(); AddInput("CVM", "(Tensor), a 2-D Tensor with shape [N x 2], where N is the batch " "size, 2 is show and click."); - AddOutput("Out", "(LoDTensor) Output tensor of concat operator."); + AddOutput("Out", "(phi::DenseTensor) Output tensor of concat operator."); AddAttr("pooltype", "(string, default 'SUM') some of the pooling " "pooltype of SequencePoolOp.") @@ -98,8 +99,8 @@ template class FusionSeqPoolCVMConcatKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { - auto ins = ctx.MultiInput("X"); - auto* out = ctx.Output("Out"); + auto ins = ctx.MultiInput("X"); + auto* out = ctx.Output("Out"); std::string pooltype = ctx.Attr("pooltype"); auto x0_lod = ins[0]->lod(); const auto& x0_dims = ins[0]->dims(); diff --git a/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.h b/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.h index 841ea11e33a9b99b9339e230789d32023c57913b..24a02553044b0aea4e7d81af27cb605b6e573678 100644 --- a/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.h +++ b/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.h @@ -18,7 +18,6 @@ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; class FusionSeqPoolCVMConcatOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.h b/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.h index 8a26358c992d4aafc5e2b0d7e8603ff2295bec76..7707bb14fcefe9f1310ae23f8a91315b90f1a88a 100644 --- a/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.h +++ b/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.h @@ -18,7 +18,6 @@ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; using Tensor = phi::DenseTensor; // ( (A.^2 * B.^2) - (A * B).^2 ) .* scalar diff --git a/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc b/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc index 84ee7c0fb9b6aee99e9985cead0039b8efce8870..c7acc1cf730ca98cdfdc157110df48c1e2d5a425 100644 --- a/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc +++ b/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc @@ -59,11 +59,11 @@ class MultiGRUHandler { origin_mode_(ctx.Attr("origin_mode")), layers_(ctx.Attr("layers")), concat_pds_(layers_, std::shared_ptr()), - x_(ctx.Input("X")), + x_(ctx.Input("X")), weights_x_(ctx.MultiInput("WeightX")), weights_h_(ctx.MultiInput("WeightH")), biases_(ctx.MultiInput("Bias")), - hidden_(ctx.Output("Hidden")), + hidden_(ctx.Output("Hidden")), x_lod_(x_->lod()[0]) { PADDLE_ENFORCE_EQ( weights_x_.size(), @@ -127,7 +127,8 @@ class MultiGRUHandler { if (is_int8) { // Add int8 attributes - const auto scale_weights = ctx.MultiInput("Scale_weights"); + const auto scale_weights = + ctx.MultiInput("Scale_weights"); PADDLE_ENFORCE_EQ( scale_weights.size(), layers_ * 2, @@ -669,11 +670,11 @@ class MultiGRUHandler { // on Ti size, thus we need another key to cache them std::string memory_key_; - const LoDTensor* x_; + const phi::DenseTensor* x_; const std::vector weights_x_; const std::vector weights_h_; const std::vector biases_; - LoDTensor* hidden_; + phi::DenseTensor* hidden_; std::vector attrs_; const paddle::framework::Vector& x_lod_; }; diff --git a/paddle/fluid/operators/fused/multi_gru_op.cc b/paddle/fluid/operators/fused/multi_gru_op.cc index 9fb260aee1936d126da0ecf458bc01bd5ff3cd09..0552c3ce9b51151d7f5061778922f32e2b98c2a1 100644 --- a/paddle/fluid/operators/fused/multi_gru_op.cc +++ b/paddle/fluid/operators/fused/multi_gru_op.cc @@ -148,11 +148,12 @@ framework::OpKernelType MultiGRUOp::GetExpectedKernelType( } void MultiGRUOpMaker::Make() { - AddInput("X", - "(LoDTensor) the input is an LodTensor, which support " - "variable-time length input sequence. The underlying tensor in " - "this LoDTensor 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 LodTensor, 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("WeightX", "(MultiTensor) The FC weight with shape (M x 3D)," "where M is the dim size of x, D is the hidden size. ") @@ -176,7 +177,7 @@ void MultiGRUOpMaker::Make() { "Only used with MKL-DNN INT8.") .AsDuplicable() .AsDispensable(); - AddOutput("Hidden", "(LoDTensor) (T x D) Same as GRUOp"); + AddOutput("Hidden", "(phi::DenseTensor) (T x D) Same as GRUOp"); AddAttr("activation", "(string, default tanh) " "The activation type used for output candidate {h}_t.") diff --git a/paddle/fluid/operators/fused/multi_gru_op.h b/paddle/fluid/operators/fused/multi_gru_op.h index 004ca350a4e308c6640dc07e9162990bd646f658..1846d819600f9604719a5513cff5439589882150 100644 --- a/paddle/fluid/operators/fused/multi_gru_op.h +++ b/paddle/fluid/operators/fused/multi_gru_op.h @@ -20,7 +20,6 @@ namespace paddle { namespace operators { using framework::ExecutionContext; -using LoDTensor = phi::DenseTensor; class MultiGRUOp : public framework::OperatorWithKernel { public: diff --git a/paddle/fluid/operators/math/context_project.h b/paddle/fluid/operators/math/context_project.h index 832be9b0efd2f6bd63c3a8d98bbcbba1705e1d15..0038b25fb42de98b86c9b304746ded4b44bfa61f 100644 --- a/paddle/fluid/operators/math/context_project.h +++ b/paddle/fluid/operators/math/context_project.h @@ -27,7 +27,6 @@ namespace operators { namespace math { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; /* * \brief Context projection concatenates features in adjacent time-steps in @@ -51,9 +50,8 @@ using LoDTensor = phi::DenseTensor; * For a mini-batch of 2 variable lengths sentences, containing 3, and 1 * time-steps: * - * Assumed input (X) is a [4, M, N] float LoDTensor, and X->lod()[0] = [0, 3, - * 4]. - * Besides, for the sake of simplicity, we assume M=1 and N=2. + * Assumed input (X) is a [4, M, N] float phi::DenseTensor, and X->lod()[0] = + * [0, 3, 4]. Besides, for the sake of simplicity, we assume M=1 and N=2. * * X = [[a1, a2; * b1, b2; @@ -89,7 +87,7 @@ template class ContextProjectFunctor { public: void operator()(const DeviceContext& context, - const LoDTensor& in, + const phi::DenseTensor& in, const phi::DenseTensor* padding_data, bool padding_trainable, const int context_start, @@ -218,7 +216,7 @@ template class ContextProjectGradFunctor { public: void operator()(const DeviceContext& context, - const LoDTensor& in, + const phi::DenseTensor& in, bool padding_trainable, const int context_start, const int context_length, diff --git a/paddle/fluid/operators/math/sequence_padding.h b/paddle/fluid/operators/math/sequence_padding.h index 8b76f85d7a83ce0f76c821f3c1300e10a585185c..9e7db9f03ed4929479d9493026d9cd3ad39d3543 100644 --- a/paddle/fluid/operators/math/sequence_padding.h +++ b/paddle/fluid/operators/math/sequence_padding.h @@ -82,8 +82,8 @@ inline static void CheckDims(const framework::DDim& seq_tensor_dims, } /* - * \brief Padding/Unpadding LoDTensor to/from normal Tensor of the shape - * [max_sequence_length, num_sequences, sequence_width]. + * \brief Padding/Unpadding phi::DenseTensor to/from normal Tensor of the + * shape [max_sequence_length, num_sequences, sequence_width]. * * Padding sequence: * padding[i] = seq[lod[level][i]] @@ -97,13 +97,11 @@ inline static void CheckDims(const framework::DDim& seq_tensor_dims, * padding (s0, s1, s2, s3; s0, s1, s2, 0; s0, 0, s2, 0; s0, 0, 0, 0) * * \param context device context of this functor. - * \param seq LoDTensor which is stored in sequence format, the shape - * is [total_sequence_length, sequence_width] where - * total_sequence_length is the sum of all sequences' - * length. - * \param padding Tensor which is padded to the same length, the shape is - * [max_sequence_length, num_sequences, sequence_width]. - * \param norm_by_times whether dividing sequence's length. + * \param seq phi::DenseTensor which is stored in sequence format, the + * shape is [total_sequence_length, sequence_width] where total_sequence_length + * is the sum of all sequences' length. \param padding Tensor which is + * padded to the same length, the shape is [max_sequence_length, num_sequences, + * sequence_width]. \param norm_by_times whether dividing sequence's length. * * \note transposition is also done in this functor. */ diff --git a/paddle/fluid/operators/math/sequence_pooling.cc b/paddle/fluid/operators/math/sequence_pooling.cc index 9008111e42b87769d79b4bc148edeb4e50925ddb..65d4a479a4988b31ef30f68c79a401fa3b90aa9e 100644 --- a/paddle/fluid/operators/math/sequence_pooling.cc +++ b/paddle/fluid/operators/math/sequence_pooling.cc @@ -25,7 +25,6 @@ namespace operators { namespace math { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; template diff --git a/paddle/fluid/operators/math/sequence_scale.h b/paddle/fluid/operators/math/sequence_scale.h index e9c1c9832f5243ec3548a3d7c0aabea0cc904134..7d7becbd51a96c4d6d02bb2857b51f5e96285385 100644 --- a/paddle/fluid/operators/math/sequence_scale.h +++ b/paddle/fluid/operators/math/sequence_scale.h @@ -35,7 +35,8 @@ namespace math { * * \param context Device context of this functor. - * \param seq LoDTensor which is stored in sequence format, the shape + * \param seq phi::DenseTensor which is stored in sequence format, the + shape * is [total_sequence_length, sequence_width] where * total_sequence_length is the sum of all sequences' * length. diff --git a/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc index 6a6704c09453341f6ec4115aca8900465b38a732..b4ced90db807c28e3a87ff978799366223e5df3b 100644 --- a/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc @@ -28,7 +28,6 @@ using dnnl::prop_kind; using dnnl::stream; using framework::DDim; using framework::ExecutionContext; -using LoDTensor = phi::DenseTensor; using phi::funcs::OneDNNGetDataType; using phi::funcs::to_void_cast; using platform::MKLDNNDeviceContext; @@ -382,7 +381,7 @@ class FCMKLDNNKernel : public framework::OpKernel { void PrepareSrcMem(const std::shared_ptr& fc_p, const std::shared_ptr& src_mem, - const LoDTensor* x, + const phi::DenseTensor* x, const dnnl::engine& engine) const { auto x_md = x->mem_desc().reshape(src_mem->get_desc().dims()); if (x_md != src_mem->get_desc()) { @@ -403,10 +402,10 @@ class FCMKLDNNKernel : public framework::OpKernel { ctx.template device_context(); const auto& mkldnn_engine = dev_ctx.GetEngine(); - const auto* x = ctx.Input("Input"); + const auto* x = ctx.Input("Input"); const auto* weights = ctx.Input("W"); const auto* bias = ctx.Input("Bias"); - auto out = ctx.Output("Out"); + auto out = ctx.Output("Out"); const auto& scale_weights = ctx.Attr>("Scale_weights"); @@ -513,9 +512,9 @@ class FCMKLDNNKernel : public framework::OpKernel { } void RecomputeOutputDims(const ExecutionContext& ctx, - const LoDTensor* x, + const phi::DenseTensor* x, const phi::DenseTensor* weights, - LoDTensor* out) const { + phi::DenseTensor* out) const { int in_num_col_dims = ctx.Attr("in_num_col_dims"); bool padding_weights = ctx.Attr("padding_weights"); PADDLE_ENFORCE_EQ(padding_weights, diff --git a/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc index 86395b0465d0389f078ad571de7ea8765c12f046..a0bc835a4cc29d70f62ec7a57a2752d590235833 100644 --- a/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc @@ -26,7 +26,6 @@ namespace operators { using framework::DDim; using framework::ExecutionContext; -using LoDTensor = phi::DenseTensor; using platform::MatMulV2MKLDNNHandler; using platform::MKLDNNDeviceContext; diff --git a/paddle/fluid/operators/nccl/nccl_op.cu.cc b/paddle/fluid/operators/nccl/nccl_op.cu.cc index 780e12c1241694600ef29bb17f2a1179414a49a3..d328329e1c24a8011b05eadc19ce7d425fc0ebbd 100644 --- a/paddle/fluid/operators/nccl/nccl_op.cu.cc +++ b/paddle/fluid/operators/nccl/nccl_op.cu.cc @@ -19,8 +19,6 @@ limitations under the License. */ namespace paddle { namespace operators { -using LoDTensor = phi::DenseTensor; - using platform::Communicator; template @@ -62,8 +60,8 @@ class NCCLAllReduceKernel : public framework::OpKernel { true, platform::errors::PreconditionNotMet( "This kernel only runs on GPU device.")); - auto* x = ctx.Input("X"); - auto* out = ctx.Output("Out"); + auto* x = ctx.Input("X"); + auto* out = ctx.Output("Out"); auto* comm = ctx.Input("Communicator"); std::string reduction = ctx.Attr("reduction"); @@ -97,8 +95,8 @@ class NCCLReduceKernel : public framework::OpKernel { true, platform::errors::InvalidArgument( "This kernel only runs on GPU device.")); - auto x = ctx.Input("X"); // x0, x1, x2 - auto out = ctx.Output("Out"); + auto x = ctx.Input("X"); // x0, x1, x2 + auto out = ctx.Output("Out"); auto* comm = ctx.Input("Communicator"); int root = ctx.Attr("root"); std::string reduction = ctx.Attr("reduction"); @@ -144,7 +142,7 @@ class NCCLBcastKernel : public framework::OpKernel { int gpu_id = ctx.GetPlace().GetDeviceId(); int idx = comm->GetCommId(gpu_id); if (idx == root) { - auto* x = ctx.Input("X"); + auto* x = ctx.Input("X"); VLOG(3) << "gpu : " << gpu_id << " invoke Bcast. send " << x->numel(); PADDLE_ENFORCE_GPU_SUCCESS(platform::dynload::ncclBcast( reinterpret_cast(const_cast(x->data())), @@ -155,7 +153,7 @@ class NCCLBcastKernel : public framework::OpKernel { ctx.cuda_device_context().stream())); VLOG(3) << "gpu : " << gpu_id << " finished Bcast."; } else { - auto* out = ctx.Output("Out"); + auto* out = ctx.Output("Out"); VLOG(3) << "gpu : " << gpu_id << " invoke Bcast. recv buffer " << phi::product(out->dims()); PADDLE_ENFORCE_GPU_SUCCESS( diff --git a/paddle/fluid/operators/optimizers/adam_op_mlu.cc b/paddle/fluid/operators/optimizers/adam_op_mlu.cc index 80743606c7cf6ddc043823e408c94a6c9897fce9..c9c33643d1ee518eb2fa8f6916e2a86b6928f902 100644 --- a/paddle/fluid/operators/optimizers/adam_op_mlu.cc +++ b/paddle/fluid/operators/optimizers/adam_op_mlu.cc @@ -20,7 +20,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; template class AdamMLUKernel : public framework::OpKernel { @@ -30,32 +29,32 @@ class AdamMLUKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(param_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Param").front(), framework::ToTypeName(param_var->Type()))); - auto* param = ctx.Input("Param"); + auto* param = ctx.Input("Param"); auto* grad_var = ctx.InputVar("Grad"); PADDLE_ENFORCE_EQ(grad_var->IsType(), true, platform::errors::InvalidArgument( - "The Grad(%s)'s type should be LoDTensor, " + "The Grad(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Grad").front(), framework::ToTypeName(param_var->Type()))); - auto* grad = ctx.Input("Grad"); - auto* mom1 = ctx.Input("Moment1"); - auto* mom2 = ctx.Input("Moment2"); - auto* lr = ctx.Input("LearningRate"); + auto* grad = ctx.Input("Grad"); + auto* mom1 = ctx.Input("Moment1"); + auto* mom2 = ctx.Input("Moment2"); + auto* lr = ctx.Input("LearningRate"); auto* beta1_pow = ctx.Input("Beta1Pow"); auto* beta2_pow = ctx.Input("Beta2Pow"); - auto* param_out = ctx.Output("ParamOut"); - auto* mom1_out = ctx.Output("Moment1Out"); - auto* mom2_out = ctx.Output("Moment2Out"); - auto* beta1_pow_out = ctx.Output("Beta1PowOut"); - auto* beta2_pow_out = ctx.Output("Beta2PowOut"); + auto* param_out = ctx.Output("ParamOut"); + auto* mom1_out = ctx.Output("Moment1Out"); + auto* mom2_out = ctx.Output("Moment2Out"); + auto* beta1_pow_out = ctx.Output("Beta1PowOut"); + auto* beta2_pow_out = ctx.Output("Beta2PowOut"); bool skip_update = false; if (ctx.HasInput("SkipUpdate")) { @@ -110,8 +109,8 @@ class AdamMLUKernel : public framework::OpKernel { mom1_out->ShareDataWith(*mom1); mom2_out->ShareDataWith(*mom2); - LoDTensor beta1_pow_tmp; - LoDTensor beta2_pow_tmp; + phi::DenseTensor beta1_pow_tmp; + phi::DenseTensor beta2_pow_tmp; if (beta1_pow->place() == platform::CPUPlace()) { T beta1 = *beta1_pow->data(); beta1_pow_tmp.mutable_data({1}, ctx.GetPlace()); @@ -292,13 +291,13 @@ class AdamWMLUKernel : public AdamMLUKernel { } bool with_decay = ctx.Attr("with_decay"); const bool multi_precision = ctx.Attr("multi_precision"); - auto* param_out = ctx.Output("ParamOut"); - auto* master_param_out = ctx.Output("MasterParamOut"); - const auto* master_param = ctx.Input("MasterParam"); + auto* param_out = ctx.Output("ParamOut"); + auto* master_param_out = ctx.Output("MasterParamOut"); + const auto* master_param = ctx.Input("MasterParam"); VLOG(3) << "Skip update: " << skip_update << ", With decay: " << with_decay; if (!skip_update && with_decay) { - auto* param = ctx.Input("Param"); + auto* param = ctx.Input("Param"); MLUCnnlTensorDesc param_desc(*param); if (multi_precision) { VLOG(3) << "[adamw] multi_precision, cast masterparam to param."; @@ -328,12 +327,12 @@ class AdamWMLUKernel : public AdamMLUKernel { PADDLE_ENFORCE_EQ(param_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Param").front(), framework::ToTypeName(param_var->Type()))); - auto* lr = ctx.Input("LearningRate"); + auto* lr = ctx.Input("LearningRate"); float coeff = ctx.Attr("coeff"); // update param with decay coeff: mul(-1 * lr, coeff * param) + param @@ -502,8 +501,8 @@ class MergedAdamMLUKernel : public framework::OpKernel { mom1_outs[i]->ShareDataWith(*mom1s[i]); mom2_outs[i]->ShareDataWith(*mom2s[i]); - LoDTensor beta1_pow_tmp; - LoDTensor beta2_pow_tmp; + phi::DenseTensor beta1_pow_tmp; + phi::DenseTensor beta2_pow_tmp; if (beta1_pows[i]->place() == platform::CPUPlace()) { T beta1 = *beta1_pows[i]->data(); beta1_pow_tmp.mutable_data({1}, ctx.GetPlace()); diff --git a/paddle/fluid/operators/optimizers/adam_op_npu.cc b/paddle/fluid/operators/optimizers/adam_op_npu.cc index f53a6b750723b4be6c35565bb47eac81ac3212a3..f94b32413a04a1ca87029d91ace6630978534b3b 100644 --- a/paddle/fluid/operators/optimizers/adam_op_npu.cc +++ b/paddle/fluid/operators/optimizers/adam_op_npu.cc @@ -23,7 +23,6 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; template class AdamNPUKernel : public framework::OpKernel { @@ -33,32 +32,32 @@ class AdamNPUKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(param_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Param").front(), framework::ToTypeName(param_var->Type()))); - auto* param = ctx.Input("Param"); + auto* param = ctx.Input("Param"); auto* grad_var = ctx.InputVar("Grad"); PADDLE_ENFORCE_EQ(grad_var->IsType(), true, platform::errors::InvalidArgument( - "The Grad(%s)'s type should be LoDTensor, " + "The Grad(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Grad").front(), framework::ToTypeName(param_var->Type()))); - auto* grad = ctx.Input("Grad"); - auto* mom1 = ctx.Input("Moment1"); - auto* mom2 = ctx.Input("Moment2"); - auto* lr = ctx.Input("LearningRate"); + auto* grad = ctx.Input("Grad"); + auto* mom1 = ctx.Input("Moment1"); + auto* mom2 = ctx.Input("Moment2"); + auto* lr = ctx.Input("LearningRate"); auto* beta1_pow = ctx.Input("Beta1Pow"); auto* beta2_pow = ctx.Input("Beta2Pow"); - auto* param_out = ctx.Output("ParamOut"); - auto* mom1_out = ctx.Output("Moment1Out"); - auto* mom2_out = ctx.Output("Moment2Out"); - auto* beta1_pow_out = ctx.Output("Beta1PowOut"); - auto* beta2_pow_out = ctx.Output("Beta2PowOut"); + auto* param_out = ctx.Output("ParamOut"); + auto* mom1_out = ctx.Output("Moment1Out"); + auto* mom2_out = ctx.Output("Moment2Out"); + auto* beta1_pow_out = ctx.Output("Beta1PowOut"); + auto* beta2_pow_out = ctx.Output("Beta2PowOut"); bool skip_update = false; if (ctx.HasInput("SkipUpdate")) { @@ -114,8 +113,8 @@ class AdamNPUKernel : public framework::OpKernel { // NOTE(zhiqiu): beta1_pow and beta2_pow may on CPU and not transform // place. - LoDTensor beta1_pow_tmp; - LoDTensor beta2_pow_tmp; + phi::DenseTensor beta1_pow_tmp; + phi::DenseTensor beta2_pow_tmp; if (beta1_pow->place() == platform::CPUPlace()) { T beta1 = *beta1_pow->data(); beta1_pow_tmp.mutable_data({1}, ctx.GetPlace()); @@ -279,7 +278,7 @@ class AdamWNPUKernel : public AdamNPUKernel { bool with_decay = ctx.Attr("with_decay"); if (!skip_update && with_decay) { float coeff = ctx.Attr("coeff"); - auto* lr = ctx.Input("LearningRate"); + auto* lr = ctx.Input("LearningRate"); auto place = ctx.GetPlace(); @@ -308,18 +307,18 @@ class AdamWNPUKernel : public AdamNPUKernel { PADDLE_THROW(platform::errors::Unimplemented( "Master Parma is not supported on npu")); } else { - auto* param_out = ctx.Output("ParamOut"); + auto* param_out = ctx.Output("ParamOut"); param_out->mutable_data(ctx.GetPlace()); const auto* param_var = ctx.InputVar("Param"); PADDLE_ENFORCE_EQ(param_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Param").front(), framework::ToTypeName(param_var->Type()))); - auto* param = ctx.Input("Param"); + auto* param = ctx.Input("Param"); const auto& runner = NpuOpRunner("Mul", diff --git a/paddle/fluid/operators/optimizers/decayed_adagrad_op.cc b/paddle/fluid/operators/optimizers/decayed_adagrad_op.cc index 94a52d9765bfa966e58e508e74313ec8b25371a1..5ab3ef3b2e61c712fc31c7d2d15d22e9e67b4797 100644 --- a/paddle/fluid/operators/optimizers/decayed_adagrad_op.cc +++ b/paddle/fluid/operators/optimizers/decayed_adagrad_op.cc @@ -32,20 +32,20 @@ class DecayedAdagradOp : public framework::OperatorWithKernel { "Input", "LearningRate", "DecayedAdagradOp"); - PADDLE_ENFORCE_EQ( - ctx->GetInputsVarType("Param").front(), - framework::proto::VarType::LOD_TENSOR, - platform::errors::InvalidArgument( - "The input var's type should be LoDTensor, but the received is %s", - ctx->Inputs("Param").front(), - ctx->GetInputsVarType("Param").front())); - PADDLE_ENFORCE_EQ( - ctx->GetInputsVarType("Grad").front(), - framework::proto::VarType::LOD_TENSOR, - platform::errors::InvalidArgument( - "The input var's type should be LoDTensor, but the received is %s", - ctx->Inputs("Grad").front(), - ctx->GetInputsVarType("Grad").front())); + PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Param").front(), + framework::proto::VarType::LOD_TENSOR, + platform::errors::InvalidArgument( + "The input var's type should be phi::DenseTensor, " + "but the received is %s", + ctx->Inputs("Param").front(), + ctx->GetInputsVarType("Param").front())); + PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Grad").front(), + framework::proto::VarType::LOD_TENSOR, + platform::errors::InvalidArgument( + "The input var's type should be phi::DenseTensor, " + "but the received is %s", + ctx->Inputs("Grad").front(), + ctx->GetInputsVarType("Grad").front())); OP_INOUT_CHECK( ctx->HasOutput("ParamOut"), "Output", "ParamOut", "DecayedAdagradOp"); diff --git a/paddle/fluid/operators/optimizers/decayed_adagrad_op.h b/paddle/fluid/operators/optimizers/decayed_adagrad_op.h index 8c5c6a3f4457fe378836bd6f9691beb456c9502d..e5925866b834139823e848152e767b19a895b647 100644 --- a/paddle/fluid/operators/optimizers/decayed_adagrad_op.h +++ b/paddle/fluid/operators/optimizers/decayed_adagrad_op.h @@ -27,7 +27,7 @@ class DecayedAdagradOpKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(param_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Param").front(), framework::ToTypeName(param_var->Type()))); @@ -35,7 +35,7 @@ class DecayedAdagradOpKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(grad_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Grad").front(), framework::ToTypeName(grad_var->Type()))); diff --git a/paddle/fluid/operators/optimizers/dpsgd_op.cc b/paddle/fluid/operators/optimizers/dpsgd_op.cc index 9d522031acf6c82e23f5cf851b53617a5669f3fe..e866a97f1ddccb3e4e699d1bfea450abe24df7ab 100644 --- a/paddle/fluid/operators/optimizers/dpsgd_op.cc +++ b/paddle/fluid/operators/optimizers/dpsgd_op.cc @@ -36,18 +36,18 @@ class DpsgdOp : public framework::OperatorWithKernel { true, platform::errors::NotFound( "Input(LearningRate) of DpsgdOp should not be null.")); - PADDLE_ENFORCE_EQ( - ctx->GetInputsVarType("Param").front(), - framework::proto::VarType::LOD_TENSOR, - platform::errors::InvalidArgument( - "The input var's type should be LoDTensor, but the received is %s", - ctx->GetInputsVarType("Param").front())); - PADDLE_ENFORCE_EQ( - ctx->GetInputsVarType("Grad").front(), - framework::proto::VarType::LOD_TENSOR, - platform::errors::InvalidArgument( - "The input var's type should be LoDTensor, but the received is %s", - ctx->GetInputsVarType("Grad").front())); + PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Param").front(), + framework::proto::VarType::LOD_TENSOR, + platform::errors::InvalidArgument( + "The input var's type should be phi::DenseTensor, " + "but the received is %s", + ctx->GetInputsVarType("Param").front())); + PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Grad").front(), + framework::proto::VarType::LOD_TENSOR, + platform::errors::InvalidArgument( + "The input var's type should be phi::DenseTensor, " + "but the received is %s", + ctx->GetInputsVarType("Grad").front())); PADDLE_ENFORCE_EQ(ctx->HasOutput("ParamOut"), true, diff --git a/paddle/fluid/operators/optimizers/dpsgd_op.h b/paddle/fluid/operators/optimizers/dpsgd_op.h index 0d89ca2b6a752d7a8039143b914e8a3c0d18f211..d6ee84f4b7b632a5aa86e0a1a8ef84ef36b7018f 100644 --- a/paddle/fluid/operators/optimizers/dpsgd_op.h +++ b/paddle/fluid/operators/optimizers/dpsgd_op.h @@ -32,7 +32,7 @@ class DpsgdOpKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(param_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Param").front(), framework::ToTypeName(param_var->Type()))); @@ -41,7 +41,7 @@ class DpsgdOpKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(grad_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Grad").front(), framework::ToTypeName(grad_var->Type()))); diff --git a/paddle/fluid/operators/optimizers/lamb_op.cc b/paddle/fluid/operators/optimizers/lamb_op.cc index 3e2ee495b058605ce7019375ae95867deba4fe36..df55ffa116a2fc1a587f243806b1e4e6bdf01dc8 100644 --- a/paddle/fluid/operators/optimizers/lamb_op.cc +++ b/paddle/fluid/operators/optimizers/lamb_op.cc @@ -52,10 +52,10 @@ class LambOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("Param", - "(LoDTensor, default LoDTensor) " + "(phi::DenseTensor, default phi::DenseTensor) " "Input parameter that has to be updated."); AddInput("Grad", - "(LoDTensor, default LoDTensor) " + "(phi::DenseTensor, default phi::DenseTensor) " "Input gradient of the parameter."); AddInput("LearningRate", "(Tensor) Learning rate."); AddInput("Moment1", "(Tensor) Input first moment."); @@ -63,7 +63,7 @@ class LambOpMaker : public framework::OpProtoAndCheckerMaker { AddInput("Beta1Pow", "(Tensor) Input beta1 power accumulator."); AddInput("Beta2Pow", "(Tensor) Input beta2 power accumulator."); AddInput("MasterParam", - "(LoDTensor, default LoDTensor) " + "(phi::DenseTensor, default phi::DenseTensor) " "Input master parameter that has to be updated.") .AsDispensable(); AddInput( diff --git a/paddle/fluid/operators/optimizers/lars_momentum_op.cc b/paddle/fluid/operators/optimizers/lars_momentum_op.cc index 30e08779f51b0392c0fb22d4023a664fe0013496..a5c641cc70a0a629a655adaa27c4265251ccf6de 100644 --- a/paddle/fluid/operators/optimizers/lars_momentum_op.cc +++ b/paddle/fluid/operators/optimizers/lars_momentum_op.cc @@ -37,12 +37,12 @@ class LarsMomentumOp : public framework::OperatorWithKernel { "Output", "VelocityOut", "LarsMomentum"); - PADDLE_ENFORCE_EQ( - ctx->GetInputsVarType("Param").front(), - framework::proto::VarType::LOD_TENSOR, - platform::errors::InvalidArgument( - "The input var's type should be LoDTensor, but the received is %s", - ctx->GetInputsVarType("Param").front())); + PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Param").front(), + framework::proto::VarType::LOD_TENSOR, + platform::errors::InvalidArgument( + "The input var's type should be phi::DenseTensor, " + "but the received is %s", + ctx->GetInputsVarType("Param").front())); auto lr_dims = ctx->GetInputsDim("LearningRate"); auto grad_dim = ctx->GetInputsDim("Grad"); @@ -102,7 +102,7 @@ class LarsMomentumOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Grad")[i], framework::proto::VarType::LOD_TENSOR, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx->Inputs("Grad")[i].front(), ctx->GetInputsVarType("Grad")[i])); @@ -145,31 +145,31 @@ class LarsMomentumOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("Param", - "(LoDTensor, default LoDTensor) " + "(phi::DenseTensor, default phi::DenseTensor) " "Input parameter that has to be updated") .AsDuplicable(); AddInput("Grad", - "(LoDTensor, default LoDTensor) " + "(phi::DenseTensor, default phi::DenseTensor) " "Input gradient of the parameter") .AsDuplicable(); AddInput("Velocity", - "(LoDTensor, default LoDTensor) " + "(phi::DenseTensor, default phi::DenseTensor) " "Input velocity (corresponding to the parameter) " "that has to be updated") .AsDuplicable(); AddInput("LearningRate", - "(LoDTensor, default LoDTensor) " + "(phi::DenseTensor, default phi::DenseTensor) " "Input learning rate") .AsDuplicable(); AddInput("MasterParam", "FP32 master weight for AMP.") .AsDuplicable() .AsDispensable(); AddOutput("ParamOut", - "(LoDTensor) This output is updated parameter. " + "(phi::DenseTensor) This output is updated parameter. " "It shared memory with Input(Param).") .AsDuplicable(); AddOutput("VelocityOut", - "(LoDTensor) This output is updated velocity. " + "(phi::DenseTensor) This output is updated velocity. " "It shared memory with Input(Velocity).") .AsDuplicable(); AddOutput("MasterParamOut", diff --git a/paddle/fluid/operators/optimizers/momentum_op.h b/paddle/fluid/operators/optimizers/momentum_op.h index 847601777ebbc31002c8b224e1c823fb09d854ec..ad1ae550745dd25a928425a0bfc9b74976c002fc 100644 --- a/paddle/fluid/operators/optimizers/momentum_op.h +++ b/paddle/fluid/operators/optimizers/momentum_op.h @@ -54,12 +54,12 @@ class MomentumOp : public framework::OperatorWithKernel { true, platform::errors::NotFound( "Input(LearningRate) of Momentum should not be null.")); - PADDLE_ENFORCE_EQ( - ctx->GetInputsVarType("Param").front(), - framework::proto::VarType::LOD_TENSOR, - platform::errors::InvalidArgument( - "The input var's type should be LoDTensor, but the received is %s", - ctx->GetInputsVarType("Param").front())); + PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Param").front(), + framework::proto::VarType::LOD_TENSOR, + platform::errors::InvalidArgument( + "The input var's type should be phi::DenseTensor, " + "but the received is %s", + ctx->GetInputsVarType("Param").front())); PADDLE_ENFORCE_EQ(ctx->HasOutput("ParamOut"), true, diff --git a/paddle/fluid/operators/optimizers/rmsprop_op_npu.cc b/paddle/fluid/operators/optimizers/rmsprop_op_npu.cc index e285dc6d202d54576f22e77708baf8bff7e2bb52..579bc76be5f4746f750835d7eb24cfd5d4f8638b 100644 --- a/paddle/fluid/operators/optimizers/rmsprop_op_npu.cc +++ b/paddle/fluid/operators/optimizers/rmsprop_op_npu.cc @@ -16,16 +16,15 @@ namespace paddle { namespace operators { using Tensor = phi::DenseTensor; -using LoDTensor = phi::DenseTensor; template class RMSPROPNPUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &ctx) const override { auto *grad_var = ctx.InputVar("Grad"); - auto *param_out = ctx.Output("ParamOut"); - auto *moment_out = ctx.Output("MomentOut"); - auto *mean_square_out = ctx.Output("MeanSquareOut"); + auto *param_out = ctx.Output("ParamOut"); + auto *moment_out = ctx.Output("MomentOut"); + auto *mean_square_out = ctx.Output("MeanSquareOut"); param_out->mutable_data(ctx.GetPlace()); moment_out->mutable_data(ctx.GetPlace()); @@ -34,17 +33,17 @@ class RMSPROPNPUKernel : public framework::OpKernel { auto epsilon = static_cast(ctx.Attr("epsilon")); auto rho = static_cast(ctx.Attr("decay")); auto momentum = static_cast(ctx.Attr("momentum")); - auto *p_tensor = ctx.Input("Param"); - auto *ms_tensor = ctx.Input("MeanSquare"); - auto *lr_tensor = ctx.Input("LearningRate"); - auto *mom_tensor = ctx.Input("Moment"); + auto *p_tensor = ctx.Input("Param"); + auto *ms_tensor = ctx.Input("MeanSquare"); + auto *lr_tensor = ctx.Input("LearningRate"); + auto *mom_tensor = ctx.Input("Moment"); bool centered = ctx.Attr("centered"); auto stream = ctx.template device_context() .stream(); - if (grad_var->IsType()) { - auto *grad_tensor = ctx.Input("Grad"); + if (grad_var->IsType()) { + auto *grad_tensor = ctx.Input("Grad"); if (centered) { framework::NPUAttributeMap attr_input = {{"use_locking", false}}; const Tensor *rho_tensor = nullptr; diff --git a/paddle/fluid/operators/optimizers/sgd_op.cu b/paddle/fluid/operators/optimizers/sgd_op.cu index 385e9a70e5489b5fb18dbd8b29891ab340b6ceec..79cce5abdb03fb9f7c0a8ea154c69a2619861c17 100644 --- a/paddle/fluid/operators/optimizers/sgd_op.cu +++ b/paddle/fluid/operators/optimizers/sgd_op.cu @@ -72,7 +72,7 @@ class SGDOpKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ(param_var->IsType(), true, platform::errors::InvalidArgument( - "The Var(%s)'s type should be LoDTensor, " + "The Var(%s)'s type should be phi::DenseTensor, " "but the received is %s", ctx.InputNames("Param").front(), paddle::framework::ToTypeName(param_var->Type()))); @@ -107,7 +107,7 @@ class SGDOpKernel : public framework::OpKernel { ? master_param_out->mutable_data(ctx.GetPlace()) : nullptr; - // Actually, all tensors are LoDTensor except SelectedRows. + // Actually, all tensors are phi::DenseTensor except SelectedRows. if (grad_var->IsType()) { auto* grad = ctx.Input("Grad"); diff --git a/paddle/fluid/operators/optimizers/sgd_op.h b/paddle/fluid/operators/optimizers/sgd_op.h index e3a2e6e17e97d7eaa8991549b5d8b5e02562bb2c..ffdf1898f582911e54a1034c2d238e83b51d5dca 100644 --- a/paddle/fluid/operators/optimizers/sgd_op.h +++ b/paddle/fluid/operators/optimizers/sgd_op.h @@ -36,7 +36,7 @@ template struct sgd_dense_param_kernel::kId> { void operator()(const framework::ExecutionContext &ctx) const { - VLOG(4) << "[CPU]: sgd_dense_param_kernel"; + VLOG(4) << "[CPU]: sgd_dense_param_kernel"; const auto *learning_rate = ctx.Input("LearningRate"); const auto *param = ctx.Input("Param"); auto *param_out = ctx.Output("ParamOut"); @@ -95,7 +95,7 @@ template <> struct sgd_dense_param_kernel::kId> { void operator()(const framework::ExecutionContext &ctx) const { - VLOG(4) << "[CPU]: sgd_dense_param_kernel"; + VLOG(4) << "[CPU]: sgd_dense_param_kernel"; const auto *learning_rate = ctx.Input("LearningRate"); const auto *param = ctx.Input("Param"); auto *param_out = ctx.Output("ParamOut"); diff --git a/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc b/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc index dbdf58637580db178cf99a2bee3c0be0faa14ba3..046269a396ee0c1aadeda1621a7d57fa6194a497 100644 --- a/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc +++ b/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc @@ -90,7 +90,7 @@ class DistributedLookupTableOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("Ids", - "(LoDTensor) Ids's type should be LoDTensor" + "(phi::DenseTensor) Ids's type should be phi::DenseTensor" "THe ids to be looked up in W.") .AsDuplicable(); @@ -98,8 +98,9 @@ class DistributedLookupTableOpMaker : public framework::OpProtoAndCheckerMaker { "(Tensor) The input represents embedding tensors, " "which is a learnable parameter."); - AddOutput("Outputs", - "(LoDTensor) The lookup results, which have the same type as W.") + AddOutput( + "Outputs", + "(phi::DenseTensor) The lookup results, which have the same type as W.") .AsDuplicable(); AddAttr("table_id", "sparse table id").SetDefault(0); diff --git a/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc b/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc index a2bf63da10bd2ff85ab2347b6999c13e956789d1..97391bc0e8b9de1416f19940a33129767bd74d93 100644 --- a/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc +++ b/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc @@ -63,22 +63,23 @@ class DistributedPushSparseOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("Ids", - "(LoDTensor) Ids's type should be LoDTensor" + "(phi::DenseTensor) Ids's type should be phi::DenseTensor" "THe ids to be looked up in W.") .AsDuplicable(); AddInput("Shows", - "(LoDTensor) Shows's type should be LoDTensor" + "(phi::DenseTensor) Shows's type should be phi::DenseTensor" "THe shows default to be 1.") .AsDuplicable(); AddInput("Clicks", - "(LoDTensor) Clicks's type should be LoDTensor" + "(phi::DenseTensor) Clicks's type should be phi::DenseTensor" "THe clicks usually equal to label.") .AsDuplicable(); - AddOutput("Outputs", - "(LoDTensor) The lookup results, which have the same type as W.") + AddOutput( + "Outputs", + "(phi::DenseTensor) The lookup results, which have the same type as W.") .AsDuplicable(); AddAttr("table_id", "sparse table id").SetDefault(0); diff --git a/paddle/fluid/operators/pscore/fake_init_op.cc b/paddle/fluid/operators/pscore/fake_init_op.cc index b59f5fd0306bce495a75fecc13578410953dda27..cefd0ee5855f2b3617ad9045d1a1c2e500816be1 100644 --- a/paddle/fluid/operators/pscore/fake_init_op.cc +++ b/paddle/fluid/operators/pscore/fake_init_op.cc @@ -45,7 +45,7 @@ class FakeInitOp : public framework::OperatorBase { } else { PADDLE_THROW(platform::errors::InvalidArgument( "fake init op's output only" - "supports SelectedRows and LoDTensor")); + "supports SelectedRows and phi::DenseTensor")); } } }; diff --git a/paddle/fluid/operators/reader/create_py_reader_op.cc b/paddle/fluid/operators/reader/create_py_reader_op.cc index 718298112fc9c586bdf17bdf0ecea0c2de21899a..1e6ef050ae1360aa7c74c3ec6a9f36ae4f09d0d4 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 LoDTensor data feeding in Python side. + Create PyReader to support phi::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 ac8c4362f1a327dc728317ac8e6ed1c8b26607c5..1c65669adc3a9b5bfc294c298408510e980ebc42 100644 --- a/paddle/fluid/operators/reader/read_op.cc +++ b/paddle/fluid/operators/reader/read_op.cc @@ -171,7 +171,7 @@ class ReadOpMaker : public framework::OpProtoAndCheckerMaker { public: void Make() override { AddInput("Reader", "(ReaderHolder) The executed reader."); - AddOutput("Out", "(LoDTensor) The output data.").AsDuplicable(); + AddOutput("Out", "(phi::DenseTensor) The output data.").AsDuplicable(); AddAttr( "throw_eof_exp", "If set true, an exception will be thrown when the Reader "