Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <functional>
#include <memory>
#include <optional>
#include <random>
#include "paddle/cinn/hlir/dialect/operator/transforms/check_infer_symbolic_pass.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/local_infer_symbolic_util.h"
#include "paddle/cinn/hlir/dialect/operator/transforms/split_generate_shape_into_shape_ops_pass.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "paddle/common/errors.h"
#include "paddle/common/flags.h"
#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/fluid/framework/new_executor/new_executor_defs.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/phi/core/memory/allocation/spin_lock.h"
#include "paddle/phi/core/platform/device_event.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <memory>
#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/phi/core/ddim.h"

namespace pir {
class Operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/fluid/framework/new_executor/interpreter/execution_config.h"
#include "paddle/fluid/framework/new_executor/new_executor_defs.h"

namespace ir {
class Operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/fluid/framework/new_executor/interpreter/execution_config.h"
#include "paddle/fluid/framework/new_executor/new_executor_defs.h"

namespace ir {
class Operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <unordered_map>
#include <vector>

#include "paddle/fluid/framework/new_executor/new_executor_defs.h"
#include "paddle/fluid/framework/new_executor/instruction/instruction_defs.h"
#include "paddle/phi/api/profiler/event.h"

namespace pir {
Expand All @@ -29,8 +29,8 @@ class Value;
namespace paddle {
namespace framework {
class ValueExecutionInfo;

using SchedulingPriority = int64_t;
class Variable;
class Scope;

class InstructionBase {
public:
Expand Down
52 changes: 52 additions & 0 deletions paddle/fluid/framework/new_executor/instruction/instruction_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2021 -> 2025

//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once

#include <unordered_set>
#include "paddle/phi/core/platform/device_event_base.h"
#include "paddle/pir/include/core/operation.h"

namespace paddle {
namespace framework {

using SchedulingPriority = int64_t;

constexpr const char* kCoalesceTensor = "coalesce_tensor";

// stream types
constexpr const char* kCustomStream = "CustomStream";
constexpr const char* kDefaultStream = "DefaultStream";
constexpr const char* kD2HStream = "D2HStream";
constexpr const char* kH2DStream = "H2DStream";

constexpr int kEmptyVarIndex = 0;

struct EventInter {
explicit EventInter(size_t instr_id,
std::shared_ptr<platform::DeviceEvent> event,
platform::DeviceType waiter_type)
: instr_id_(instr_id), event_(event), waiter_type_(waiter_type) {}
size_t instr_id_;
std::shared_ptr<platform::DeviceEvent> event_;
platform::DeviceType waiter_type_;
};

enum class OpFuncType {
kCpuSync, // CPU kernel, block host
kGpuSync, // GPU or other device kernel without asynchronous operation
kGpuAsync // GPU or other device kernel with asynchronous operation
};

} // namespace framework
} // namespace paddle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/fluid/framework/new_executor/new_executor_defs.h"

namespace pir {
class Operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/fluid/framework/new_executor/new_executor_defs.h"

namespace pir {
class Operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/fluid/framework/new_executor/new_executor_defs.h"

namespace pir {
class Operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "paddle/fluid/framework/new_executor/instruction/instruction_base.h"
#include "paddle/fluid/framework/new_executor/new_executor_defs.h"

namespace pir {
class Operation;
Expand Down
29 changes: 1 addition & 28 deletions paddle/fluid/framework/new_executor/new_executor_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <vector>

#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/new_executor/instruction/instruction_defs.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/variable_helper.h"
#include "paddle/fluid/pir/dialect/operator/interface/infermeta.h"
Expand Down Expand Up @@ -48,18 +49,6 @@ using HookFunc = std::function<void(OperatorBase*, Scope*)>;
using PirHookFunc =
std::function<void(InstructionBase*, ValueExecutionInfo*, Scope*)>;

using SchedulingPriority = int64_t;

constexpr const char* kCoalesceTensor = "coalesce_tensor";

// stream types
constexpr const char* kCustomStream = "CustomStream";
constexpr const char* kDefaultStream = "DefaultStream";
constexpr const char* kD2HStream = "D2HStream";
constexpr const char* kH2DStream = "H2DStream";

constexpr int kEmptyVarIndex = 0;

struct OpKernelFunc {
OpKernelComputeFunc compute_func_;
};
Expand Down Expand Up @@ -152,22 +141,6 @@ class VariableScope {
std::vector<std::pair<std::string, int>> data_transfer_added_vars_;
};

struct EventInter {
explicit EventInter(size_t instr_id,
std::shared_ptr<platform::DeviceEvent> event,
platform::DeviceType waiter_type)
: instr_id_(instr_id), event_(event), waiter_type_(waiter_type) {}
size_t instr_id_;
std::shared_ptr<platform::DeviceEvent> event_;
platform::DeviceType waiter_type_;
};

enum class OpFuncType {
kCpuSync, // CPU kernel, block host
kGpuSync, // GPU or other device kernel without asynchronous operation
kGpuAsync // GPU or other device kernel with asynchronous operation
};

struct OpFuncNode {
int stream_priority_{0}; // lower value, higher priority
// fit for phi kernel
Expand Down
45 changes: 45 additions & 0 deletions paddle/fluid/ir_adaptor/translator/pd_op_sig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2023 -> 2025

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些文件是移动,不是新建,所以没改创建日期

//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <string>
#include <vector>

namespace paddle {
namespace dialect {
struct PdOpSig {
std::string name;
std::vector<std::string> inputs;
std::vector<std::string> outputs;
PdOpSig() = default;
PdOpSig(const PdOpSig& input_info) = default;

PdOpSig(const std::string& name,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs)
: name(name), inputs(inputs), outputs(outputs) {}
};

bool HaveOpToMultiKernelsMap(std::string op_name);

const std::vector<PdOpSig>& LegacyOpToPdOpsMapping(std::string op_name);
const std::vector<PdOpSig>& SparseOpToPdOpsMapping(std::string op_name);

#ifdef PADDLE_WITH_DNNL
bool IsOneDNNOnlyOp(std::string op_name);
#endif

} // namespace dialect
} // namespace paddle
28 changes: 1 addition & 27 deletions paddle/fluid/ir_adaptor/translator/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,12 @@

#include "paddle/fluid/framework/data_type.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/ir_adaptor/translator/pd_op_sig.h"
#include "paddle/fluid/ir_adaptor/translator/program_translator.h"
#include "paddle/pir/include/core/ir_context.h"
#include "paddle/pir/include/core/operation.h"
#include "paddle/pir/include/core/program.h"

namespace paddle {
namespace dialect {
struct PdOpSig {
std::string name;
std::vector<std::string> inputs;
std::vector<std::string> outputs;
PdOpSig() = default;
PdOpSig(const PdOpSig& input_info) = default;

PdOpSig(const std::string& name,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs)
: name(name), inputs(inputs), outputs(outputs) {}
};

bool HaveOpToMultiKernelsMap(std::string op_name);

const std::vector<PdOpSig>& LegacyOpToPdOpsMapping(std::string op_name);
const std::vector<PdOpSig>& SparseOpToPdOpsMapping(std::string op_name);

#ifdef PADDLE_WITH_DNNL
bool IsOneDNNOnlyOp(std::string op_name);
#endif

} // namespace dialect
} // namespace paddle

namespace paddle {
namespace translator {

Expand Down
3 changes: 1 addition & 2 deletions paddle/fluid/pir/dialect/op_generator/op_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@
#ifdef PADDLE_WITH_DNNL
#include "paddle/fluid/pir/dialect/operator/trait/onednn.h"
#endif
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/ir_adaptor/translator/utils.h"
#include "paddle/fluid/ir_adaptor/translator/pd_op_sig.h"
#include "paddle/fluid/pir/dialect/operator/ir/manual_op.h"
#include "paddle/fluid/pir/dialect/operator/trait/custom_vjp.h"
#include "paddle/phi/core/infermeta_utils.h"
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pir/dialect/op_generator/op_kerneltype_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

OP_COMPLEX_PROMOTE_CHECK_TEMPLATE = """
// deal complex_promote
if (framework::IsComplexType(expected_kernel_dtype)) {{
if (phi::IsComplexType(expected_kernel_dtype)) {{
// only promote inputs’s types when contains complex input
return tensor_dtype;
}}
Expand Down
1 change: 0 additions & 1 deletion paddle/fluid/pir/dialect/operator/ir/manual_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#pragma once
#include <vector>

#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/pir/dialect/operator/interface/decomp.h"
#include "paddle/fluid/pir/dialect/operator/interface/get_kernel_type_for_var.h"
#include "paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/infer_symbolic_shape.h"
Expand Down
3 changes: 3 additions & 0 deletions paddle/fluid/pir/transforms/gpu/conv2d_add_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include "paddle/fluid/pir/dialect/operator/ir/op_attribute.h"
#include "paddle/fluid/pir/dialect/operator/ir/pd_op.h"
#include "paddle/fluid/pir/drr/include/drr_pattern_base.h"
#ifdef PADDLE_WITH_CUDA
#include "paddle/phi/core/platform/device/gpu/gpu_info.h"
#endif

#include "paddle/fluid/pir/utils/general_functions.h"
#include "paddle/pir/include/pass/pass.h"
Expand Down
3 changes: 3 additions & 0 deletions paddle/fluid/pir/transforms/gpu/fused_flash_attn_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "paddle/fluid/pir/dialect/operator/ir/pd_op.h"
#include "paddle/fluid/pir/drr/include/drr_pattern_base.h"
#include "paddle/fluid/pir/utils/general_functions.h"
#ifdef PADDLE_WITH_CUDA
#include "paddle/phi/core/platform/device/gpu/gpu_info.h"
#endif

#include "paddle/pir/include/pass/pass.h"
#include "paddle/pir/include/pass/pass_registry.h"
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/pir/transforms/sub_graph_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <memory>

#include <climits>
#include <iterator>
#include <queue>
#include <regex>
Expand Down
2 changes: 2 additions & 0 deletions paddle/fluid/pir/transforms/xpu/conv2d_bn_xpu_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

#include "paddle/fluid/pir/transforms/xpu/conv2d_bn_xpu_fuse_pass.h"
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/ir_adaptor/translator/utils.h"
#include "paddle/fluid/pir/dialect/operator/ir/pd_op.h"
#include "paddle/fluid/pir/drr/include/drr_pattern_base.h"
#include "paddle/fluid/pir/utils/general_functions.h"
Expand Down
4 changes: 2 additions & 2 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ headers = (
list(find_files('token.h','@PADDLE_SOURCE_DIR@/paddle/pir/src/core/parser/'))+
#pir ops and dependency
list(find_files('pd_op.h','@PADDLE_BINARY_DIR@/paddle/fluid/pir/dialect/operator/ir/'))+
list(find_files('utils.h','@PADDLE_SOURCE_DIR@/paddle/fluid/ir_adaptor/translator/'))+
list(find_files('utils_defs.h','@PADDLE_SOURCE_DIR@/paddle/fluid/ir_adaptor/translator/'))+
list(find_files('*.h','@PADDLE_SOURCE_DIR@/paddle/fluid/pir/dialect/operator/interface/'))+
list(find_files('*.hpp','@PADDLE_SOURCE_DIR@/paddle/fluid/pir/dialect/operator/interface/'))+
list(find_files('*.h','@PADDLE_SOURCE_DIR@/paddle/fluid/pir/dialect/operator/trait/'))+
Expand All @@ -1187,7 +1187,7 @@ headers = (
#new_executor headers
list(find_files('pir_adaptor_util.h','@PADDLE_SOURCE_DIR@/paddle/fluid/framework/new_executor/pir_adaptor/'))+
list(find_files('custom_engine_instruction.h','@PADDLE_SOURCE_DIR@/paddle/fluid/framework/new_executor/instruction/'))+
list(find_files('new_executor_defs.h','@PADDLE_SOURCE_DIR@/paddle/fluid/framework/new_executor/'))+
list(find_files('instruction_defs.h','@PADDLE_SOURCE_DIR@/paddle/fluid/framework/new_executor/'))+
list(find_files('instruction_base.h','@PADDLE_SOURCE_DIR@/paddle/fluid/framework/new_executor/instruction/')))
jit_layer_headers = ['layer.h', 'serializer.h', 'serializer_utils.h', 'all.h', 'function.h']
for f in jit_layer_headers:
Expand Down