forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add python bind for pe (PaddlePaddle#169)
* add python bind for pe * refine pe test
- Loading branch information
Showing
23 changed files
with
209 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/hlir/framework/scope.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
cc_library(core_api SHARED | ||
SRCS runtime.cc common.cc lang.cc ir.cc poly.cc backends.cc bind.cc optim.cc | ||
DEPS core cinn_runtime pybind) | ||
|
||
if (WITH_CUDA) | ||
message(STATUS "Compile core_api with CUDA support") | ||
nv_library(core_api SHARED | ||
SRCS runtime.cc common.cc lang.cc ir.cc poly.cc backends.cc bind.cc optim.cc pe.cc | ||
DEPS core cinn_runtime pybind) | ||
message("cuda_nvrtc: ${CUDA_NVRTC}") | ||
target_link_libraries(core_api ${CUDA_NVRTC_LIB} ${CUDA_LIBRARIES} cuda) | ||
else() | ||
message(STATUS "Compile core_api without CUDA support") | ||
cc_library(core_api SHARED | ||
SRCS runtime.cc common.cc lang.cc ir.cc poly.cc backends.cc bind.cc optim.cc pe.cc | ||
DEPS core cinn_runtime pybind) | ||
endif() | ||
|
||
execute_process(COMMAND python3 -m pybind11 --includes OUTPUT_VARIABLE pybind_includes) | ||
string(REGEX REPLACE "\n$" "" pybind_includes "${pybind_includes}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${pybind_includes}") | ||
|
||
|
||
#execute_process(COMMAND python3-config --extension-suffix OUTPUT_VARIABLE python3_module_suffix) | ||
SET_TARGET_PROPERTIES(core_api PROPERTIES PREFIX "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "cinn/common/target.h" | ||
#include "cinn/hlir/pe/elementwise.h" | ||
#include "cinn/pybind/bind.h" | ||
#include "cinn/pybind/bind_utils.h" | ||
#include "cinn/utils/string.h" | ||
|
||
namespace py = pybind11; | ||
|
||
namespace cinn { | ||
namespace pybind { | ||
|
||
using common::Type; | ||
using lang::Placeholder; | ||
using py::arg; | ||
using utils::GetStreamCnt; | ||
using utils::StringFormat; | ||
|
||
void BindPE(py::module* m) { | ||
#define BIND_UNARY(name__, fn__) m->def(#name__, &hlir::pe::fn__, py::arg("x"), py::arg("out") = "T_" #name__ "_out") | ||
BIND_UNARY(exp, Exp); | ||
BIND_UNARY(erf, Erf); | ||
BIND_UNARY(sqrt, Sqrt); | ||
BIND_UNARY(log, Log); | ||
BIND_UNARY(log2, Log2); | ||
BIND_UNARY(log10, Log10); | ||
BIND_UNARY(floor, Floor); | ||
BIND_UNARY(ceil, Ceil); | ||
BIND_UNARY(round, Round); | ||
BIND_UNARY(trunc, Trunc); | ||
BIND_UNARY(cos, Cos); | ||
BIND_UNARY(cosh, Cosh); | ||
BIND_UNARY(tan, Tan); | ||
BIND_UNARY(sin, Sin); | ||
BIND_UNARY(sinh, Sinh); | ||
BIND_UNARY(acos, Acos); | ||
BIND_UNARY(acosh, Acosh); | ||
BIND_UNARY(asin, Asin); | ||
BIND_UNARY(asinh, Asinh); | ||
BIND_UNARY(atan, Atan); | ||
BIND_UNARY(atanh, Atanh); | ||
BIND_UNARY(isnan, Isnan); | ||
BIND_UNARY(tanh, Tanh); | ||
BIND_UNARY(isfinite, Isfinite); | ||
BIND_UNARY(isinf, Isinf); | ||
|
||
BIND_UNARY(negative, Negative); | ||
BIND_UNARY(identity, Identity); | ||
BIND_UNARY(logical_not, LogicalNot); | ||
BIND_UNARY(bitwise_not, BitwiseNot); | ||
BIND_UNARY(sigmoid, Sigmoid); | ||
BIND_UNARY(sign, Sign); | ||
BIND_UNARY(abs, Abs); | ||
BIND_UNARY(rsqrt, Rsqrt); | ||
} | ||
|
||
} // namespace pybind | ||
} // namespace cinn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .core_api.pe import * |
Oops, something went wrong.