Skip to content

Commit

Permalink
Merge commit 'b29e2f7f98a2185acd48b038ca74eed3d8f67fc2' into pir_pad
Browse files Browse the repository at this point in the history
  • Loading branch information
BeingGod committed Sep 14, 2023
2 parents 0840c3f + b29e2f7 commit a88c44d
Show file tree
Hide file tree
Showing 1,249 changed files with 32,512 additions and 15,186 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ python/paddle/incubate/fleet/parameter_server/pslib/ps_pb2.py
paddle/phi/kernels/fusion/cutlass/conv2d/generated/*
python/paddle/base/incubate/fleet/parameter_server/pslib/ps_pb2.py
paddle/fluid/ir_adaptor/translator/op_compat_info.cc
paddle/phi/kernels/fusion/cutlass/cutlass_kernels/fpA_intB_gemm/autogen/*
paddle/fluid/pybind/static_op_function.*
paddle/fluid/pybind/ops_api.cc
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at paddle-dev@baidu.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ext_paddle_oss@baidu.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

## 强制执行

可以通过paddle-dev@baidu.com,来联系项目团队来举报滥用、骚扰或其他不被接受的行为。
可以通过ext_paddle_oss@baidu.com,来联系项目团队来举报滥用、骚扰或其他不被接受的行为。

任何维护团队认为有必要且适合的所有投诉都将进行审查及调查,并做出相对应的回应。项目小组有对事件回报者有保密的义务。具体执行的方针近一步细节可能会单独公布。

Expand Down
8 changes: 4 additions & 4 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ cinn_cc_library(
add_dependencies(cinnapi GEN_LLVM_RUNTIME_IR_HEADER ZLIB::ZLIB)
add_dependencies(cinnapi GEN_LLVM_RUNTIME_IR_HEADER ${core_deps})
if(NOT CINN_ONLY)
target_link_libraries(cinnapi pd_dialect phi)
add_dependencies(cinnapi pd_dialect phi)
target_link_libraries(cinnapi pd_op_dialect phi)
add_dependencies(cinnapi pd_op_dialect phi)
endif()

target_link_libraries(cinnapi ${PYTHON_LIBRARIES})
Expand Down Expand Up @@ -222,8 +222,8 @@ function(gen_cinncore LINKTYPE)
add_dependencies(${CINNCORE_TARGET} GEN_LLVM_RUNTIME_IR_HEADER ZLIB::ZLIB)
add_dependencies(${CINNCORE_TARGET} GEN_LLVM_RUNTIME_IR_HEADER ${core_deps})
if(NOT CINN_ONLY)
target_link_libraries(${CINNCORE_TARGET} pd_dialect phi)
add_dependencies(${CINNCORE_TARGET} pd_dialect phi)
target_link_libraries(${CINNCORE_TARGET} pd_op_dialect phi)
add_dependencies(${CINNCORE_TARGET} pd_op_dialect phi)
endif()

add_dependencies(${CINNCORE_TARGET} pybind)
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/brpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

include(ExternalProject)

set(OPENSSL_USE_STATIC_LIBS ON)
find_package(OpenSSL REQUIRED)

message(STATUS "ssl:" ${OPENSSL_SSL_LIBRARY})
Expand Down
4 changes: 2 additions & 2 deletions cmake/inference_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ else()
DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
endif()
if(WITH_SHARED_IR)
set(paddle_ir_lib ${PADDLE_BINARY_DIR}/paddle/ir/libir.*)
set(paddle_pir_lib ${PADDLE_BINARY_DIR}/paddle/pir/libpir.*)
copy(
inference_lib_dist
SRCS ${paddle_ir_lib}
SRCS ${paddle_pir_lib}
DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
endif()
endif()
Expand Down
2 changes: 1 addition & 1 deletion paddle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(PYTHON_TESTS_DIR
CACHE INTERNAL "python tests directory")

add_subdirectory(utils)
add_subdirectory(ir)
add_subdirectory(pir)
add_subdirectory(scripts)
add_subdirectory(testing)
add_subdirectory(phi)
Expand Down
1 change: 1 addition & 0 deletions paddle/cinn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if(WITH_TESTING)
endif()

add_subdirectory(api)
add_subdirectory(ast_gen_ius)
add_subdirectory(auto_schedule)
add_subdirectory(common)
add_subdirectory(utils)
Expand Down
6 changes: 6 additions & 0 deletions paddle/cinn/ast_gen_ius/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
core_gather_headers()

gather_srcs(cinnapi_src SRCS ast_gen.cc tensor_group.cc)

cinn_cc_test(test_ast_gen_ius SRCS ast_gen_test.cc DEPS cinncore)
cinn_cc_test(test_tensor_group SRCS tensor_group_test.cc DEPS cinncore)
52 changes: 52 additions & 0 deletions paddle/cinn/ast_gen_ius/ast_gen.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2023 CINN Authors. All Rights Reserved.
//
// 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.

#include "paddle/cinn/ast_gen_ius/ast_gen.h"
#include "paddle/cinn/ir/ir.h"
#include "paddle/cinn/ir/ir_base.h"
#include "paddle/cinn/ir/operation.h"
#include "paddle/cinn/ir/tensor.h"
#include "paddle/cinn/ir/utils/ir_printer.h"

namespace cinn {
namespace ast_gen_ius {

ir::Expr AstGen::Build(const ir::Tensor& tensor) {
const std::vector<ir::Var>& axis = tensor->axis();
const std::vector<ir::Expr>& shape = tensor->shape;
size_t axis_len = axis.size();
CHECK_EQ(shape.size(), axis_len)
<< "Internal Error: Tensor has different shape and axis length in AstGen";

std::vector<ir::Expr> axis_exprs;
for (const auto& a : axis) {
axis_exprs.push_back(a);
}
ir::Expr body = ir::Store::Make(tensor, tensor->body(), axis_exprs);

for (int i = static_cast<int>(axis_len) - 1; i >= 0; --i) {
ir::Var loop_var = axis[i];
ir::Expr loop_extent = shape[i];
body = ir::For::Make(loop_var,
Expr(0),
loop_extent,
ir::ForType::Serial,
ir::DeviceAPI::Host,
ir::Block::Make({body}));
}
return body;
}

} // namespace ast_gen_ius
} // namespace cinn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 CINN Authors. All Rights Reserved.
// Copyright (c) 2023 CINN Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,22 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* This file implements the strategy to remove the unnecessary nested block.
*/
#pragma once
#include <vector>

