diff options
| author | Konstantin <const@const.me> | 2023-01-16 19:32:49 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-01-16 19:32:49 +0100 |
| commit | 00fa441b1cfbc4fa9cdab45cb9ed4ff115c402b0 (patch) | |
| tree | 0ec71ca159e10783009149095edba428660e6c24 | |
| parent | 843a2a6ca6ea47c5ac4889a281badfc808d0ea01 (diff) | |
Bugfix, failed C++ with the lack of move constructor in the CPU profiler RAII class
| -rw-r--r-- | Whisper/Utils/ProfileCollection.cpp | 2 | ||||
| -rw-r--r-- | Whisper/Utils/ProfileCollection.h | 20 |
2 files changed, 18 insertions, 4 deletions
diff --git a/Whisper/Utils/ProfileCollection.cpp b/Whisper/Utils/ProfileCollection.cpp index 2fc5919..eaf737c 100644 --- a/Whisper/Utils/ProfileCollection.cpp +++ b/Whisper/Utils/ProfileCollection.cpp @@ -50,9 +50,11 @@ namespace #define V(x) case eCpuBlock::x: return #x V( LoadModel ); V( Run ); + V( Callbacks ); V( Spectrogram ); V( Sample ); V( VAD ); + V( Encode ); V( Decode ); V( DecodeStep ); V( DecodeLayer ); diff --git a/Whisper/Utils/ProfileCollection.h b/Whisper/Utils/ProfileCollection.h index 732bb48..a03319e 100644 --- a/Whisper/Utils/ProfileCollection.h +++ b/Whisper/Utils/ProfileCollection.h @@ -16,9 +16,11 @@ namespace Whisper { LoadModel, Run, + Callbacks, Spectrogram, Sample, VAD, + Encode, Decode, DecodeStep, DecodeLayer, @@ -62,17 +64,27 @@ namespace Whisper class CpuRaii { - Measure& dest; + Measure* dest; const int64_t tsc; public: - CpuRaii( Measure& m ) : dest( m ), tsc( tscNow() ) + CpuRaii( Measure& m ) : dest( &m ), tsc( tscNow() ) { } + CpuRaii( const CpuRaii& ) = delete; + CpuRaii( CpuRaii&& that ) noexcept : + tsc( that.tsc ) + { + dest = that.dest; + that.dest = nullptr; + } ~CpuRaii() { - const int64_t elapsed = tscNow() - tsc; - dest.add( ticksFromTsc( elapsed ) ); + if( nullptr != dest ) + { + const int64_t elapsed = tscNow() - tsc; + dest->add( ticksFromTsc( elapsed ) ); + } } }; |
