未验证 提交 061bb9d5 编写于 作者: A Aurelius84 提交者: GitHub

[NewIR]Refine and Split CINN Dilact directory (#56805)

* [NewIR]Refine CINN Dilact directory

* fix conflict

* fix deps

* fix unittest deps
上级 fa75ebeb
# TODO(Aurelius84): new_ir_compiler depends on pd_dialect and could
# not found under CINN_ONLY mode
if(NOT CINN_ONLY)
set(CINN_DIALECT_SOURCE_DIR "${PADDLE_SOURCE_DIR}/paddle/cinn/hlir/dialect")
set(CINN_DIALECT_BINARY_DIR "${PADDLE_BINARY_DIR}/paddle/cinn/hlir/dialect")
# Generate cinn_dialect files defining op using op_gen_file
set(cinn_op_gen_parsed_yaml_file
${PADDLE_SOURCE_DIR}/paddle/fluid/operators/generator/parse_op.py)
set(cinn_op_gen_file
${PADDLE_SOURCE_DIR}/paddle/fluid/ir/dialect/op_generator/op_gen.py)
set(cinn_op_compat_yaml_file
${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/op_compat.yaml)
set(cinn_op_yaml_file
${PADDLE_SOURCE_DIR}/paddle/cinn/hlir/dialect/cinn_ops.yaml)
set(parsed_op_dir ${PADDLE_SOURCE_DIR}/paddle/cinn/hlir/dialect/generated)
set(cinn_op_parsed_yaml_file ${parsed_op_dir}/cinn_ops.parsed.yaml)
set(cinn_op_parsed_yaml_files ${cinn_op_parsed_yaml_file})
set(cinn_op_namespace cinn,dialect)
set(cinn_dialect_name cinn)
set(cinn_op_header_file ${CINN_DIALECT_BINARY_DIR}/cinn_op.h)
set(cinn_op_source_file ${CINN_DIALECT_BINARY_DIR}/cinn_op.cc)
set(cinn_op_header_file_tmp ${cinn_op_header_file}.tmp)
set(cinn_op_source_file_tmp ${cinn_op_source_file}.tmp)
add_custom_command(
OUTPUT ${cinn_op_parsed_yaml_file}
COMMAND ${CMAKE_COMMAND} -E make_directory ${parsed_op_dir}
COMMAND ${PYTHON_EXECUTABLE} ${cinn_op_gen_parsed_yaml_file} --op_yaml_path
${cinn_op_yaml_file} --output_path ${cinn_op_parsed_yaml_file}
VERBATIM)
add_custom_command(
OUTPUT ${cinn_op_header_file} ${cinn_op_source_file}
COMMAND
${PYTHON_EXECUTABLE} ${cinn_op_gen_file} --op_yaml_files
${cinn_op_parsed_yaml_files} --op_compat_yaml_file
${cinn_op_compat_yaml_file} --namespaces ${cinn_op_namespace}
--dialect_name ${cinn_dialect_name} --op_def_h_file
${cinn_op_header_file_tmp} --op_def_cc_file ${cinn_op_source_file_tmp}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${cinn_op_header_file_tmp}
${cinn_op_header_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${cinn_op_source_file_tmp}
${cinn_op_source_file}
DEPENDS ${cinn_op_gen_file} ${cinn_op_parsed_yaml_file}
${cinn_op_compat_yaml_file}
VERBATIM)
cinn_cc_library(
cinn_dialect
SRCS
runtime_dialect.cc
jit_kernel_op.cc
cinn_dialect.cc
cinn_op.cc
DEPS
pd_dialect)
target_include_directories(cinn_dialect PRIVATE ${CINN_DIALECT_BINARY_DIR})
endif()
add_subdirectory(cinn_dialect)
add_subdirectory(runtime_dialect)
# TODO(Aurelius84): new_ir_compiler depends on pd_dialect and could
# not found under CINN_ONLY mode
if(NOT CINN_ONLY)
set(CINN_DIALECT_BINARY_DIR
"${PADDLE_BINARY_DIR}/paddle/cinn/hlir/dialect/cinn_dialect/ir")
# Generate cinn_dialect files defining op using op_gen_file
set(cinn_op_gen_parsed_yaml_file
${PADDLE_SOURCE_DIR}/paddle/fluid/operators/generator/parse_op.py)
set(cinn_op_gen_file
${PADDLE_SOURCE_DIR}/paddle/fluid/ir/dialect/op_generator/op_gen.py)
set(cinn_op_compat_yaml_file
${PADDLE_SOURCE_DIR}/paddle/phi/api/yaml/op_compat.yaml)
set(cinn_op_yaml_file
${PADDLE_SOURCE_DIR}/paddle/cinn/hlir/dialect/cinn_dialect/ir/cinn_ops.yaml
)
set(parsed_op_dir ${PADDLE_SOURCE_DIR}/paddle/cinn/hlir/dialect/generated)
set(cinn_op_parsed_yaml_file ${parsed_op_dir}/cinn_ops.parsed.yaml)
set(cinn_op_parsed_yaml_files ${cinn_op_parsed_yaml_file})
set(cinn_op_namespace cinn,dialect)
set(cinn_dialect_name cinn)
set(cinn_op_header_file ${CINN_DIALECT_BINARY_DIR}/cinn_op.h)
set(cinn_op_source_file ${CINN_DIALECT_BINARY_DIR}/cinn_op.cc)
set(cinn_op_header_file_tmp ${cinn_op_header_file}.tmp)
set(cinn_op_source_file_tmp ${cinn_op_source_file}.tmp)
add_custom_command(
OUTPUT ${cinn_op_parsed_yaml_file}
COMMAND ${CMAKE_COMMAND} -E make_directory ${parsed_op_dir}
COMMAND ${PYTHON_EXECUTABLE} ${cinn_op_gen_parsed_yaml_file} --op_yaml_path
${cinn_op_yaml_file} --output_path ${cinn_op_parsed_yaml_file}
VERBATIM)
add_custom_command(
OUTPUT ${cinn_op_header_file} ${cinn_op_source_file}
COMMAND
${PYTHON_EXECUTABLE} ${cinn_op_gen_file} --op_yaml_files
${cinn_op_parsed_yaml_files} --op_compat_yaml_file
${cinn_op_compat_yaml_file} --namespaces ${cinn_op_namespace}
--dialect_name ${cinn_dialect_name} --op_def_h_file
${cinn_op_header_file_tmp} --op_def_cc_file ${cinn_op_source_file_tmp}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${cinn_op_header_file_tmp}
${cinn_op_header_file}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${cinn_op_source_file_tmp}
${cinn_op_source_file}
DEPENDS ${cinn_op_gen_file} ${cinn_op_parsed_yaml_file}
${cinn_op_compat_yaml_file}
VERBATIM)
cinn_cc_library(cinn_dialect SRCS cinn_dialect.cc ${cinn_op_source_file} DEPS
pd_dialect)
target_include_directories(cinn_dialect PRIVATE ${CINN_DIALECT_BINARY_DIR})
endif()
......@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/cinn/hlir/dialect/cinn_dialect.h"
#include "paddle/cinn/hlir/dialect/cinn_dialect/ir/cinn_dialect.h"
// NOTE(chenxi67): File cinn_op.h is generated by op_gen.py, see details in
// paddle/cinn/hlir/dialect/CMakeLists.txt.
#include "paddle/cinn/hlir/dialect/cinn_op.h"
#include "paddle/cinn/hlir/dialect/cinn_dialect/ir/cinn_op.h"
namespace cinn {
namespace dialect {
......@@ -32,7 +32,7 @@ void CinnDialect::initialize() {
// paddle/cinn/hlir/dialect/CMakeLists.txt.
RegisterOps<
#define GET_OP_LIST
#include "paddle/cinn/hlir/dialect/cinn_op.h" // NOLINT
#include "paddle/cinn/hlir/dialect/cinn_dialect/ir/cinn_op.h" // NOLINT
>();
}
......
- name: add
inputs:
- typename: Tensor
name: x
optional: false
no_need_buffer: false
data_transform: {}
- typename: Tensor
name: y
optional: false
no_need_buffer: false
data_transform: {}
attrs: []
outputs:
- {typename: Tensor, name: out, optional: false, intermediate: false}
no_need_buffer: null
data_transform: null
infer_meta:
func: ElementwiseInferMeta
param: [x, y]
kernel:
func: [add]
param: [x, y]
backend: null
layout: null
data_type: null
dispatch: {add: null}
force_backend: null
inplace: {out: x}
view: null
backward: null
if(NOT CINN_ONLY)
cinn_cc_library(runtime_dialect SRCS runtime_dialect.cc jit_kernel_op.cc DEPS
ir_core)
endif()
......@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/cinn/hlir/dialect/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/jit_kernel_op.h"
#include "paddle/ir/core/builtin_attribute.h"
#include "paddle/ir/core/enforce.h"
......
......@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/cinn/hlir/dialect/runtime_dialect.h"
#include "paddle/cinn/hlir/dialect/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/runtime_dialect.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/jit_kernel_op.h"
namespace cinn {
namespace dialect {
......
......@@ -17,8 +17,8 @@
#include <string>
#include <unordered_map>
#include "paddle/cinn/hlir/dialect/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/runtime_dialect.h"
#include "paddle/cinn/hlir/framework/program.h"
#include "paddle/ir/core/builtin_attribute.h"
#include "paddle/ir/core/program.h"
......
......@@ -8,5 +8,5 @@ if(WITH_CINN AND NOT CINN_ONLY)
cc_library(
cinn_jit_instruction NOT_FOR_INFER
SRCS cinn_jit_instruction.cc
DEPS phi cinnapi cinn_dialect)
DEPS phi cinnapi cinn_dialect runtime_dialect)
endif()
......@@ -14,8 +14,8 @@
#include "paddle/fluid/framework/new_executor/instruction/cinn_jit_instruction.h"
#include "paddle/cinn/hlir/dialect/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/runtime_dialect.h"
#include "paddle/cinn/hlir/framework/instruction.h"
#include "paddle/fluid/framework/paddle2cinn/transform_type.h"
......
......@@ -6,6 +6,7 @@ if(WITH_TESTING AND WITH_CINN)
DEPS
new_ir_compiler
convert_to_dialect
runtime_dialect
ir
phi
gtest
......
......@@ -27,8 +27,8 @@
#include "paddle/ir/core/ir_context.h"
#include "paddle/ir/core/program.h"
#include "paddle/cinn/hlir/dialect/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/runtime_dialect.h"
#include "paddle/cinn/hlir/framework/convert_to_dialect.h"
#include "paddle/cinn/hlir/framework/new_ir_compiler.h"
#include "paddle/cinn/utils/data_util.h"
......
......@@ -26,8 +26,8 @@
#include "paddle/cinn/utils/data_util.h"
#include "paddle/cinn/hlir/dialect/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/jit_kernel_op.h"
#include "paddle/cinn/hlir/dialect/runtime_dialect/ir/runtime_dialect.h"
#include "paddle/cinn/hlir/framework/convert_to_dialect.h"
#include "paddle/cinn/hlir/framework/new_ir_compiler.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册