version.cpp 1.2 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
}

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#if MGB_CUDA
#include "NvInfer.h"
#include "cuda.h"
#include "cudnn.h"
int mgb::get_cuda_version() {
    return CUDA_VERSION;
}
int mgb::get_cudnn_version() {
    return CUDNN_VERSION;
}
int mgb::get_tensorrt_version() {
    return NV_TENSORRT_VERSION;
}
#else
int mgb::get_cuda_version() {
    return -1;
}
int mgb::get_cudnn_version() {
    return -1;
}
int mgb::get_tensorrt_version() {
    return -1;
}
#endif

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