12
12
13
13
## Adding a New Package
14
14
15
- Here is adding ` MLXFFT ` :
15
+ Here is adding ` MLXOptimizers ` :
16
16
17
17
1 . ` Package.swift ` add a new product (for anything that should be exported) and target:
18
18
19
19
```
20
20
products: [
21
21
...
22
- .library(name: "MLXFFT ", targets: ["MLXFFT "]),
22
+ .library(name: "MLXOptimizers ", targets: ["MLXOptimizers "]),
23
23
```
24
24
25
25
```
26
26
targets: [
27
27
...
28
28
.target(
29
- name: "MLXFFT ",
29
+ name: "MLXOptimizers ",
30
30
dependencies: ["MLX"]
31
31
),
32
32
```
@@ -36,18 +36,17 @@ add to MLXTests:
36
36
```
37
37
.testTarget(
38
38
name: "MLXTests",
39
- dependencies: ["MLX", "MLXRandom", " MLXNN", "MLXOptimizers", "MLXFFT "]
39
+ dependencies: ["MLX", "MLXNN", "MLXOptimizers"]
40
40
),
41
41
```
42
42
43
-
44
43
2 . Update ` CMakeLists `
45
-
44
+
46
45
```
47
- # MLXFFT package
48
- file(GLOB MLXFFT -src ${CMAKE_CURRENT_LIST_DIR}/Source/MLXFFT /*.swift)
49
- add_library(MLXFFT STATIC ${MLXFFT -src})
50
- target_link_libraries(MLXFFT PRIVATE MLX)
46
+ # MLXOptimizers package
47
+ file(GLOB MLXOptimizers -src ${CMAKE_CURRENT_LIST_DIR}/Source/MLXOptimizers /*.swift)
48
+ add_library(MLXOptimizers STATIC ${MLXOptimizers -src})
49
+ target_link_libraries(MLXOptimizers PRIVATE MLX)
51
50
```
52
51
53
52
3 . Create directory in ` Source `
@@ -56,18 +55,13 @@ target_link_libraries(MLXFFT PRIVATE MLX)
56
55
57
56
5 . Add source files and documentation
58
57
59
- 6 . Add linkage to the other documentation, e.g. in ` MLXFFT .md`
58
+ 6 . Add linkage to the other documentation, e.g. in ` MLXOptimizers .md`
60
59
61
60
```
62
61
## Other MLX Packages
63
62
64
63
- [MLX](mlx)
65
- - [MLXRandom](mlxrandom)
66
64
- [MLXNN](mlxnn)
67
- - [MLXOptimizers](mlxoptimizers)
68
- - [MLXFFT](mlxfft)
69
- - [MLXLinalg](mlxlinalg)
70
- - [MLXFast](mlxfast)
71
65
72
66
- [Python `mlx`](https://ml-explore.github.io/mlx/build/html/index.html)
73
67
```
@@ -78,27 +72,23 @@ target_link_libraries(MLXFFT PRIVATE MLX)
78
72
## Other MLX Packages
79
73
80
74
...
81
- - [MLXFFT ](../mlxfft /)
75
+ - [MLXOptimizers ](../mlxoptimizers /)
82
76
```
83
77
84
78
8 . Update README.md
85
79
86
80
```
87
81
dependencies: [.product(name: "MLX", package: "mlx-swift"),
88
- .product(name: "MLXRandom", package: "mlx-swift"),
89
82
.product(name: "MLXNN", package: "mlx-swift"),
90
- .product(name: "MLXOptimizers", package: "mlx-swift"),
91
- .product(name: "MLXFFT", package: "mlx-swift")]
83
+ .product(name: "MLXOptimizers", package: "mlx-swift")]
92
84
```
93
85
94
86
9 . Update install.md
95
87
96
88
```
97
89
dependencies: [.product(name: "MLX", package: "mlx-swift"),
98
- .product(name: "MLXRandom", package: "mlx-swift"),
99
90
.product(name: "MLXNN", package: "mlx-swift"),
100
- .product(name: "MLXOptimizers", package: "mlx-swift"),
101
- .product(name: "MLXFFT", package: "mlx-swift")]
91
+ .product(name: "MLXOptimizers", package: "mlx-swift")]
102
92
```
103
93
104
94
10 . Update ` tools/generate_integration_tests.py ` as needed
@@ -113,7 +103,7 @@ import MLXNN
113
103
12 . Update ` tools/build-documentation.sh `
114
104
115
105
```
116
- for x in MLX MLXRandom MLXNN MLXOptimizers MLXFFT ; do
106
+ for x in MLX MLXNN MLXOptimizers; do
117
107
```
118
108
119
109
13 . Add to ` .spi.yml ` for swift package index
@@ -129,25 +119,24 @@ pre-commit run --all-files
129
119
## Updating ` mlx ` and ` mlx-c `
130
120
131
121
SwiftPM is able to fetch repositories from github and build them _ if_ they have
132
- a ` Package.swift ` at the top level. It is unable to do this for repositories
133
- that do not have a ` Package.swift ` . For this reason ` mlx-swift ` uses
122
+ a ` Package.swift ` at the top level. It is unable to do this for repositories
123
+ that do not have a ` Package.swift ` . For this reason ` mlx-swift ` uses
134
124
git submodules to include the ` mlx ` and ` mlx-c ` repositories.
135
125
136
126
When a new version of ` mlx ` and its equivalent ` mlx-c ` are to be used, there is a
137
127
process to go through to update ` mlx-swift ` .
138
128
139
129
Additionally, SwiftPM supports plugins that can produce derived source for
140
- building, but this can only produce new swift source. It is possible to use
130
+ building, but this can only produce new swift source. It is possible to use
141
131
plugins to generate new source ` .cpp ` files and even compile them, but at
142
132
best the ` .o ` is copied into the output as a resource, not linked.
143
133
This is important because ` mlx ` has some build-time source generation
144
- (e.g. ` make_compiled_preamble.sh ` ). This is handled in ` mlx-swift ` by
134
+ (e.g. ` make_compiled_preamble.sh ` ). This is handled in ` mlx-swift ` by
145
135
pre-generating the source when updating the ` mlx ` version.
146
136
147
137
1 . Update the ` mlx ` and ` mlx-c ` submodules via ` git pull ` or ` git checkout ... `
148
- - ` Source/Cmlx/mlx `
149
- - ` Source/Cmlx/mlx-c `
150
-
138
+ - ` Source/Cmlx/mlx `
139
+ - ` Source/Cmlx/mlx-c `
151
140
2 . Add any vendored dependencies as needed in ` /vendor `
152
141
153
142
3 . Regenerate any build-time source: ` ./tools/update-mlx.sh `
0 commit comments