I have a coremlmodel taking an input of shape MultiArray (Float32 67 x 256 x 320)
I am having a hard time to shape the input to this model.
Currently, I am trying to achieve it like so,
var m = try! MLMultiArray(shape: [67,256,320], dataType: .double)
for i in 0...66{
var cost = rand((256,320)) // this is coming from swix [SWIX]
memcpy(m.dataPointer+i*256*320, &cur_cost.flat.grid , 256*320)
}
I will have to replace the rand with matrices of that size later. I am using this for testing purposes first.
Any pointers on how to mould input to fit the volume would be greatly appreciated..
[SWIX]
What seems to be wrong in your code is that you're copying bytes instead of doubles. A double is 8 bytes, so your offset should be
i*256*320*MemoryLayout<Double>.stride
and the amount you're copying should be256*320*MemoryLayout<Double>.stride
.Note that you can also use the MLMultiArray's
strides
property to compute the offset for a given data element in the array: