Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions gomlx/backend.go → coreml/gomlx/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"
"sync"

"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-coreml/runtime"
"github.com/gomlx/go-darwinml/coreml/model"
"github.com/gomlx/go-darwinml/coreml/runtime"
"github.com/gomlx/gomlx/backends"
"github.com/pkg/errors"
)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion gomlx/builder.go → coreml/gomlx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"reflect"

"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/coreml/model"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/backends/notimplemented"
"github.com/gomlx/gomlx/pkg/core/dtypes"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion gomlx/executable.go → coreml/gomlx/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"sync"

"github.com/gomlx/go-coreml/runtime"
"github.com/gomlx/go-darwinml/coreml/runtime"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/pkg/core/shapes"
"github.com/pkg/errors"
Expand Down
2 changes: 1 addition & 1 deletion gomlx/function.go → coreml/gomlx/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"math"
"slices"

"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/coreml/model"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/backends/notimplemented"
"github.com/gomlx/gomlx/backends/shapeinference"
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions gomlx/go.mod → coreml/gomlx/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/gomlx/go-coreml/gomlx
module github.com/gomlx/go-darwinml/coreml/gomlx

go 1.26.0

require (
github.com/gomlx/go-coreml v0.0.0-20260218230850-b757a40d32e7
github.com/gomlx/gomlx v0.26.1-0.20260220075116-8da82ca8aaad
github.com/gomlx/go-darwinml v0.0.0-20260218230850-b757a40d32e7
github.com/gomlx/gomlx v0.27.0
github.com/pkg/errors v0.9.1
)

Expand All @@ -15,7 +15,7 @@ require (
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect
google.golang.org/protobuf v1.36.11 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/klog/v2 v2.140.0 // indirect
)

replace github.com/gomlx/go-coreml => ../
replace github.com/gomlx/go-darwinml => ../../
7 changes: 7 additions & 0 deletions gomlx/go.sum → coreml/gomlx/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0=
github.com/gomlx/go-xla v0.1.5-0.20260219173412-338774b2e7a7 h1:lZSXhh4/1962rXKwEvnhkRPYXPFe0zWn57JzZaQgEOQ=
github.com/gomlx/go-xla v0.1.5-0.20260219173412-338774b2e7a7/go.mod h1:gwv58mA3ih33rgue4CuZ/ERxj5P2ZKKSFaD0s6Rt090=
github.com/gomlx/go-xla v0.2.0 h1:vPRgGjKUaN4Pq58ZswWtiKNGUkqcbUj95YmvELZNvTA=
github.com/gomlx/gomlx v0.26.1-0.20260220075116-8da82ca8aaad h1:5sVrSlklIfVDaAm4GhfHHIkmeNeWgifI0T5OeoFP//c=
github.com/gomlx/gomlx v0.26.1-0.20260220075116-8da82ca8aaad/go.mod h1:qh8htE4nkodsshIvgIiqkwW2IIzbOkJBT3QXI4i93Z8=
github.com/gomlx/gomlx v0.27.0 h1:tkmzft4WR+6oncPUT4jCHQYtfW2r6QkfFxUEBy7RmxA=
github.com/gomlx/gomlx v0.27.0/go.mod h1:9fOMnTb7YMs/6zYVR6diliq25x9oSjMUPMlHAbcJWd4=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand All @@ -26,11 +29,15 @@ golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa h1:Zt3DZoOFFYkKhDT3v7Lm9FDME
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc=
k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0=
2 changes: 1 addition & 1 deletion gomlx/int_ops_test.go → coreml/gomlx/int_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package coreml
import (
"testing"

"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/coreml/model"
"github.com/gomlx/gomlx/pkg/core/dtypes"
"github.com/gomlx/gomlx/pkg/core/graph"
"github.com/gomlx/gomlx/pkg/core/shapes"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion model/builder.go → coreml/model/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package model
import (
"fmt"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
)

// DType represents a data type for tensors.
Expand Down
2 changes: 1 addition & 1 deletion model/builder_test.go → coreml/model/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"testing"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
"google.golang.org/protobuf/proto"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model_test
import (
"fmt"

"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/coreml/model"
)

// ExampleBuilder_Concat demonstrates concatenating multiple tensors along an axis.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model_test
import (
"fmt"

"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/coreml/model"
)

// ExampleBuilder_Einsum demonstrates how to use the Einsum operation for
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"testing"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
)

func TestConcat(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"fmt"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
)

// BlockBuilder builds a nested block within an operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"testing"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
)

func TestBlockBuilder_BasicOps(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"testing"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
)

func TestEinsumRank4(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion model/ops_range_test.go → coreml/model/ops_range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"testing"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
)

func TestRange1D(t *testing.T) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion model/optimize.go → coreml/model/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"sort"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
)

// optimizeHighRankOps applies optimization passes to eliminate operations
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions model/serialize.go → coreml/model/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"path/filepath"

"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-coreml/proto/coreml/spec"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/spec"
"github.com/google/uuid"
"google.golang.org/protobuf/proto"
)
Expand Down
6 changes: 3 additions & 3 deletions model/serialize_blob.go → coreml/model/serialize_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"path/filepath"

"github.com/google/uuid"
"github.com/gomlx/go-coreml/blob"
"github.com/gomlx/go-coreml/proto/coreml/milspec"
"github.com/gomlx/go-coreml/proto/coreml/spec"
"github.com/gomlx/go-darwinml/blob"
"github.com/gomlx/go-darwinml/proto/coreml/milspec"
"github.com/gomlx/go-darwinml/proto/coreml/spec"
"google.golang.org/protobuf/proto"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"testing"

