Post

Replies

Boosts

Views

Activity

Reply to BNNS random number generator for Double value types
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:
Jun ’25
Reply to Data storage for a Matrix struct when working with Accelerate
I would also like to mention that running the code below gives me almost identical elapsed times for the matrix array and matrix buffer solutions. So, at least for this case, I'm not seeing any performance differences between the two approaches. func runBenchmark1() { print("Benchmark matrix multiplication") for _ in 1...3 { let tic = Date.now let n = 8_000 let a = Matrix<Double>(rows: n, columns: n, fill: 1.5) let b = Matrix<Double>(rows: n, columns: n, fill: 2.8) let c = a * b let toc = tic.timeIntervalSinceNow.magnitude let elapsed = String(format: "%.4f", toc) print("Elapsed time is \(elapsed) sec, first element is \(c[0, 0])") } }
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24