From 8fa57f680f002f4f636da687e40e21225f1ee392 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 22 Jan 2023 12:30:54 +0100 Subject: GPU performance, optimized away a few shader dispatches --- Whisper/ML/MlContext.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Whisper/ML/MlContext.cpp') diff --git a/Whisper/ML/MlContext.cpp b/Whisper/ML/MlContext.cpp index 5a29b85..6eeae09 100644 --- a/Whisper/ML/MlContext.cpp +++ b/Whisper/ML/MlContext.cpp @@ -734,6 +734,21 @@ Tensor MlContext::mulMatByRowTiledEx( const Tensor& a, const Tensor& b ) return res; } +void MlContext::addRepeatEx( Tensor& dest, const Tensor& pattern, const Tensor& finalAdd ) +{ + if( !isSameShape( dest, finalAdd ) ) + throw E_INVALIDARG; + assert( dest.getType() == eDataType::FP32 ); + + check( cb.update( dest, pattern, finalAdd ) ); + bindShader( eComputeShader::addRepeatEx ); + cb.bind(); + + Binder bind; + bind.bind( pattern, finalAdd, dest ); + context()->Dispatch( dest.ne[ 1 ], dest.ne[ 2 ], dest.ne[ 3 ] ); +} + __m128i MlContext::getMemoryUse() const { __m128i v = cb.getMemoryUse(); -- cgit v1.2.3