CreateMLComponents: Error in Playground

I encountered an error while experimenting with the new CreateMLComponents in playground with the following code:

import CreateMLComponents
import CoreML

var fullyConnected = FullyConnectedNetworkRegressor<Float>.init()
fullyConnected.hiddenUnitCounts = [2]

let feature: AnnotatedFeature<MLShapedArray<Float>, Float> = .init(feature: .init(scalars: [2, 3], shape: [2]), annotation: 5)

let fitted = try? await fullyConnected.fitted(to: [feature, feature])
print(fitted)

The generated error message is included (partially) at the end of this post. I later found out that this same code works fine in an actual app. Any insights?

The error message:

Playground execution failed:

error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x00007ffb2093728d SwiftNN`SwiftNN.Tensor.scalar<œÑ_0_0 where œÑ_0_0: SwiftNN.TensorScalar>(as: œÑ_0_0.Type) -> œÑ_0_0 + 157
    frame #1: 0x00007ffb20937cbb SwiftNN`SwiftNN.Tensor.playgroundDescription.getter : Any + 91
    frame #2: 0x000000010da43ac4 PlaygroundLogger`___lldb_unnamed_symbol491 + 820
    frame #3: 0x000000010da45dbd PlaygroundLogger`___lldb_unnamed_symbol505 + 189

(some more lines ...)

PlaygroundLogger`___lldb_unnamed_symbol428 + 124
    frame #65: 0x000000010da41dad PlaygroundLogger`playground_log_hidden + 269
    frame #66: 0x000000010ca59aba $__lldb_expr14`async_MainTY1_ at CreateMLComp.xcplaygroundpage:12:5
    frame #67: 0x000000010ca59fb0 $__lldb_expr14`thunk for @escaping @convention(thin) @async () -> () at <compiler-generated>:0
    frame #68: 0x000000010ca5a0c0 $__lldb_expr14`partial apply for thunk for @escaping @convention(thin) @async () -> () at <compiler-generated>:0

Thanks for raising this issue @Alan_Z. As you mentioned, it looks like it's only an issue when using Xcode Playgrounds. Please use Feedback Assistant to open a bug report and post the FB number here.

Hi @Alan_Z, I'm also struggling with the Create ML Components library. I downloaded Xcode 14 beta 5 and the sample code, however, I can't build the code nor import the both Create ML and Create ML Components in the playground and the compiler says No such module 'CreateMLComponents'. Can you kindly share how you managed to make it work? like, what's your xcode version, and have you installed any extra packages?

CreateMLComponents: Error in Playground
 
 
Q