Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
35496766
Commit
35496766
authored
Jul 26, 2023
by
Michael Yang
Browse files
embed ggml-metal.metal
parent
8fa477fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
1 deletion
+57
-1
ggml-metal.metal
ggml-metal.metal
+0
-1
llama/llama.go
llama/llama.go
+4
-0
llama/llama_darwin.go
llama/llama_darwin.go
+53
-0
No files found.
ggml-metal.metal
deleted
120000 → 0
View file @
8fa477fa
llama/ggml-metal.metal
\ No newline at end of file
llama/llama.go
View file @
35496766
...
@@ -86,6 +86,7 @@ llama_token llama_sample(
...
@@ -86,6 +86,7 @@ llama_token llama_sample(
import
"C"
import
"C"
import
(
import
(
"bytes"
"bytes"
"embed"
"errors"
"errors"
"fmt"
"fmt"
"io"
"io"
...
@@ -99,6 +100,9 @@ import (
...
@@ -99,6 +100,9 @@ import (
"github.com/jmorganca/ollama/api"
"github.com/jmorganca/ollama/api"
)
)
//go:embed ggml-metal.metal
var
fs
embed
.
FS
type
LLM
struct
{
type
LLM
struct
{
params
*
C
.
struct_llama_context_params
params
*
C
.
struct_llama_context_params
model
*
C
.
struct_llama_model
model
*
C
.
struct_llama_model
...
...
llama/llama_darwin.go
0 → 100644
View file @
35496766
package
llama
import
(
"errors"
"io"
"log"
"os"
"path/filepath"
)
func
init
()
{
if
err
:=
initBackend
();
err
!=
nil
{
log
.
Printf
(
"WARNING: GPU could not be initialized correctly: %v"
,
err
)
log
.
Printf
(
"WARNING: falling back to CPU"
)
}
}
func
initBackend
()
error
{
exec
,
err
:=
os
.
Executable
()
if
err
!=
nil
{
return
err
}
exec
,
err
=
filepath
.
EvalSymlinks
(
exec
)
if
err
!=
nil
{
return
err
}
metal
:=
filepath
.
Join
(
filepath
.
Dir
(
exec
),
"ggml-metal.metal"
)
if
_
,
err
:=
os
.
Stat
(
metal
);
err
!=
nil
{
if
!
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
return
err
}
dst
,
err
:=
os
.
Create
(
filepath
.
Join
(
filepath
.
Dir
(
exec
),
"ggml-metal.metal"
))
if
err
!=
nil
{
return
err
}
defer
dst
.
Close
()
src
,
err
:=
fs
.
Open
(
"ggml-metal.metal"
)
if
err
!=
nil
{
return
err
}
defer
src
.
Close
()
if
_
,
err
:=
io
.
Copy
(
dst
,
src
);
err
!=
nil
{
return
err
}
}
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment