Hi,
Xcode fails to build a very simple code shown below ONLY IF build configuration is Debug and produces
"Undefined symbols for architecture arm64:
"(extension in Accelerate):Accelerate.AccelerateMutableBuffer< where A: Swift.MutableCollection>.withUnsafeMutableBufferPointer((inout Swift.UnsafeMutableBufferPointer<A.Accelerate.AccelerateBuffer.Element>) throws -> A1) throws -> A1", referenced "
If build configuration is Release, the build is success and it runs just fine.
Note: The code below is a just sample one to reproduce the issue easily. I don't want to use Accelerate framework or those pointer functions in viewDidLoad() for the actual project.
import UIKit
import Accelerate
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let b = UnsafeMutablePointer<Float>.allocate(capacity: 10)
var c = UnsafeMutableBufferPointer(start: b, count: 10)
c.withUnsafeMutableBufferPointer{ buf in
let base = buf.baseAddress
print("test ",base!)
}
}
}
Xcode version is 13.2.1
target iOS version is 15.2
The only workaround I know for now is just to build for release. But I really need debugger for a real project which I'm working on.
Any help, advice or comment would be appreciated.
Best Regards,
Hikaru
Post
Replies
Boosts
Views
Activity
Hi,
I found that the Core ML on iOS 15 consumes almost 450MB larger memory than iOS 14 for prediction of my model.
It may easily cause running out of memory crash on small memory devices.
To reproduce the issue, I created a sample code as bellow. It shows around 450MB on iOS 15 but only about 4MB on iOS 14.X.
I have already submitted the issue through Feedback Assistance.
But does anyone have any idea to work around the issue?
I've confirmed the the issue still exists on iOS 15.1 Beta 2.
Any advice would be appreciated.
import CoreML
class ViewController: UIViewController {
@IBOutlet weak var memoryLabel: UILabel!
@IBAction func predAction(_ sender: Any) {
let modelConf = MLModelConfiguration()
modelConf.computeUnits = .cpuOnly
do {
let input = UnsafeMutablePointer<Float>.allocate(capacity: 512 * 1024 * 2)
input.initialize(repeating: 0.0, count: 512 * 1024 * 2)
let inputMultiArray = try MLMultiArray(dataPointer: input, shape: [1,512,1024,2], dataType: .float32, strides: [(512 * 1024 * 2) as NSNumber ,(1024 * 2) as NSNumber,2,1], deallocator: nil)
let model = try TestModel(configuration: modelConf)
let memBefore = os_proc_available_memory()
let _ = try model.prediction(input:TestModelInput(strided_slice_3_0: inputMultiArray))
let memAfter = os_proc_available_memory()
print("memory size for prediction",memBefore - memAfter)
memoryLabel.text = String(describing:(memBefore - memAfter) )
}
catch {
print("error")
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}