mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-06-07 09:41:32 +00:00
Some checks failed
Bindings Tests (Ruby) / ubuntu-22 (push) Has been cancelled
CI / determine-tag (push) Has been cancelled
CI / ubuntu-22 (linux/amd64) (push) Has been cancelled
CI / ubuntu-22 (linux/ppc64le) (push) Has been cancelled
CI / ubuntu-22-arm64 (linux/arm64) (push) Has been cancelled
CI / ubuntu-22-arm-v7 (linux/arm/v7) (push) Has been cancelled
CI / macOS-latest (generic/platform=iOS) (push) Has been cancelled
CI / macOS-latest (generic/platform=macOS) (push) Has been cancelled
CI / macOS-latest (generic/platform=tvOS) (push) Has been cancelled
CI / ubuntu-22-gcc (linux/amd64, Debug) (push) Has been cancelled
CI / ubuntu-22-gcc (linux/amd64, Release) (push) Has been cancelled
CI / ubuntu-22-gcc (linux/ppc64le, Debug) (push) Has been cancelled
CI / ubuntu-22-gcc (linux/ppc64le, Release) (push) Has been cancelled
CI / ubuntu-22-gcc-arm64 (linux/arm64, Debug) (push) Has been cancelled
CI / ubuntu-22-gcc-arm64 (linux/arm64, Release) (push) Has been cancelled
CI / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Debug) (push) Has been cancelled
CI / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Release) (push) Has been cancelled
CI / ubuntu-22-clang (linux/amd64, Debug) (push) Has been cancelled
CI / ubuntu-22-clang (linux/amd64, Release) (push) Has been cancelled
CI / ubuntu-22-clang (linux/arm64, Debug) (push) Has been cancelled
CI / ubuntu-22-clang (linux/arm64, Release) (push) Has been cancelled
CI / ubuntu-22-clang (linux/ppc64le, Debug) (push) Has been cancelled
CI / ubuntu-22-clang (linux/ppc64le, Release) (push) Has been cancelled
CI / ubuntu-22-gcc-sanitized (linux/amd64, ADDRESS) (push) Has been cancelled
CI / ubuntu-22-gcc-sanitized (linux/amd64, THREAD) (push) Has been cancelled
CI / ubuntu-22-gcc-sanitized (linux/amd64, UNDEFINED) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl (linux/amd64, icx, icpx, ON) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl (linux/arm/v7, icx, icpx, ON) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl (linux/arm64, icx, icpx, ON) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl (linux/ppc64le, icx, icpx, ON) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl-fp16 (linux/amd64, icx, icpx, ON) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl-fp16 (linux/arm/v7, icx, icpx, ON) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl-fp16 (linux/arm64, icx, icpx, ON) (push) Has been cancelled
CI / ubuntu-22-cmake-sycl-fp16 (linux/ppc64le, icx, icpx, ON) (push) Has been cancelled
CI / windows-msys2 (Release, clang-x86_64, CLANG64) (push) Has been cancelled
CI / windows-msys2 (Release, ucrt-x86_64, UCRT64) (push) Has been cancelled
CI / windows (Win32, Release, win32-x86, x86, 2.28.5, ON) (push) Has been cancelled
CI / windows (x64, Release, win32-x86-64, x64, 2.28.5, ON) (push) Has been cancelled
CI / windows-blas (Win32, ON, x86, 0.3.29, Release, x86, 2.28.5, ON) (push) Has been cancelled
CI / windows-blas (x64, ON, x64_64, 0.3.29, Release, x64, 2.28.5, ON) (push) Has been cancelled
CI / windows-cublas (x64, Release, ON, 11.8.0, ON, 2.28.5) (push) Has been cancelled
CI / windows-cublas (x64, Release, ON, 12.2.0, ON, 2.28.5) (push) Has been cancelled
CI / emscripten (Release) (push) Has been cancelled
CI / ios-xcode-build (Release) (push) Has been cancelled
CI / android (push) Has been cancelled
CI / android_java (push) Has been cancelled
CI / bindings-java (push) Has been cancelled
CI / quantize (push) Has been cancelled
CI / release (push) Has been cancelled
CI / coreml-base-en (push) Has been cancelled
CI / vad (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-musa.Dockerfile platform:linux/amd64 tag:main-musa]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main.Dockerfile platform:linux/amd64 tag:main]) (push) Has been cancelled
Examples WASM / deploy-wasm-github-pages (push) Has been cancelled
ggml-ci
137 lines
3.9 KiB
C++
137 lines
3.9 KiB
C++
#pragma once
|
|
|
|
#include "llama-kv-cache-unified.h"
|
|
|
|
#include <vector>
|
|
|
|
//
|
|
// llama_kv_cache_unified_iswa
|
|
//
|
|
|
|
// utilizes two instances of llama_kv_cache_unified
|
|
// the first instance is for the non-SWA layers of the model and the second instance is for the SWA layers
|
|
|
|
class llama_kv_cache_unified_iswa : public llama_kv_cache {
|
|
public:
|
|
llama_kv_cache_unified_iswa(
|
|
const llama_model & model,
|
|
ggml_type type_k,
|
|
ggml_type type_v,
|
|
bool v_trans,
|
|
bool offload,
|
|
bool swa_full,
|
|
uint32_t kv_size,
|
|
uint32_t n_seq_max,
|
|
uint32_t n_ubatch,
|
|
uint32_t n_pad);
|
|
|
|
~llama_kv_cache_unified_iswa() = default;
|
|
|
|
//
|
|
// llama_memory_i
|
|
//
|
|
|
|
void clear() override;
|
|
|
|
bool seq_rm (llama_seq_id seq_id, llama_pos p0, llama_pos p1) override;
|
|
void seq_cp (llama_seq_id seq_id_src, llama_seq_id seq_id_dst, llama_pos p0, llama_pos p1) override;
|
|
void seq_keep(llama_seq_id seq_id) override;
|
|
void seq_add (llama_seq_id seq_id, llama_pos p0, llama_pos p1, llama_pos shift) override;
|
|
void seq_div (llama_seq_id seq_id, llama_pos p0, llama_pos p1, int d) override;
|
|
|
|
llama_pos seq_pos_min(llama_seq_id seq_id) const override;
|
|
llama_pos seq_pos_max(llama_seq_id seq_id) const override;
|
|
|
|
//
|
|
// llama_kv_cache
|
|
//
|
|
|
|
llama_memory_state_ptr init_batch(
|
|
const llama_batch & batch,
|
|
uint32_t n_ubatch,
|
|
bool embd_pooled,
|
|
bool logits_all) override;
|
|
|
|
llama_memory_state_ptr init_full() override;
|
|
|
|
bool update(llama_context & lctx) override;
|
|
|
|
void defrag_sched(float thold) override;
|
|
|
|
bool get_can_shift() const override;
|
|
|
|
// state write/load
|
|
|
|
void state_write(llama_io_write_i & io, llama_seq_id seq_id = -1) const override;
|
|
void state_read (llama_io_read_i & io, llama_seq_id seq_id = -1) override;
|
|
|
|
//
|
|
// llama_kv_cache_unified_iswa specific API
|
|
//
|
|
|
|
llama_kv_cache_unified * get_base() const;
|
|
llama_kv_cache_unified * get_swa () const;
|
|
|
|
private:
|
|
const llama_hparams & hparams;
|
|
|
|
std::unique_ptr<llama_kv_cache_unified> kv_base;
|
|
std::unique_ptr<llama_kv_cache_unified> kv_swa;
|
|
};
|
|
|
|
class llama_kv_cache_unified_iswa_state : public llama_memory_state_i {
|
|
public:
|
|
// used for errors
|
|
llama_kv_cache_unified_iswa_state(llama_memory_status status);
|
|
|
|
// used to create a full-cache state
|
|
llama_kv_cache_unified_iswa_state(
|
|
llama_memory_status status,
|
|
llama_kv_cache_unified_iswa * kv);
|
|
|
|
// used to create a state from a batch
|
|
llama_kv_cache_unified_iswa_state(
|
|
llama_memory_status status,
|
|
llama_kv_cache_unified_iswa * kv,
|
|
llama_sbatch sbatch,
|
|
std::vector<uint32_t> heads_base,
|
|
std::vector<uint32_t> heads_swa,
|
|
std::vector<llama_ubatch> ubatches);
|
|
|
|
virtual ~llama_kv_cache_unified_iswa_state();
|
|
|
|
//
|
|
// llama_memory_state_i
|
|
//
|
|
|
|
bool next() override;
|
|
bool apply() override;
|
|
|
|
std::vector<int64_t> & out_ids() override;
|
|
|
|
llama_memory_status get_status() const override;
|
|
const llama_ubatch & get_ubatch() const override;
|
|
|
|
//
|
|
// llama_kv_cache_unified_iswa_state specific API
|
|
//
|
|
|
|
const llama_kv_cache_unified_state * get_base() const;
|
|
const llama_kv_cache_unified_state * get_swa() const;
|
|
|
|
private:
|
|
const llama_memory_status status;
|
|
|
|
//llama_kv_cache_unified_iswa * kv;
|
|
|
|
llama_sbatch sbatch;
|
|
|
|
// the index of the next ubatch to process
|
|
size_t i_next = 0;
|
|
|
|
std::vector<llama_ubatch> ubatches;
|
|
|
|
std::unique_ptr<llama_kv_cache_unified_state> state_base;
|
|
std::unique_ptr<llama_kv_cache_unified_state> state_swa;
|
|
};
|