Post

Replies

Boosts

Views

Activity

Reply to Help with the (Unsafe) pointer management
Done. matrixC is the object that comes from the output of MPSMatrixMultiplication. let doublePointer = UnsafeMutablePointer<UnsafeMutablePointer<Float>>.allocate(capacity: count)         for i in 0..<matrixC.rows {             doublePointer[i] = rawPointer.advanced(by: i*matrixC.columns).bindMemory(to: Float.self, capacity: matrixC.columns)         }         // print by iterating over 1st row         for i in 0..<10 {             print(doublePointer.pointee[i])         }                  // print by iterating over 1st column         for j in 0..<10 {             print(doublePointer[j].pointee)         }
Nov ’22
Reply to Help with the (Unsafe) pointer management
Done. matrixC is the object that comes from the output of MPSMatrixMultiplication. let doublePointer = UnsafeMutablePointer<UnsafeMutablePointer<Float>>.allocate(capacity: count)         for i in 0..<matrixC.rows {             doublePointer[i] = rawPointer.advanced(by: i*matrixC.columns).bindMemory(to: Float.self, capacity: matrixC.columns)         }         // print by iterating over 1st row         for i in 0..<10 {             print(doublePointer.pointee[i])         }                  // print by iterating over 1st column         for j in 0..<10 {             print(doublePointer[j].pointee)         }
Replies
Boosts
Views
Activity
Nov ’22