apple / coremltools

Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
https://coremltools.readme.io
BSD 3-Clause "New" or "Revised" License
4.38k stars 631 forks source link

Runtime error: Invalid Rank 6 #832

Open vedashreep opened 4 years ago

vedashreep commented 4 years ago

❓Question

I am trying to train an updatable coreml model on the device. The model is a classification model trained on 6 classes and accepts an input of shape (1,3). I could successfully convert the model from Keras and run predictions on it. However, when trying to train the model on the device I get the following error: [espresso] Training kernels not enabled for engine: 100 libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Invalid rank: 6 Not sure where I am going wrong.

Attaching a screenshot of the mlmodel .

Screenshot 2020-07-31 at 2 53 04 PM

System Information

MacOS Catalina (10.15.6) Xcode 11.2.1 iOS 13.3 Coremltools 4.0b2 Python 3.7 Tensorflow 2.2

heydavid525 commented 4 years ago

The runtime engine only support up to rank 5 at the moment. Can you check (using netron or programmatically) which layers have weights or input tensor with rank >5? With that additional info it'd be easier to route to the right person within Apple to see if there's anything we can do in the short term.

PeterL1n commented 3 years ago

@daiwei89

Just went into the same issue.

Imagine if you have an image tensor [b, c, h, w]. Then you want to do a sliding window to get image patches. Currently, you have to do two sliding windows operations on two different axes. Which should give you [b, c, h, i, w, j]. This needs rank 6!

BradXiao commented 3 years ago

The same problem was encountered when converting large models such as YOLOv4. Currently, my workaround is reshaping any tensors below five ranks.