From 00fa441b1cfbc4fa9cdab45cb9ed4ff115c402b0 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 16 Jan 2023 19:32:49 +0100 Subject: Bugfix, failed C++ with the lack of move constructor in the CPU profiler RAII class --- Whisper/Utils/ProfileCollection.cpp | 2 ++ 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 ) ); + } } }; -- cgit v1.2.3