Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
Browse files Browse the repository at this point in the history
… merge_dev
  • Loading branch information
zyfncg committed Sep 6, 2023
2 parents ede8fff + 3eafa1f commit cf62d06
Show file tree
Hide file tree
Showing 41 changed files with 1,414 additions and 95 deletions.
4 changes: 0 additions & 4 deletions cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ if(WITH_DISTRIBUTE)
add_definitions(-DPADDLE_WITH_DISTRIBUTE)
endif()

if(WITH_GFLAGS)
add_definitions(-DPADDLE_WITH_GFLAGS)
endif()

if(WITH_PSCORE)
add_definitions(-DPADDLE_WITH_PSCORE)
endif()
Expand Down
1 change: 1 addition & 0 deletions cmake/external/gflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ endif()
set(flags_dep)
if(WITH_GFLAGS)
list(APPEND flags_dep gflags)
add_definitions(-DPADDLE_WITH_GFLAGS)
else()
list(APPEND flags_dep paddle_flags)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ void analyse_event_info_for_two_instructions<Instruction>(

if (has_data_dependency<Instruction, std::string>(
instructions[cur_instr_id], instructions[next_instr_id]) ||
!run_type_info[next_instr_id][DownstreamRunType::kEventRun].empty() ||
instructions[next_instr_id]->OpBase()->Type() == "depend") {
waiter_instr_ids->insert(next_instr_id);
return;
Expand Down Expand Up @@ -474,7 +473,6 @@ void analyse_event_info_for_two_instructions<

if (has_data_dependency<paddle::framework::InstructionBase, ir::Value>(
instructions[cur_instr_id], instructions[next_instr_id]) ||
!run_type_info[next_instr_id][DownstreamRunType::kEventRun].empty() ||
instructions[next_instr_id]->Name() == "pd.depend") {
waiter_instr_ids->insert(next_instr_id);
return;
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/framework/type_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License. */
#include "paddle/fluid/framework/feed_fetch_type.h"
#include "paddle/fluid/framework/raw_tensor.h"
#include "paddle/fluid/framework/string_array.h"
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_meta_tensor.h"
#include "paddle/fluid/prim/utils/static/desc_tensor.h"
#include "paddle/fluid/primitive/type/lazy_tensor.h"

Expand Down Expand Up @@ -44,5 +45,6 @@ template class TypeInfoTraits<phi::TensorBase, paddle::prim::DescTensor>;
template class TypeInfoTraits<phi::TensorBase, paddle::primitive::LazyTensor>;
template class TypeInfoTraits<phi::TensorBase,
paddle::framework::VariableRefArray>;
template class TypeInfoTraits<phi::TensorBase, paddle::dialect::IrMetaTensor>;

} // namespace phi
24 changes: 11 additions & 13 deletions paddle/fluid/ir/dialect/op_generator/op_build_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,27 +286,25 @@ def GenBuildOutputs(
build_output_str = ' VLOG(4) << "Builder construction outputs";\n'
CREATE_INPUT_METATENSOR_TEMPLATE = """
VLOG(4) << "Builder construction dense_{name}";
phi::DenseTensor dense_{name}(std::make_unique<paddle::experimental::DefaultAllocator>(paddle::platform::CPUPlace()).get(),
phi::DenseTensorMeta(paddle::dialect::TransToPhiDataType({name}.dtype()),
{name}.dims(),
{name}.data_layout(),
{name}.lod(),
{name}.offset()));
paddle::dialect::IrMetaTensor ir_meta_tensor_{name}(paddle::dialect::TransToPhiDataType({name}.dtype()),
{name}.dims(),
{name}.data_layout(),
{name}.lod(),
{name}.offset());
VLOG(4) << "Builder construction meta_{name}";
phi::MetaTensor meta_{name}(&dense_{name});
phi::MetaTensor meta_{name}(&ir_meta_tensor_{name});
"""
CREATE_INPUT_VEC_METATENSOR_TEMPLATE = """ std::vector<phi::DenseTensor> vec_dense_{name};
CREATE_INPUT_VEC_METATENSOR_TEMPLATE = """ std::vector<paddle::dialect::IrMetaTensor> vec_ir_meta_tensor_{name};
for (size_t i=0; i < static_cast<size_t>({name}.size()); i++) {{
vec_dense_{name}.push_back(phi::DenseTensor(std::make_unique<paddle::experimental::DefaultAllocator>(paddle::platform::CPUPlace()).get(),
phi::DenseTensorMeta(paddle::dialect::TransToPhiDataType({name}[i].dyn_cast<paddle::dialect::DenseTensorType>().dtype()),
vec_ir_meta_tensor_{name}.push_back(paddle::dialect::IrMetaTensor(paddle::dialect::TransToPhiDataType({name}[i].dyn_cast<paddle::dialect::DenseTensorType>().dtype()),
{name}[i].dyn_cast<paddle::dialect::DenseTensorType>().dims(),
{name}[i].dyn_cast<paddle::dialect::DenseTensorType>().data_layout(),
{name}[i].dyn_cast<paddle::dialect::DenseTensorType>().lod(),
{name}[i].dyn_cast<paddle::dialect::DenseTensorType>().offset())));
{name}[i].dyn_cast<paddle::dialect::DenseTensorType>().offset()));
}}
std::vector<phi::MetaTensor> vec_meta_{name};
for (size_t i=0; i < vec_dense_{name}.size(); i++) {{
vec_meta_{name}.push_back(phi::MetaTensor(&vec_dense_{name}[i]));
for (size_t i=0; i < vec_ir_meta_tensor_{name}.size(); i++) {{
vec_meta_{name}.push_back(phi::MetaTensor(&vec_ir_meta_tensor_{name}[i]));
}}
std::vector<const phi::MetaTensor*> meta_{name};
Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/ir/dialect/op_generator/op_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class {op_name} : public ir::Op<{op_name}{interfaces}{traits}> {{
#include "{h_file}"
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_type.h"
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_attribute.h"
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_meta_tensor.h"
#include "paddle/ir/core/builtin_attribute.h"
#include "paddle/ir/core/builtin_type.h"
#include "paddle/ir/core/builtin_op.h"
Expand Down Expand Up @@ -172,7 +173,7 @@ class {op_name} : public ir::Op<{op_name}{interfaces}{traits}> {{
'bool': 'ir::BoolAttribute',
}

_NO_NEED_GEN_OPS = {'add_n', 'split_grad'}
_NO_NEED_GEN_OPS = {'add_n', 'add_n_', 'add_n_with_kernel', 'split_grad'}


def to_phi_and_fluid_op_name(op_item):
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/ir/dialect/paddle_dialect/ir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ add_custom_target(ops_api_gen ALL DEPENDS ${ops_api_source_file})

cc_library(
pd_dialect_core
SRCS pd_attribute.cc pd_type.cc
SRCS pd_attribute.cc pd_type.cc pd_meta_tensor.cc
DEPS phi pd_interface pd_trait type_info)
cc_library(
pd_dialect_op
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/ir/dialect/paddle_dialect/ir/pd_dialect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ void PaddleDialect::initialize() {
#include "paddle/fluid/ir/dialect/paddle_dialect/ir/pd_op.h" // NOLINT
>();
RegisterOps<paddle::dialect::AddNOp,
paddle::dialect::AddN_Op,
paddle::dialect::AddNWithKernelOp,
paddle::dialect::FusedGemmEpilogueOp,
paddle::dialect::FusedGemmEpilogueGradOp,
paddle::dialect::SplitGradOp>();
Expand Down
Loading

0 comments on commit cf62d06

Please sign in to comment.