Open
Description
🐛 Describe the bug
Models with ReplicationPad3d on Core ML fail to load at runtime.
Repro:
import torch
from executorch.backends.apple.coreml.partition import CoreMLPartitioner
from executorch.exir import to_edge_transform_and_lower, EdgeCompileConfig, to_edge
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.pad = torch.nn.ReplicationPad3d(padding=2)
def forward(self, x):
return self.pad(x)
model = Model()
inputs = (
torch.randn(1, 6, 6, 6, 6),
)
eager_outputs = model(*inputs)
#print(f"Eager: {eager_outputs.shape} {eager_outputs}")
ep = torch.export.export(model.eval(), inputs)
print(ep)
lowered = to_edge_transform_and_lower(
ep,
partitioner=[CoreMLPartitioner()],
compile_config=EdgeCompileConfig(_check_ir_validity=False)
).to_executorch()
print(lowered.exported_program())
et_model = _load_for_executorch_from_buffer(lowered.buffer)
et_outputs = et_model([*inputs])[0]
et_outputs - eager_outputs
Output:
[ETCoreMLModelCompiler.mm:55] [Core ML] Failed to compile model, error = Error Domain=com.apple.mlassetio Code=1 "Failed to parse the model specification. Error: Unable to parse ML Program: in operation aten_pad_default_cast_fp16: Padding for more than two dimensions only supports `$
[backend_delegate.mm:288] [Core ML] Model init failed Failed to compile model, error = Error Domain=com.apple.mlassetio Code=1 "Failed to parse the model specification. Error: Unable to parse ML Program: in operation aten_pad_default_cast_fp16: Padding for more than two dimension$
[coreml_backend_delegate.mm:193] CoreMLBackend: Failed to init the model.
[method.cpp:113] Init failed for backend CoreMLBackend: 0x23
Versions
coremltools version 8.3
executorch commit 67b6009 (Jun 14)