From 79e0620891bf6b5c0675232ab3f374d61dddc2fa Mon Sep 17 00:00:00 2001 From: David Koski Date: Fri, 1 Mar 2024 15:55:36 -0800 Subject: [PATCH] add MNIST training example --- .circleci/config.yml | 1 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 63 ++++ .../Assets.xcassets/Contents.json | 6 + Applications/MNISTTrainer/ContentView.swift | 116 +++++++ .../MNISTTrainer/MNISTTrainer-Info.plist | 17 + .../MNISTTrainer/MNISTTrainer.entitlements | 12 + .../MNISTTrainer/MNISTTrainerApp.swift | 12 + .../Preview Assets.xcassets/Contents.json | 6 + Applications/MNISTTrainer/README.md | 13 + mlx-swift-examples.xcodeproj/project.pbxproj | 320 +++++++++++++++++- 11 files changed, 576 insertions(+), 1 deletion(-) create mode 100644 Applications/MNISTTrainer/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 Applications/MNISTTrainer/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Applications/MNISTTrainer/Assets.xcassets/Contents.json create mode 100644 Applications/MNISTTrainer/ContentView.swift create mode 100644 Applications/MNISTTrainer/MNISTTrainer-Info.plist create mode 100644 Applications/MNISTTrainer/MNISTTrainer.entitlements create mode 100644 Applications/MNISTTrainer/MNISTTrainerApp.swift create mode 100644 Applications/MNISTTrainer/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 Applications/MNISTTrainer/README.md diff --git a/.circleci/config.yml b/.circleci/config.yml index 328335c..a145b10 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,6 +37,7 @@ jobs: find . -name Package.resolved -exec rm {} \; xcodebuild -skipPackagePluginValidation -scheme llm-tool xcodebuild -skipPackagePluginValidation -scheme mnist-tool + xcodebuild -skipPackagePluginValidation -scheme MNISTTrainer workflows: build_and_test: diff --git a/Applications/MNISTTrainer/Assets.xcassets/AccentColor.colorset/Contents.json b/Applications/MNISTTrainer/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Applications/MNISTTrainer/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Applications/MNISTTrainer/Assets.xcassets/AppIcon.appiconset/Contents.json b/Applications/MNISTTrainer/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..532cd72 --- /dev/null +++ b/Applications/MNISTTrainer/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,63 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Applications/MNISTTrainer/Assets.xcassets/Contents.json b/Applications/MNISTTrainer/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Applications/MNISTTrainer/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Applications/MNISTTrainer/ContentView.swift b/Applications/MNISTTrainer/ContentView.swift new file mode 100644 index 0000000..b9fd4ee --- /dev/null +++ b/Applications/MNISTTrainer/ContentView.swift @@ -0,0 +1,116 @@ +// Copyright © 2024 Apple Inc. + +import MLX +import MLXNN +import MLXOptimizers +import MLXRandom +import MNIST +import SwiftUI + +struct ContentView: View { + + // the training loop + @State var trainer = Trainer() + + // toggle for cpu/gpu training + @State var cpu = true + + var body: some View { + VStack { + Spacer() + + ScrollView(.vertical) { + ForEach(trainer.messages, id: \.self) { + Text($0) + } + } + + HStack { + Spacer() + + Button("Train") { + Task { + try! await trainer.run(device: cpu ? .cpu : .gpu) + } + } + + Toggle("CPU", isOn: $cpu) + .frame(maxWidth: 150) + + Spacer() + } + Spacer() + } + .padding() + } +} + +@Observable +class Trainer { + + var messages = [String]() + + func run(device: Device = .cpu) async throws { + // Note: this is pretty close to the code in `mnist-tool`, just + // wrapped in an Observable to make it easy to display in SwiftUI + + Device.setDefault(device: device) + + // download & load the training data + let url = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) + try await download(into: url) + let data = try load(from: url) + + let trainImages = data[.init(.training, .images)]! + let trainLabels = data[.init(.training, .labels)]! + let testImages = data[.init(.test, .images)]! + let testLabels = data[.init(.test, .labels)]! + + // create the model with random weights + let model = MLP( + layers: 2, inputDimensions: trainImages.dim(-1), hiddenDimensions: 32, + outputDimensions: 10) + eval(model.parameters()) + + // the training loop + let lg = valueAndGrad(model: model, loss) + let optimizer = SGD(learningRate: 0.1) + + // using a consistent random seed so it behaves the same way each time + MLXRandom.seed(0) + var generator: RandomNumberGenerator = SplitMix64(seed: 0) + + for e in 0 ..< 10 { + let start = Date.timeIntervalSinceReferenceDate + + for (x, y) in iterateBatches( + batchSize: 256, x: trainImages, y: trainLabels, using: &generator) + { + // loss and gradients + let (_, grads) = lg(model, x, y) + + // use SGD to update the weights + optimizer.update(model: model, gradients: grads) + + // eval the parameters so the next iteration is independent + eval(model, optimizer) + } + + let accuracy = eval(model: model, x: testImages, y: testLabels) + + let end = Date.timeIntervalSinceReferenceDate + + // add to messages -- triggers display + await MainActor.run { + messages.append( + """ + Epoch \(e): test accuracy \(accuracy.item(Float.self).formatted()) + Time: \((end - start).formatted()) + + """ + ) + } + } + + } +} diff --git a/Applications/MNISTTrainer/MNISTTrainer-Info.plist b/Applications/MNISTTrainer/MNISTTrainer-Info.plist new file mode 100644 index 0000000..2ad835b --- /dev/null +++ b/Applications/MNISTTrainer/MNISTTrainer-Info.plist @@ -0,0 +1,17 @@ + + + + + NSAppTransportSecurity + + NSExceptionDomains + + yann.lecun.com + + NSExceptionAllowsInsecureHTTPLoads + + + + + + diff --git a/Applications/MNISTTrainer/MNISTTrainer.entitlements b/Applications/MNISTTrainer/MNISTTrainer.entitlements new file mode 100644 index 0000000..625af03 --- /dev/null +++ b/Applications/MNISTTrainer/MNISTTrainer.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + com.apple.security.network.client + + + diff --git a/Applications/MNISTTrainer/MNISTTrainerApp.swift b/Applications/MNISTTrainer/MNISTTrainerApp.swift new file mode 100644 index 0000000..b2bbba1 --- /dev/null +++ b/Applications/MNISTTrainer/MNISTTrainerApp.swift @@ -0,0 +1,12 @@ +// Copyright © 2024 Apple Inc. + +import SwiftUI + +@main +struct MNISTTrainerApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/Applications/MNISTTrainer/Preview Content/Preview Assets.xcassets/Contents.json b/Applications/MNISTTrainer/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Applications/MNISTTrainer/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Applications/MNISTTrainer/README.md b/Applications/MNISTTrainer/README.md new file mode 100644 index 0000000..04e2b83 --- /dev/null +++ b/Applications/MNISTTrainer/README.md @@ -0,0 +1,13 @@ +# MNISTTrainer + +This is an example showing how to do model training on both macOS and iOS. +This will download the MNIST training data, create a new models and train +it. It will show the timing per epoch and the test accuracy as it trains. + +You will need to set the Team on the MNISTTrainer target in order to build and +run on iOS. + +Some notes about the setup: + +- this will download test data over the network so MNISTTrainer -> Signing & Capabilities has the "Outgoing Connections (Client)" set in the App Sandbox +- the website it connects to uses http rather than https so it has a "App Transport Security Settings" in the Info.plist diff --git a/mlx-swift-examples.xcodeproj/project.pbxproj b/mlx-swift-examples.xcodeproj/project.pbxproj index ce8ac4d..75d9632 100644 --- a/mlx-swift-examples.xcodeproj/project.pbxproj +++ b/mlx-swift-examples.xcodeproj/project.pbxproj @@ -37,6 +37,15 @@ C3932D592B6A0BE400A81055 /* Random.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3932D582B6A0BE400A81055 /* Random.swift */; }; C397C59C2B62C6D0004B084D /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = C397C59B2B62C6D0004B084D /* ArgumentParser */; }; C3A8B3AC2B9283150002EFB8 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A8B3AB2B9283150002EFB8 /* Models.swift */; }; + C3A8B3CA2B92951E0002EFB8 /* MNISTTrainer-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C3A8B3C22B92951E0002EFB8 /* MNISTTrainer-Info.plist */; }; + C3A8B3CB2B92951E0002EFB8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3A8B3C32B92951E0002EFB8 /* Assets.xcassets */; }; + C3A8B3CC2B92951E0002EFB8 /* MNISTTrainerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A8B3C42B92951E0002EFB8 /* MNISTTrainerApp.swift */; }; + C3A8B3CD2B92951E0002EFB8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3A8B3C62B92951E0002EFB8 /* Preview Assets.xcassets */; }; + C3A8B3CE2B92951E0002EFB8 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = C3A8B3C82B92951E0002EFB8 /* README.md */; }; + C3A8B3CF2B92951E0002EFB8 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A8B3C92B92951E0002EFB8 /* ContentView.swift */; }; + C3A8B3D22B92A0880002EFB8 /* MLXOptimizers in Frameworks */ = {isa = PBXBuildFile; productRef = C3A8B3D12B92A0880002EFB8 /* MLXOptimizers */; }; + C3A8B3D32B92A0880002EFB8 /* MNIST.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C34E490D2B69A92900FCB841 /* MNIST.framework */; }; + C3A8B3D42B92A0880002EFB8 /* MNIST.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C34E490D2B69A92900FCB841 /* MNIST.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C3E786AB2B8D1AEC0004D037 /* Evaluate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E786AA2B8D1AEC0004D037 /* Evaluate.swift */; }; C3E786AD2B8D4AF50004D037 /* Tokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E786AC2B8D4AF50004D037 /* Tokenizer.swift */; }; C3FBCB212B8520B80007E490 /* MLX in Frameworks */ = {isa = PBXBuildFile; productRef = C3FBCB202B8520B80007E490 /* MLX */; }; @@ -64,6 +73,13 @@ remoteGlobalIDString = C38935C42B869C7A0037B833; remoteInfo = LLM; }; + C3A8B3D52B92A0880002EFB8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C39273682B60697700368D5D /* Project object */; + proxyType = 1; + remoteGlobalIDString = C34E490C2B69A92900FCB841; + remoteInfo = MNIST; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -125,6 +141,17 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + C3A8B3D72B92A0880002EFB8 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + C3A8B3D42B92A0880002EFB8 /* MNIST.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -154,6 +181,15 @@ C3932D582B6A0BE400A81055 /* Random.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Random.swift; sourceTree = ""; }; C397C58B2B62C6A9004B084D /* llm-tool */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "llm-tool"; sourceTree = BUILT_PRODUCTS_DIR; }; C3A8B3AB2B9283150002EFB8 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = ""; }; + C3A8B3B22B9295090002EFB8 /* MNISTTrainer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MNISTTrainer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C3A8B3C22B92951E0002EFB8 /* MNISTTrainer-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "MNISTTrainer-Info.plist"; sourceTree = ""; }; + C3A8B3C32B92951E0002EFB8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C3A8B3C42B92951E0002EFB8 /* MNISTTrainerApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MNISTTrainerApp.swift; sourceTree = ""; }; + C3A8B3C62B92951E0002EFB8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + C3A8B3C72B92951E0002EFB8 /* MNISTTrainer.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = MNISTTrainer.entitlements; sourceTree = ""; }; + C3A8B3C82B92951E0002EFB8 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + C3A8B3C92B92951E0002EFB8 /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + C3A8B3D02B929F400002EFB8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = MNISTTrainer/Info.plist; sourceTree = ""; }; C3C3240B2B6CA689007D2D9A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; C3C3240C2B6CA792007D2D9A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; C3E786AA2B8D1AEC0004D037 /* Evaluate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Evaluate.swift; sourceTree = ""; }; @@ -223,6 +259,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C3A8B3AF2B9295090002EFB8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3A8B3D32B92A0880002EFB8 /* MNIST.framework in Frameworks */, + C3A8B3D22B92A0880002EFB8 /* MLXOptimizers in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -286,8 +331,10 @@ C39273672B60697700368D5D = { isa = PBXGroup; children = ( + C3A8B3D02B929F400002EFB8 /* Info.plist */, C325DE3F2B648CDB00628871 /* README.md */, C39273822B606A9200368D5D /* Libraries */, + C3A8B3AD2B9294E30002EFB8 /* Applications */, C39273812B606A7400368D5D /* Tools */, C39273752B606A0A00368D5D /* Products */, C392737E2B606A2C00368D5D /* Frameworks */, @@ -303,6 +350,7 @@ C34E49212B6A026F00FCB841 /* mnist-tool */, C3288D732B6D9313009FF608 /* LinearModelTraining */, C38935C52B869C7A0037B833 /* LLM.framework */, + C3A8B3B22B9295090002EFB8 /* MNISTTrainer.app */, ); name = Products; sourceTree = ""; @@ -342,6 +390,36 @@ path = Libraries; sourceTree = ""; }; + C3A8B3AD2B9294E30002EFB8 /* Applications */ = { + isa = PBXGroup; + children = ( + C3A8B3C12B92951E0002EFB8 /* MNISTTrainer */, + ); + path = Applications; + sourceTree = ""; + }; + C3A8B3C12B92951E0002EFB8 /* MNISTTrainer */ = { + isa = PBXGroup; + children = ( + C3A8B3C32B92951E0002EFB8 /* Assets.xcassets */, + C3A8B3C92B92951E0002EFB8 /* ContentView.swift */, + C3A8B3C22B92951E0002EFB8 /* MNISTTrainer-Info.plist */, + C3A8B3C72B92951E0002EFB8 /* MNISTTrainer.entitlements */, + C3A8B3C42B92951E0002EFB8 /* MNISTTrainerApp.swift */, + C3A8B3C52B92951E0002EFB8 /* Preview Content */, + C3A8B3C82B92951E0002EFB8 /* README.md */, + ); + path = MNISTTrainer; + sourceTree = ""; + }; + C3A8B3C52B92951E0002EFB8 /* Preview Content */ = { + isa = PBXGroup; + children = ( + C3A8B3C62B92951E0002EFB8 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -502,6 +580,28 @@ productReference = C397C58B2B62C6A9004B084D /* llm-tool */; productType = "com.apple.product-type.tool"; }; + C3A8B3B12B9295090002EFB8 /* MNISTTrainer */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3A8B3BE2B92950A0002EFB8 /* Build configuration list for PBXNativeTarget "MNISTTrainer" */; + buildPhases = ( + C3A8B3AE2B9295090002EFB8 /* Sources */, + C3A8B3AF2B9295090002EFB8 /* Frameworks */, + C3A8B3B02B9295090002EFB8 /* Resources */, + C3A8B3D72B92A0880002EFB8 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + C3A8B3D62B92A0880002EFB8 /* PBXTargetDependency */, + ); + name = MNISTTrainer; + packageProductDependencies = ( + C3A8B3D12B92A0880002EFB8 /* MLXOptimizers */, + ); + productName = MNISTTrainer; + productReference = C3A8B3B22B9295090002EFB8 /* MNISTTrainer.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -509,7 +609,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1500; + LastSwiftUpdateCheck = 1520; LastUpgradeCheck = 1500; TargetAttributes = { C3288D722B6D9313009FF608 = { @@ -531,6 +631,9 @@ C397C58A2B62C6A9004B084D = { CreatedOnToolsVersion = 15.0.1; }; + C3A8B3B12B9295090002EFB8 = { + CreatedOnToolsVersion = 15.2; + }; }; }; buildConfigurationList = C392736B2B60697700368D5D /* Build configuration list for PBXProject "mlx-swift-examples" */; @@ -559,6 +662,7 @@ C34E49202B6A026F00FCB841 /* mnist-tool */, C34E490C2B69A92900FCB841 /* MNIST */, C3288D722B6D9313009FF608 /* LinearModelTraining */, + C3A8B3B12B9295090002EFB8 /* MNISTTrainer */, ); }; /* End PBXProject section */ @@ -578,6 +682,17 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C3A8B3B02B9295090002EFB8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C3A8B3CE2B92951E0002EFB8 /* README.md in Resources */, + C3A8B3CA2B92951E0002EFB8 /* MNISTTrainer-Info.plist in Resources */, + C3A8B3CD2B92951E0002EFB8 /* Preview Assets.xcassets in Resources */, + C3A8B3CB2B92951E0002EFB8 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -639,6 +754,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C3A8B3AE2B9295090002EFB8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C3A8B3CC2B92951E0002EFB8 /* MNISTTrainerApp.swift in Sources */, + C3A8B3CF2B92951E0002EFB8 /* ContentView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -652,6 +776,11 @@ target = C38935C42B869C7A0037B833 /* LLM */; targetProxy = C38935D92B869CCD0037B833 /* PBXContainerItemProxy */; }; + C3A8B3D62B92A0880002EFB8 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C34E490C2B69A92900FCB841 /* MNIST */; + targetProxy = C3A8B3D52B92A0880002EFB8 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -1520,6 +1649,181 @@ }; name = Release; }; + C3A8B3BF2B92950A0002EFB8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_ENTITLEMENTS = Applications/MNISTTrainer/MNISTTrainer.entitlements; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_ASSET_PATHS = "\"Applications/MNISTTrainer/Preview Content\""; + ENABLE_PREVIEWS = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Applications/MNISTTrainer/Info.plist; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.2; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = mlx.MNISTTrainer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C3A8B3C02B92950A0002EFB8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_ENTITLEMENTS = Applications/MNISTTrainer/MNISTTrainer.entitlements; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_ASSET_PATHS = "\"Applications/MNISTTrainer/Preview Content\""; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_PREVIEWS = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Applications/MNISTTrainer/Info.plist; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.2; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = mlx.MNISTTrainer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1586,6 +1890,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + C3A8B3BE2B92950A0002EFB8 /* Build configuration list for PBXNativeTarget "MNISTTrainer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3A8B3BF2B92950A0002EFB8 /* Debug */, + C3A8B3C02B92950A0002EFB8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ @@ -1682,6 +1995,11 @@ package = C392736E2B60699100368D5D /* XCRemoteSwiftPackageReference "swift-argument-parser" */; productName = ArgumentParser; }; + C3A8B3D12B92A0880002EFB8 /* MLXOptimizers */ = { + isa = XCSwiftPackageProductDependency; + package = C3FBCB1F2B8520B00007E490 /* XCRemoteSwiftPackageReference "mlx-swift" */; + productName = MLXOptimizers; + }; C3FBCB202B8520B80007E490 /* MLX */ = { isa = XCSwiftPackageProductDependency; package = C3FBCB1F2B8520B00007E490 /* XCRemoteSwiftPackageReference "mlx-swift" */;