apple / apple/coremltools

Anyway to convert pb model that has NWHC input shape to mlmodel that has NCHW input shape?

Open
#1,047 1 comment 0 reactions 0 assignees View on GitHub
perf question tf1.x
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## ❓Question
Anyway to convert pb model that has NWHC input/output shape to mlmodel that has NCHW input/output shape?

CoreML3.0 converter will automatically do such conversion,CoreML4.0 just keep the input shape and add a “transpose” which makes the mlmodel much slower than CoreML3.0 version (I guess the reason for the lower efficiency is the "transpose", nearly 3.0 times slower)!
Source:
![image](https://user-images.githubusercontent.com/6919667/103753197-b126af00-5045-11eb-8489-fcefbd9a025c.png)
![image](https://user-images.githubusercontent.com/6919667/103754313-2a72d180-5047-11eb-9dea-08037f681cfd.png)

CoreML3.0:
![image](https://user-images.githubusercontent.com/6919667/103753309-dc110300-5045-11eb-903b-750e6abea4ec.png)
![image](https://user-images.githubusercontent.com/6919667/103754245-13cc7a80-5047-11eb-9ceb-51588bf05f8d.png)

CoreML4.0:
![image](https://user-images.githubusercontent.com/6919667/103753868-8721bc80-5046-11eb-9249-3f496424a265.png)
![image](https://user-images.githubusercontent.com/6919667/103754185-fe575080-5046-11eb-8a26-d651fdf0f2a5.png)

## System Information
- iPhone XR iOS(14.3)

Contributor guide

Open the contributing guide

Research direction

The issue names no repository file, test, or entry point. Start by reproducing conversion of the NWHC pb model with CoreML 3.0 and CoreML 4.0, then inspect the generated transpose and compare performance; done would require an agreed conversion approach that preserves the expected NCHW behavior without the reported slowdown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.