-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommon.h
42 lines (38 loc) · 1.26 KB
/
common.h
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
41
42
#ifndef _TRT_COMMON_H_
#define _TRT_COMMON_H_
#include "NvInfer.h"
#include <string>
#include <vector>
#include <fstream>
#include <cassert>
#include <iostream>
#define CHECK(status) \
{ \
if (status != 0) \
{ \
fprintf(stderr, "CUDA_ERROR(%d) %s: %s\n", status, cudaGetErrorName(status), cudaGetErrorString(status)); \
abort(); \
} \
}
// Logger for GIE info/warning/errors
class Logger : public nvinfer1::ILogger
{
public:
void log(nvinfer1::ILogger::Severity severity, const char* msg) override
{
// suppress info-level messages
if (severity == Severity::kINFO) return;
switch (severity)
{
case Severity::kINTERNAL_ERROR: std::cerr << "INTERNAL_ERROR: "; break;
case Severity::kERROR: std::cerr << "ERROR: "; break;
case Severity::kWARNING: std::cerr << "WARNING: "; break;
case Severity::kINFO: std::cerr << "INFO: "; break;
default: std::cerr << "UNKNOWN: "; break;
}
std::cerr << msg << std::endl;
}
};
std::string locateFile(const std::string& input, const std::vector<std::string> & directories);
void readPGMFile(const std::string& fileName, uint8_t *buffer, int inH, int inW);
#endif // _TRT_COMMON_H_