Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHI decoupling]migrate enforce_custom.h from fluid to phi #48422

Merged
merged 3 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion paddle/fluid/platform/device/device_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ limitations under the License. */
#endif

#ifdef PADDLE_WITH_CUSTOM_DEVICE
#include "paddle/fluid/platform/device/custom/enforce_custom.h"
#include "paddle/phi/backends/callback_manager.h"
#include "paddle/phi/backends/device_guard.h"
#include "paddle/phi/backends/device_manager.h"
#include "paddle/phi/backends/event.h"
#include "paddle/phi/backends/stream.h"
#include "paddle/phi/core/enforce_custom.h"
#endif
2 changes: 1 addition & 1 deletion paddle/phi/backends/custom/custom_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "paddle/fluid/platform/device/custom/enforce_custom.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/common/data_type.h"
#include "paddle/phi/core/enforce_custom.h"

#include "paddle/phi/backends/callback_manager.h"
#include "paddle/phi/backends/device_base.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ limitations under the License. */
#ifdef PADDLE_WITH_CUSTOM_DEVICE
#include <string>

#include "paddle/fluid/platform/enforce.h"
#include "paddle/phi/backends/device_ext.h"
#include "paddle/phi/core/enforce.h"
Asthestarsfalll marked this conversation as resolved.
Show resolved Hide resolved

namespace paddle {
namespace platform {
namespace details {
namespace phi {
// namespace details {
Asthestarsfalll marked this conversation as resolved.
Show resolved Hide resolved
template <typename T>
struct CustomDeviceStatusType {};

Expand All @@ -33,27 +32,25 @@ struct CustomDeviceStatusType {};
}

DEFINE_CUSTOM_DEVICE_STATUS_TYPE(C_Status, C_SUCCESS);
} // namespace details
// } // namespace details
Asthestarsfalll marked this conversation as resolved.
Show resolved Hide resolved

inline std::string build_custom_device_error_msg(C_Status stat) {
std::ostringstream sout;
sout << " CustomDevice error, the error code is : " << stat << ". ";
return sout.str();
}

#define PADDLE_ENFORCE_CUSTOM_DEVICE_SUCCESS(COND) \
do { \
auto __cond__ = (COND); \
using __CUSTOM_DEVICE_STATUS_TYPE__ = decltype(__cond__); \
constexpr auto __success_type__ = \
::paddle::platform::details::CustomDeviceStatusType< \
__CUSTOM_DEVICE_STATUS_TYPE__>::kSuccess; \
if (UNLIKELY(__cond__ != __success_type__)) { \
auto __summary__ = ::paddle::platform::errors::External( \
::paddle::platform::build_custom_device_error_msg(__cond__)); \
__THROW_ERROR_INTERNAL__(__summary__); \
} \
#define PADDLE_ENFORCE_CUSTOM_DEVICE_SUCCESS(COND) \
do { \
auto __cond__ = (COND); \
using __CUSTOM_DEVICE_STATUS_TYPE__ = decltype(__cond__); \
constexpr auto __success_type__ = ::phi::CustomDeviceStatusType< \
__CUSTOM_DEVICE_STATUS_TYPE__>::kSuccess; \
if (UNLIKELY(__cond__ != __success_type__)) { \
auto __summary__ = ::phi::errors::External( \
::phi::build_custom_device_error_msg(__cond__)); \
__THROW_ERROR_INTERNAL__(__summary__); \
} \
} while (0)
} // namespace platform
} // namespace paddle
} // namespace phi
#endif // PADDLE_WITH_CUSTOM_DEVICE