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