"github.com/gomlx/go-coreml/blob"
"github.com/gomlx/go-darwinml/blob"
)

func TestSaveMLPackageWithBlobs(t *testing.T) {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions runtime/blob_e2e_test.go → coreml/runtime/blob_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"path/filepath"
"testing"

"github.com/gomlx/go-coreml/blob"
"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/blob"
"github.com/gomlx/go-darwinml/coreml/model"
)

func TestBlobStorageE2E(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions runtime/runtime.go → coreml/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"sync"
"unsafe"

"github.com/gomlx/go-coreml/internal/bridge"
"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/coreml/internal/bridge"
"github.com/gomlx/go-darwinml/coreml/model"
)

// Runtime manages CoreML model compilation and execution.
Expand Down
4 changes: 2 additions & 2 deletions runtime/runtime_test.go → coreml/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package runtime
import (
"testing"

"github.com/gomlx/go-coreml/internal/bridge"
"github.com/gomlx/go-coreml/model"
"github.com/gomlx/go-darwinml/coreml/internal/bridge"
"github.com/gomlx/go-darwinml/coreml/model"
)

// skipIfNotMacOS skips the test if not running on macOS.
Expand Down
57 changes: 11 additions & 46 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,56 +1,21 @@
// Package gocoreml provides Go bindings to Apple's CoreML framework.
// Package godarwinml provides Go backends for machine learning on Apple Silicon.
//
// This package enables running machine learning models on Apple's Neural Engine (ANE),
// Metal GPU, and CPU. It is designed to be used as a backend for GoMLX, providing
// high-performance inference on Apple Silicon.
// This project provides multiple GoMLX backends targeting Apple hardware:
//
// # Architecture
// - coreml: CoreML backend supporting Apple Neural Engine (ANE), Metal GPU, and CPU
// - mpsgraph: MPSGraph backend for direct Metal GPU computation
//
// The package is organized into several sub-packages:
// Each backend implements the GoMLX backends.Backend interface and can be used
// interchangeably for inference on Apple Silicon.
//
// - internal/bridge: Low-level cgo bindings to CoreML via Objective-C++
// - model: High-level model building and management
// - runtime: Model loading and execution
// - ops: MIL (Model Intermediate Language) operation builders
// # Shared Packages
//
// # Usage
//
// This package is primarily intended to be used through the GoMLX CoreML backend.
// Direct usage is also possible for loading and running pre-built CoreML models:
//
// import "github.com/gomlx/go-coreml/runtime"
//
// model, err := runtime.LoadModel("path/to/model.mlmodelc")
// if err != nil {
// log.Fatal(err)
// }
// defer model.Close()
//
// // Create input tensor
// input := runtime.NewTensor([]int64{1, 3, 224, 224}, runtime.Float32)
// // ... fill input data ...
//
// // Run inference
// output, err := model.Predict(map[string]*runtime.Tensor{"input": input})
// if err != nil {
// log.Fatal(err)
// }
// - blob: Weight blob storage format
// - proto: CoreML protobuf specifications
//
// # Requirements
//
// - macOS 12.0+ (Monterey or later)
// - Xcode Command Line Tools
// - Go 1.21+
//
// # Compute Units
//
// CoreML can run on different compute units:
//
// - All: Let CoreML decide (default, usually best performance)
// - CPU Only: Force CPU-only execution
// - CPU and GPU: Use CPU and Metal GPU
// - CPU and ANE: Use CPU and Apple Neural Engine
//
// The Neural Engine (ANE) provides the best performance and power efficiency
// for supported operations on Apple Silicon.
package gocoreml
// - Go 1.25+
package godarwinml
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/gomlx/go-coreml
module github.com/gomlx/go-darwinml

go 1.25.5

Expand Down
2 changes: 1 addition & 1 deletion mpsgraph/gomlx/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package mpsgraph
import (
"sync"

"github.com/gomlx/go-coreml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/go-darwinml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/pkg/core/shapes"
"github.com/pkg/errors"
Expand Down
2 changes: 1 addition & 1 deletion mpsgraph/gomlx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package mpsgraph

import (
"github.com/gomlx/go-coreml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/go-darwinml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/backends/notimplemented"
"github.com/gomlx/gomlx/pkg/core/shapes"
Expand Down
2 changes: 1 addition & 1 deletion mpsgraph/gomlx/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"
"unsafe"

"github.com/gomlx/go-coreml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/go-darwinml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/pkg/core/shapes"
"github.com/pkg/errors"
Expand Down
3 changes: 2 additions & 1 deletion mpsgraph/gomlx/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"runtime"
"unsafe"

"github.com/gomlx/go-coreml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/go-darwinml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/backends/notimplemented"
"github.com/gomlx/gomlx/backends/shapeinference"
Expand Down Expand Up @@ -2672,6 +2672,7 @@ func (f *Function) FusedScaledDotProductAttention(
axesLayout backends.AxesLayout,
scale float64,
causal bool,
options *backends.ScaledDotProductAttentionConfig,
) (backends.Value, error) {
qNode, err := f.resolveNode(query)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion mpsgraph/gomlx/gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package mpsgraph
import (
"slices"

"github.com/gomlx/go-coreml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/go-darwinml/mpsgraph/gomlx/internal/bridge"
"github.com/gomlx/gomlx/backends"
"github.com/gomlx/gomlx/backends/shapeinference"
"github.com/gomlx/gomlx/pkg/core/shapes"
Expand Down
2 changes: 1 addition & 1 deletion mpsgraph/gomlx/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/gomlx/go-coreml/mpsgraph/gomlx
module github.com/gomlx/go-darwinml/mpsgraph/gomlx

go 1.25

Expand Down
Loading