utils.hpp 2.8 KB
Newer Older
yanjl1's avatar
Initial  
yanjl1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier:  MIT
#pragma once

#include <hip/hip_runtime.h>
#include <hipdnn_frontend.hpp>

#define HIP_CHECK(status)                                                                        \
    do                                                                                           \
    {                                                                                            \
        if((status) != hipSuccess)                                                               \
        {                                                                                        \
            std::cerr << "HIP Error: " << hipGetErrorString((status)) << " in file " << __FILE__ \
                      << " at line " << __LINE__ << "\n";                                        \
            exit(EXIT_FAILURE);                                                                  \
        }                                                                                        \
    } while(0)

#define HIPDNN_CHECK(status)                                                               \
    do                                                                                     \
    {                                                                                      \
        if((status) != HIPDNN_STATUS_SUCCESS)                                              \
        {                                                                                  \
            std::cerr << "hipDNN Error: " << hipdnnGetErrorString((status)) << " in file " \
                      << __FILE__ << " at line " << __LINE__ << "\n";                      \
            exit(EXIT_FAILURE);                                                            \
        }                                                                                  \
    } while(0)

#define HIPDNN_FE_CHECK(statusObj)                                                        \
    do                                                                                    \
    {                                                                                     \
        auto const& status = statusObj;                                                   \
        if(!status.is_good())                                                             \
        {                                                                                 \
            std::cerr << "hipDNN Frontend Error: " << status.get_message() << " in file " \
                      << __FILE__ << " at line " << __LINE__ << "\n";                     \
            exit(EXIT_FAILURE);                                                           \
        }                                                                                 \
    } while(0)