Add verbose define
Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@ int main(int argc, char *argv[]) {
|
|||||||
std::cout<<"Min: "<<*std::min_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
|
std::cout<<"Min: "<<*std::min_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
|
||||||
std::cout<<"Max: "<<*std::max_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
|
std::cout<<"Max: "<<*std::max_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
|
||||||
for(int i=0; i<detNN->stats.size(); i++) mean += detNN->stats[i]; mean /= detNN->stats.size();
|
for(int i=0; i<detNN->stats.size(); i++) mean += detNN->stats[i]; mean /= detNN->stats.size();
|
||||||
std::cout<<"Avg: "<<mean/n_batch<<" ms\n"<<COL_END;
|
std::cout<<"Avg: "<<mean/n_batch<<" ms\t"<<1000/(mean/n_batch)<<" FPS\n"<<COL_END;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class DetectionNN {
|
|||||||
if(save_times && times==nullptr)
|
if(save_times && times==nullptr)
|
||||||
FatalError("save_times set to true, but no valid ofstream given");
|
FatalError("save_times set to true, but no valid ofstream given");
|
||||||
|
|
||||||
printCenteredTitle(" TENSORRT detection ", '=', 30);
|
if(VERBOSE) printCenteredTitle(" TENSORRT detection ", '=', 30);
|
||||||
{
|
{
|
||||||
TIMER_START
|
TIMER_START
|
||||||
for(int bi=0; bi<nBatches;++bi){
|
for(int bi=0; bi<nBatches;++bi){
|
||||||
@@ -117,11 +117,11 @@ class DetectionNN {
|
|||||||
tk::dnn::dataDim_t dim = netRT->input_dim;
|
tk::dnn::dataDim_t dim = netRT->input_dim;
|
||||||
dim.n = nBatches;
|
dim.n = nBatches;
|
||||||
{
|
{
|
||||||
dim.print();
|
if(VERBOSE) dim.print();
|
||||||
TIMER_START
|
TIMER_START
|
||||||
netRT->infer(dim, input_d);
|
netRT->infer(dim, input_d);
|
||||||
TIMER_STOP
|
TIMER_STOP
|
||||||
dim.print();
|
if(VERBOSE) dim.print();
|
||||||
stats.push_back(t_ns);
|
stats.push_back(t_ns);
|
||||||
if(save_times) *times<<t_ns<<";";
|
if(save_times) *times<<t_ns<<";";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,16 +36,18 @@
|
|||||||
#define COL_PURPLEB "\033[1;35m"
|
#define COL_PURPLEB "\033[1;35m"
|
||||||
#define COL_CYANB "\033[1;36m"
|
#define COL_CYANB "\033[1;36m"
|
||||||
|
|
||||||
|
#define VERBOSE 0
|
||||||
|
|
||||||
// Simple Timer
|
// Simple Timer
|
||||||
#define TIMER_START timespec start, end; \
|
#define TIMER_START timespec start, end; \
|
||||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||||
|
|
||||||
#define TIMER_STOP_C(col) clock_gettime(CLOCK_MONOTONIC, &end); \
|
#define TIMER_STOP_C(col, show) clock_gettime(CLOCK_MONOTONIC, &end); \
|
||||||
double t_ns = ((double)(end.tv_sec - start.tv_sec) * 1.0e9 + \
|
double t_ns = ((double)(end.tv_sec - start.tv_sec) * 1.0e9 + \
|
||||||
(double)(end.tv_nsec - start.tv_nsec))/1.0e6; \
|
(double)(end.tv_nsec - start.tv_nsec))/1.0e6; \
|
||||||
std::cout<<col<<"Time:"<<std::setw(16)<<t_ns<<" ms\n"<<COL_END;
|
if(show) std::cout<<col<<"Time:"<<std::setw(16)<<t_ns<<" ms\n"<<COL_END;
|
||||||
|
|
||||||
#define TIMER_STOP TIMER_STOP_C(COL_CYANB)
|
#define TIMER_STOP TIMER_STOP_C(COL_CYANB, VERBOSE)
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Prints the error message, and exits
|
* Prints the error message, and exits
|
||||||
|
|||||||
Reference in New Issue
Block a user