mirror of
https://github.com/ollama/ollama.git
synced 2025-05-11 02:16:36 +02:00
ml/backend/ggml: create tensor on specific backend
some tensors should be created on specific backends to reduce number of copies and improve performance
This commit is contained in:
parent
764e199d67
commit
7bae7fa5ce
6 changed files with 129 additions and 60 deletions
|
@ -24,6 +24,7 @@ type Backend interface {
|
|||
Config() Config
|
||||
Get(name string) Tensor
|
||||
NewContext() Context
|
||||
NewContextSize(size int) Context
|
||||
}
|
||||
|
||||
// BackendCacheConfig should be implemented by backends that need special output
|
||||
|
@ -101,6 +102,15 @@ type Context interface {
|
|||
Compute(...Tensor)
|
||||
MaxGraphNodes() int
|
||||
Close()
|
||||
|
||||
// Input returns a context appropriate for creating input tensors
|
||||
Input() Context
|
||||
|
||||
// Output returns a context appropriate for creating output tensors
|
||||
Output() Context
|
||||
|
||||
// Layer returns a context appropriate for creating intermediate tensors
|
||||
Layer(int) Context
|
||||
}
|
||||
|
||||
type Tensor interface {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue