I updated my example with vDSP.convertElements but this requires two arrays which are result and resultDouble. Is there a way to do this with just one array instead of two?
import Accelerate
let n = 100_000_000
let result = Array<Float>(unsafeUninitializedCapacity: n) { buffer, initCount in
var descriptor = BNNSNDArrayDescriptor(data: buffer, shape: .vector(n))!
let randomGenerator = BNNSCreateRandomGenerator(BNNSRandomGeneratorMethodAES_CTR, nil)
BNNSRandomFillUniformFloat(randomGenerator, &descriptor, 0, 1)
initCount = n
}
var resultDouble = [Double](repeating: 0, count: n)
vDSP.convertElements(of: result, to: &resultDouble)
Topic:
Machine Learning & AI
SubTopic:
General
Tags: