version.cpp 1.6 KB
Newer Older
1
#include "megbrain/version.h"
2
#include "megbrain/common.h"
3

4 5 6 7
#ifndef __IN_TEE_ENV__
#include "git_full_hash_header.h"
#endif

8 9
using namespace mgb;

10 11 12 13 14 15
//! some sdk do not call mgb::get_version explicitly, so we force show version for
//! debug, mgb_log level is info, sdk may config a higher, need export
//! RUNTIME_OVERRIDE_LOG_LEVEL=0 to force change log level to show version
#ifndef __IN_TEE_ENV__
static __attribute__((constructor)) void show_version() {
    auto v = get_version();
16 17
    mgb_log("init Engine with version: %d.%d.%d(%d) @(%s)", v.major, v.minor, v.patch,
            v.is_dev, GIT_FULL_HASH);
18 19 20
}
#endif

21
Version mgb::get_version() {
22
#ifdef MGB_MAJOR
23
    return {MGB_MAJOR, MGB_MINOR, MGB_PATCH, MGB_IS_DEV};
24 25 26
#else
    return {MGE_MAJOR, MGE_MINOR, MGE_PATCH, MGB_IS_DEV};
#endif
27 28
}

G
grimoire 已提交
29
#if __has_include("NvInfer.h") && MGB_ENABLE_TENSOR_RT
30 31 32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
33
#include "NvInfer.h"
34 35 36 37 38 39 40 41 42 43
int mgb::get_tensorrt_version() {
    return NV_TENSORRT_VERSION;
}
#pragma GCC diagnostic pop
#else
int mgb::get_tensorrt_version() {
    return -1;
}
#endif

G
grimoire 已提交
44
#if __has_include("cuda.h") && MGB_CUDA
45 46 47 48 49 50 51 52
#include "cuda.h"
int mgb::get_cuda_version() {
    return CUDA_VERSION;
}
#else
int mgb::get_cuda_version() {
    return -1;
}
53 54
#endif

G
grimoire 已提交
55
#if __has_include("cudnn.h") && MGB_CUDA
56
#include "cudnn.h"
57
int mgb::get_cudnn_version() {
58
    return CUDNN_VERSION;
59
}
60 61
#else
int mgb::get_cudnn_version() {
62 63 64 65
    return -1;
}
#endif

66
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}