未验证 提交 13e4280f 编写于 作者: Z Zhou Wei 提交者: GitHub

[Custom OP]polish doc of custom OP (#31369)

上级 946dbdae
...@@ -102,7 +102,7 @@ class ErrorMessage { ...@@ -102,7 +102,7 @@ class ErrorMessage {
do { \ do { \
auto __message__ = ::paddle::ErrorMessage(__VA_ARGS__).to_string(); \ auto __message__ = ::paddle::ErrorMessage(__VA_ARGS__).to_string(); \
throw ::paddle::PD_Exception(__message__, __FILE__, __LINE__, \ throw ::paddle::PD_Exception(__message__, __FILE__, __LINE__, \
"An error occured."); \ "An error occurred."); \
} while (0) } while (0)
} // namespace paddle } // namespace paddle
...@@ -519,7 +519,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -519,7 +519,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
VLOG(0) << "error: the number of ids is a negative number: " << num; VLOG(0) << "error: the number of ids is a negative number: " << num;
VLOG(0) << "please check line<" << instance_cout << "> in file<" VLOG(0) << "please check line<" << instance_cout << "> in file<"
<< filename << ">"; << filename << ">";
VLOG(0) << "Error occured when parsing " << i VLOG(0) << "Error occurred when parsing " << i
<< " th slot with total slots number: " << all_slots_.size(); << " th slot with total slots number: " << all_slots_.size();
return false; return false;
} else if (num == 0) { } else if (num == 0) {
...@@ -530,14 +530,14 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -530,14 +530,14 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
"characters."; "characters.";
VLOG(0) << "please check line<" << instance_cout << "> in file<" VLOG(0) << "please check line<" << instance_cout << "> in file<"
<< filename << ">"; << filename << ">";
VLOG(0) << "Error occured when parsing " << i VLOG(0) << "Error occurred when parsing " << i
<< " th slot with total slots number: " << all_slots_.size(); << " th slot with total slots number: " << all_slots_.size();
return false; return false;
} else if (errno == ERANGE || num > INT_MAX) { } else if (errno == ERANGE || num > INT_MAX) {
VLOG(0) << "error: the number of ids greater than INT_MAX"; VLOG(0) << "error: the number of ids greater than INT_MAX";
VLOG(0) << "please check line<" << instance_cout << "> in file<" VLOG(0) << "please check line<" << instance_cout << "> in file<"
<< filename << ">"; << filename << ">";
VLOG(0) << "Error occured when parsing " << i VLOG(0) << "Error occurred when parsing " << i
<< " th slot with total slots number: " << all_slots_.size(); << " th slot with total slots number: " << all_slots_.size();
return false; return false;
} }
...@@ -549,7 +549,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -549,7 +549,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
"representable values for float"; "representable values for float";
VLOG(0) << "please check line<" << instance_cout << "> in file<" VLOG(0) << "please check line<" << instance_cout << "> in file<"
<< filename << ">"; << filename << ">";
VLOG(0) << "Error occured when parsing " << i VLOG(0) << "Error occurred when parsing " << i
<< " th slot with total slots number: " << " th slot with total slots number: "
<< all_slots_.size(); << all_slots_.size();
VLOG(0) << "and in this slot: " << j VLOG(0) << "and in this slot: " << j
...@@ -558,7 +558,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -558,7 +558,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
} }
if (j + 1 != num && endptr - str == len) { if (j + 1 != num && endptr - str == len) {
VLOG(0) << "error: there is a wrong with the number of ids."; VLOG(0) << "error: there is a wrong with the number of ids.";
VLOG(0) << "Error occured when parsing " << i VLOG(0) << "Error occurred when parsing " << i
<< " th slot with total slots number: " << " th slot with total slots number: "
<< all_slots_.size(); << all_slots_.size();
VLOG(0) << "and in this slot: " << j VLOG(0) << "and in this slot: " << j
...@@ -574,7 +574,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -574,7 +574,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
if (errno == ERANGE) { if (errno == ERANGE) {
VLOG(0) << "error: the value is out of the range of " VLOG(0) << "error: the value is out of the range of "
"representable values for uint64_t"; "representable values for uint64_t";
VLOG(0) << "Error occured when parsing " << i VLOG(0) << "Error occurred when parsing " << i
<< " th slot with total slots number: " << " th slot with total slots number: "
<< all_slots_.size(); << all_slots_.size();
VLOG(0) << "and in this slot: " << j VLOG(0) << "and in this slot: " << j
...@@ -585,7 +585,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) { ...@@ -585,7 +585,7 @@ bool MultiSlotDataFeed::CheckFile(const char* filename) {
} }
if (j + 1 != num && endptr - str == len) { if (j + 1 != num && endptr - str == len) {
VLOG(0) << "error: there is a wrong with the number of ids."; VLOG(0) << "error: there is a wrong with the number of ids.";
VLOG(0) << "Error occured when parsing " << i VLOG(0) << "Error occurred when parsing " << i
<< " th slot with total slots number: " << " th slot with total slots number: "
<< all_slots_.size(); << all_slots_.size();
VLOG(0) << "and in this slot: " << j VLOG(0) << "and in this slot: " << j
......
...@@ -108,7 +108,7 @@ class ExceptionHolder { ...@@ -108,7 +108,7 @@ class ExceptionHolder {
type_ = kNone; type_ = kNone;
} }
// NOTE: currently in PE, multiple exceptions may occured in multiple // NOTE: currently in PE, multiple exceptions may occurred in multiple
// threads, and the exception that occur later will overwrite that // threads, and the exception that occur later will overwrite that
// occur earlier, but what we want should be the first triggered exception. // occur earlier, but what we want should be the first triggered exception.
// However, EOF exception is lower priority exception and can be overwritten, // However, EOF exception is lower priority exception and can be overwritten,
......
...@@ -21,7 +21,7 @@ TEST(PD_THROW, empty) { ...@@ -21,7 +21,7 @@ TEST(PD_THROW, empty) {
} catch (const std::exception& e) { } catch (const std::exception& e) {
caught_exception = true; caught_exception = true;
std::string err_msg = e.what(); std::string err_msg = e.what();
EXPECT_TRUE(err_msg.find("An error occured.") != std::string::npos); EXPECT_TRUE(err_msg.find("An error occurred.") != std::string::npos);
#if _WIN32 #if _WIN32
EXPECT_TRUE(err_msg.find("tests\\custom_op\\test_check_error.cc:20") != EXPECT_TRUE(err_msg.find("tests\\custom_op\\test_check_error.cc:20") !=
std::string::npos); std::string::npos);
......
...@@ -52,24 +52,28 @@ def setup(**attr): ...@@ -52,24 +52,28 @@ def setup(**attr):
It encapsulates the python built-in ``setuptools.setup`` function and keeps arguments It encapsulates the python built-in ``setuptools.setup`` function and keeps arguments
and usage same as the native interface. Meanwhile, it hiddens Paddle inner framework and usage same as the native interface. Meanwhile, it hiddens Paddle inner framework
concepts, such as necessary compiling flags, included paths of head files, and linking concepts, such as necessary compiling flags, included paths of head files, and linking
flags. It also will automatically search and valid local enviromment and versions of ``cc`` and flags. It also will automatically search and valid local enviromment and versions of
``nvcc`` , then compiles customized operators supporting CPU or GPU device according to ``cc(Linux)`` , ``cl.exe(Windows)`` and ``nvcc`` , then compiles customized operators
the specified Extension type. supporting CPU or GPU device according to the specified Extension type.
Moreover, `ABI compatibility <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html>`_ Moreover, `ABI compatibility <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html>`_
will be checked to ensure that compiler version from ``cc`` will be checked to ensure that compiler version from ``cc(Linux)`` , ``cl.exe(Windows)``
on local machine is compatible with pre-installed Paddle whl in python site-packages. on local machine is compatible with pre-installed Paddle whl in python site-packages.
For example if Paddle with CUDA 10.1 is built with GCC 8.2, then the version of user's
local machine should satisfy GCC >= 8.2. Otherwise, a fatal error will occur because of For Linux, GCC version will be checked . For example if Paddle with CUDA 10.1 is built with GCC 8.2,
ABI compatibility. then the version of user's local machine should satisfy GCC >= 8.2.
For Windows, Visual Studio version will be checked, and it shoule be greater than or equal to that of
PaddlePaddle (Visual Studio 2015 update3).
If the above conditions are not met, the corresponding warning will be printed, and a fatal error may
occur because of ABI compatibility.
.. note:: .. note::
1. Compiler ABI compatibility is forward compatible. On Linux platform, 1. Currently we support Linux and Windows platfrom. MacOS is supporting...
we recommend to use GCC 8.2 as soft linking condidate of ``/usr/bin/cc`` . 2. On Linux platform, we recommend to use GCC 8.2 as soft linking condidate of ``/usr/bin/cc`` .
2. Using ``which cc`` to ensure location of ``cc`` and using ``cc --version`` Then, Use ``which cc`` to ensure location of ``cc`` and using ``cc --version`` to ensure linking
to ensure linking GCC version on Linux. GCC version.
3. Currently we support Linux and Windows platfrom. MacOS is supporting... 3. On Windows platform, we recommend to install `` Visual Studio`` (>=2015 update3).
Compared with Just-In-Time ``load`` interface, it only compiles once by executing Compared with Just-In-Time ``load`` interface, it only compiles once by executing
...@@ -673,19 +677,23 @@ def load(name, ...@@ -673,19 +677,23 @@ def load(name,
append user defined custom operators in background while building models. append user defined custom operators in background while building models.
It will perform compiling, linking, Python API generation and module loading It will perform compiling, linking, Python API generation and module loading
processes under a individual subprocess. It does not require CMake or Ninja environment processes under a individual subprocess. It does not require CMake or Ninja
and only ``g++/nvcc`` on Linux and clang++ on MacOS. For example it requires environment. On Linux platform, it requires GCC compiler whose version is
GCC compiler with version is greater than 5.4 and linked into ``/usr/bin/cc`` . greater than 5.4 and it should be soft linked to ``/usr/bin/cc`` . On Windows
If compiling Operators supporting GPU device, please make sure ``nvcc`` compiler platform, it requires Visual Studio whose version is greater than 2015 update3.
is installed in local environment. On MacOS, clang++ is requited. In addition, if compiling Operators supporting
GPU device, please make sure ``nvcc`` compiler is installed in local environment.
Moreover, `ABI compatibility <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html>`_ Moreover, `ABI compatibility <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html>`_
will be checked to ensure that compiler version from ``cc`` will be checked to ensure that compiler version from ``cc(Linux)`` , ``cl.exe(Windows)``
on local machine is compatible with pre-installed Paddle whl in python site-packages. on local machine is compatible with pre-installed Paddle whl in python site-packages.
For example if Paddle with CUDA 10.1 is built with GCC 8.2, then the version of user's
local machine should satisfy GCC >= 8.2. Otherwise, a fatal error will occur because of For Linux, GCC version will be checked . For example if Paddle with CUDA 10.1 is built with GCC 8.2,
ABI compatibility. then the version of user's local machine should satisfy GCC >= 8.2.
For Windows, Visual Studio version will be checked, and it shoule be greater than or equal to that of
PaddlePaddle (Visual Studio 2015 update3).
If the above conditions are not met, the corresponding warning will be printed, and a fatal error may
occur because of ABI compatibility.
Compared with ``setup`` interface, it doesn't need extra ``setup.py`` and excute Compared with ``setup`` interface, it doesn't need extra ``setup.py`` and excute
``python setup.py install`` command. The interface contains all compiling and installing ``python setup.py install`` command. The interface contains all compiling and installing
...@@ -693,11 +701,11 @@ def load(name, ...@@ -693,11 +701,11 @@ def load(name,
.. note:: .. note::
1. Compiler ABI compatibility is forward compatible. On Linux platform, 1. Currently we support Linux and Windows platfrom. MacOS is supporting...
we recommend to use GCC 8.2 as soft linking condidate of ``/usr/bin/cc`` . 2. On Linux platform, we recommend to use GCC 8.2 as soft linking condidate of ``/usr/bin/cc`` .
2. Using ``which cc`` to ensure location of ``cc`` and using ``cc --version`` Then, Use ``which cc`` to ensure location of ``cc`` and using ``cc --version`` to ensure linking
to ensure linking GCC version on Linux. GCC version.
3. Currenly we support Linux and Windows platfrom. MacOS is supporting... 3. On Windows platform, we recommend to install `` Visual Studio`` (>=2015 update3).
**A simple example:** **A simple example:**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册