Open
Description
🐛 Describe the bug
The following repro intermittently crashes the process on my M1 Pro. Putting this in a notebook and running the cell twice appears to crash 100% of the time for me. I'm not 100% sure if it's a CoreML issue, but it does not crash when removing the CoreML partitioner and running on portable.
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__()
def forward(self, x):
return torch.argmax(x, dim=None, keepdim=False)
model = Model()
inputs = (
torch.randn(10, 10),
)
eager_outputs = model(*inputs)
#print(f"Eager: {eager_outputs.shape} {eager_outputs}")
ep = torch.export.export(model.eval(), inputs)
print(ep)
print(f"EP: {ep.module()(*inputs)}")
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
This causes a segmentation fault.
Versions
coremltools version 8.3
executorch commit 67b6009 (Jun 14)