Post

Replies

Boosts

Views

Activity

MLShapedArraySlice not behaving as expected
Hi, I am trying to manipulate some data that I receive from a coreml model. To do this I am attempting to use MLShapedArray and MLShapedArraySlice. However, the shaped array slice does not behave as expected. Here is a small code snippet that initialize a 3D shaped array, prints it, then slices it and prints the slice: import CoreML var x = MLShapedArray<Float>(scalars: [0,1,2,3,4,5], shape: [1,3,2]) for i in 0..<x.shape[0] { for j in 0..<x.shape[1] { for k in 0..<x.shape[2] { print("[\(i),\(j),\(k)] = \(x[i,j,k].scalar ?? 0)") } } } var y = x[0...0,1..<2] print(y) for i in 0..<y.shape[0] { for j in 0..<y.shape[1] { for k in 0..<y.shape[2] { print("[\(i),\(j),\(k)] = \(y[i,j,k].scalar ?? 0)") } } } My expectation is that the slice will yield the second pair of numbers 2,3 but instead I get: [0,0,0] = 0.0 [0,0,1] = 1.0 [0,1,0] = 2.0 [0,1,1] = 3.0 [0,2,0] = 4.0 [0,2,1] = 5.0 MLShapedArraySlice<Float>(shape: [1, 1, 2], baseShapedArray: 0.0 1.0 2.0 3.0 4.0 5.0 , baseIndices: [], sliceRanges: [Range(0..<1), Range(1..<2), Range(0..<2)], originIndices: [0, 1, 0]) [0,0,0] = 0.0 [0,0,1] = 1.0 As you can see from the details of the printed slice - its shape is correct and it has the proper ranges displayed - yet when I subscript it it yields the same as the original shaped array. This is not what I expected - however I can't find any documentation or examples on how to use the slicing with ranges (or much on the slices at all) Am I using it wrong or is it just not working correctly?
0
0
582
May ’23
ARKit crash help
Hi - I am seeing a crash in ARKit and it is very challenging to tell what I am doing in code to trigger it. Is it possible to get more information about what may be triggering this crash. Here is the crashing thread: Thread 41 name: Thread 41 Crashed: 0 libsystem_kernel.dylib 0x00000001b8505964 __pthread_kill + 8 1 libsystem_pthread.dylib 0x00000001f2141378 pthread_kill + 268 (pthread.c:1668) 2 libsystem_c.dylib 0x000000018bd2cf50 abort + 164 (abort.c:118) 3 AppleCV3D 0x00000001c26623ec cv3d::kit::concurrency::detail::ProcessorInputMessageHandlingStrategy<cv3d::recon::frame::FrameBundle, cv3d::applecv3d::spatial_mapping::MeshingNodeMeshUpdateResult, void, std::__1::optional<cv3d::... + 244 (ProcessorInputMessageHandlingStrategy.h:112) 4 AppleCV3D 0x00000001c2662174 _ZZNK4cv3d3kit11concurrency6detail9ProcessorINS_5recon5frame11FrameBundleENS_9applecv3d15spatial_mapping27MeshingNodeMeshUpdateResultEvNSt3__18optionalIS9_EELb0EE25EnqueueMessageAndDispatchIZNKSD_4... + 192 (Processor.h:238) 5 AppleCV3D 0x00000001c39f6c48 dispatch_async_C_CallBack + 68 (functional:1885) 6 libdispatch.dylib 0x0000000180adb670 _dispatch_client_callout + 20 (object.m:560) 7 libdispatch.dylib 0x0000000180ae2ed4 _dispatch_lane_serial_drain + 896 (inline_internal.h:2587) 8 libdispatch.dylib 0x0000000180ae399c _dispatch_lane_invoke + 444 (queue.c:3937) 9 libdispatch.dylib 0x0000000180ae4c84 _dispatch_workloop_invoke + 1796 (inline_internal.h:0) 10 libdispatch.dylib 0x0000000180aee1b8 _dispatch_workloop_worker_thread + 656 (queue.c:6727) 11 libsystem_pthread.dylib 0x00000001f213b0f4 _pthread_wqthread + 288 (pthread.c:2599) 12 libsystem_pthread.dylib 0x00000001f213ae94 start_wqthread + 8
2
0
915
Feb ’22