#include "paddle/cinn/common/common.h"
#include "paddle/cinn/ir/ir.h"
#include "paddle/cinn/ir/ir_base.h"
#include "paddle/cinn/ir/tensor.h"

namespace cinn {
namespace optim {
namespace ast_gen_ius {

/**
* Remove the unecessary nested block.
*/
void RemoveNestedBlock(Expr* e);
class AstGen {
public:
static ir::Expr Build(const ir::Tensor& tensor);
};

} // namespace optim
} // namespace ast_gen_ius
} // namespace cinn
44 changes: 44 additions & 0 deletions paddle/cinn/ast_gen_ius/ast_gen_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) 2023 CINN Authors. All Rights Reserved.
//
// 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.

#include <gtest/gtest.h>
#include <vector>

#include "paddle/cinn/ast_gen_ius/ast_gen.h"
#include "paddle/cinn/ir/ir.h"
#include "paddle/cinn/ir/ir_base.h"
#include "paddle/cinn/ir/tensor.h"
#include "paddle/cinn/lang/builtin.h"
#include "paddle/cinn/lang/compute.h"
#include "paddle/cinn/lang/placeholder.h"

namespace cinn {
namespace ast_gen_ius {

using cinn::ir::Expr;
using cinn::ir::Tensor;

TEST(AstGen, Build) {
std::vector<Expr> shape = {Expr(10), Expr(10), Expr(10), Expr(10)};
lang::Placeholder<float> A("A", shape);
Tensor B = lang::Compute(
shape,
[&](const std::vector<Expr>& indice) { return lang::Relu(A(indice), 0); },
"relu_test");
Expr out = AstGen::Build(B);
LOG(INFO) << out;
}

} // namespace ast_gen_ius
} // namespace cinn
Loading

0 comments on commit a88c44d

Please sign in to comment.