devices:
iphone 11
config:
configuration.computeUnits = .all
let myModel = try! myCoremlModel(configuration: configuration).model
Set the Range for Each Dimension:
input_shape= ct.Shape(shape=(1,3,ct.RangeDim(lower_bound=128, upper_bound=384, default=256),ct.RangeDim(lower_bound=128, upper_bound=384, default=256)))
- inference time as table(average of 100 runs)
The default size inference for dynamic models is the same as for static models, but 128128 and 384384 hundreds of times slow than fixed-size models. Is this normal? Is there any good solution?
- model init time is too long
load model time about 2 minutes, Is there a way to speed it up? For example, load from the cache? Can converted mlparkage speed up the loading time?
For models with range flexibility, we currently only support running on the Neural Engine for the input's default shape. Other shapes will be run on either GPU or CPU, which is likely why you are seeing higher latency for non-default shapes.
One other option you have here is to use enumerated flexibility instead of range flexibility. If you only need a smaller set of sizes supported by the model, you can use ct.EnumeratedShapes type to specify each shape the model should support. For enumerated shape flexibility, each shape should be able to run on the Neural Engine. You can read more about the advantages of enumerated shapes here https://coremltools.readme.io/docs/flexible-inputs.