未验证 提交 9896ac1e 编写于 作者: A Asthestarsfalll 提交者: GitHub

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

* migrate enforce_custom.h from fluid to phi

* move to backends/custom/
上级 fa10524d
...@@ -40,8 +40,8 @@ limitations under the License. */ ...@@ -40,8 +40,8 @@ limitations under the License. */
#endif #endif
#ifdef PADDLE_WITH_CUSTOM_DEVICE #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/callback_manager.h"
#include "paddle/phi/backends/custom/enforce_custom.h"
#include "paddle/phi/backends/device_guard.h" #include "paddle/phi/backends/device_guard.h"
#include "paddle/phi/backends/device_manager.h" #include "paddle/phi/backends/device_manager.h"
#include "paddle/phi/backends/event.h" #include "paddle/phi/backends/event.h"
......
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "paddle/fluid/platform/device/custom/enforce_custom.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/common/data_type.h"
#include "paddle/phi/backends/callback_manager.h" #include "paddle/phi/backends/callback_manager.h"
#include "paddle/phi/backends/custom/enforce_custom.h"
#include "paddle/phi/backends/device_base.h" #include "paddle/phi/backends/device_base.h"
#include "paddle/phi/backends/device_guard.h" #include "paddle/phi/backends/device_guard.h"
#include "paddle/phi/backends/device_manager.h" #include "paddle/phi/backends/device_manager.h"
#include "paddle/phi/backends/event.h" #include "paddle/phi/backends/event.h"
#include "paddle/phi/backends/stream.h" #include "paddle/phi/backends/stream.h"
#include "paddle/phi/common/data_type.h"
static bool operator==(const C_Device_st& d1, const C_Device_st& d2) { static bool operator==(const C_Device_st& d1, const C_Device_st& d2) {
return d1.id == d2.id; return d1.id == d2.id;
......
...@@ -16,12 +16,10 @@ limitations under the License. */ ...@@ -16,12 +16,10 @@ limitations under the License. */
#ifdef PADDLE_WITH_CUSTOM_DEVICE #ifdef PADDLE_WITH_CUSTOM_DEVICE
#include <string> #include <string>
#include "paddle/fluid/platform/enforce.h"
#include "paddle/phi/backends/device_ext.h" #include "paddle/phi/backends/device_ext.h"
#include "paddle/phi/core/enforce.h"
namespace paddle { namespace phi {
namespace platform {
namespace details {
template <typename T> template <typename T>
struct CustomDeviceStatusType {}; struct CustomDeviceStatusType {};
...@@ -33,7 +31,6 @@ struct CustomDeviceStatusType {}; ...@@ -33,7 +31,6 @@ struct CustomDeviceStatusType {};
} }
DEFINE_CUSTOM_DEVICE_STATUS_TYPE(C_Status, C_SUCCESS); DEFINE_CUSTOM_DEVICE_STATUS_TYPE(C_Status, C_SUCCESS);
} // namespace details
inline std::string build_custom_device_error_msg(C_Status stat) { inline std::string build_custom_device_error_msg(C_Status stat) {
std::ostringstream sout; std::ostringstream sout;
...@@ -45,15 +42,13 @@ inline std::string build_custom_device_error_msg(C_Status stat) { ...@@ -45,15 +42,13 @@ inline std::string build_custom_device_error_msg(C_Status stat) {
do { \ do { \
auto __cond__ = (COND); \ auto __cond__ = (COND); \
using __CUSTOM_DEVICE_STATUS_TYPE__ = decltype(__cond__); \ using __CUSTOM_DEVICE_STATUS_TYPE__ = decltype(__cond__); \
constexpr auto __success_type__ = \ constexpr auto __success_type__ = ::phi::CustomDeviceStatusType< \
::paddle::platform::details::CustomDeviceStatusType< \
__CUSTOM_DEVICE_STATUS_TYPE__>::kSuccess; \ __CUSTOM_DEVICE_STATUS_TYPE__>::kSuccess; \
if (UNLIKELY(__cond__ != __success_type__)) { \ if (UNLIKELY(__cond__ != __success_type__)) { \
auto __summary__ = ::paddle::platform::errors::External( \ auto __summary__ = ::phi::errors::External( \
::paddle::platform::build_custom_device_error_msg(__cond__)); \ ::phi::build_custom_device_error_msg(__cond__)); \
__THROW_ERROR_INTERNAL__(__summary__); \ __THROW_ERROR_INTERNAL__(__summary__); \
} \ } \
} while (0) } while (0)
} // namespace platform } // namespace phi
} // namespace paddle
#endif // PADDLE_WITH_CUSTOM_DEVICE #endif // PADDLE_WITH_CUSTOM_DEVICE
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册