Download nemotron-ocr/cpp/scope_timer.h from Metausermac13/nemotron-ocr-v2: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/Metausermac13/nemotron-ocr-v2/resolve/main/nemotron-ocr/cpp/scope_timer.h
- Command line
-
hf download hf://Metausermac13/nemotron-ocr-v2/nemotron-ocr/cpp/scope_timer.h
-
curl -L -o scope_timer.h https://huggingface.co/Metausermac13/nemotron-ocr-v2/resolve/main/nemotron-ocr/cpp/scope_timer.h
1 kB
| // SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| // SPDX-License-Identifier: Apache-2.0 | |
| namespace chrono = std::chrono; | |
| class CudaStoreTimer | |
| { | |
| typedef decltype(chrono::high_resolution_clock::now()) tp_t; | |
| public: | |
| CudaStoreTimer(double &storage, bool enabled=true, bool synchronize=true) | |
| : m_storage(&storage), m_enabled(enabled), m_synchronize(synchronize) | |
| { | |
| m_start = GetTP(); | |
| } | |
| ~CudaStoreTimer() | |
| { | |
| if (! m_enabled) return; | |
| auto tNow = GetTP(); | |
| chrono::duration<double, std::milli> dur = tNow - m_start; | |
| *m_storage = dur.count(); | |
| } | |
| private: | |
| tp_t GetTP() const | |
| { | |
| if (m_enabled && m_synchronize) { | |
| cudaDeviceSynchronize(); | |
| } | |
| return chrono::high_resolution_clock::now(); | |
| } | |
| double *m_storage; | |
| tp_t m_start; | |
| bool m_enabled; | |
| bool m_synchronize; | |
| }; | |