Repository: pytorch
Issue: [torchbench] torch._dynamo.exc.Unsupported: Graph break due to unsupported builtin None.morphologyEx
Labels: oncall: pt2,module: dynamo,oncall: export,pt2-pass-rate-regression

### 🐛 Describe the bug

Repro:
```
python benchmarks/dynamo/torchbench.py --accuracy --no-translation-validation --inference --amp --export --disable-cudagraphs --device cuda --only doctr_det_predictor
```

```
cuda eval  doctr_det_predictor                
ERROR:common:
Traceback (most recent call last):
  File "/data/users/ivankobzarev/a/pytorch/benchmarks/dynamo/common.py", line 3055, in check_accuracy
    optimized_model_iter_fn = optimize_ctx(
  File "/data/users/ivankobzarev/a/pytorch/benchmarks/dynamo/common.py", line 1623, in export
    ep = torch.export.export(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/__init__.py", line 270, in export
    return _export(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/_trace.py", line 1017, in wrapper
    raise e
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/_trace.py", line 990, in wrapper
    ep = fn(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/exported_program.py", line 114, in wrapper
    return fn(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/_trace.py", line 1880, in _export
    export_artifact = export_func(  # type: ignore[operator]
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/_trace.py", line 1224, in _strict_export
    return _strict_export_lower_to_aten_ir(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/_trace.py", line 1252, in _strict_export_lower_to_aten_ir
    gm_torch_level = _export_to_torch_ir(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/export/_trace.py", line 560, in _export_to_torch_ir
    gm_torch_level, _ = torch._dynamo.export(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1432, in inner
    result_traced = opt_f(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 465, in _fn
    return fn(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1269, in __call__
    return self._torchdynamo_orig_callable(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 526, in __call__
    return _compile(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 924, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 666, in compile_inner
    return _compile_inner(code, one_graph, hooks, transform)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_utils_internal.py", line 87, in wrapper_function
    return function(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 699, in _compile_inner
    out_code = transform_code_object(code, transform)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1322, in transform_code_object
    transformations(instructions, code_options)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 219, in _fn
    return fn(*args, **kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 634, in transform
    tracer.run()
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2796, in run
    super().run()
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 983, in run
    while self.step():
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 895, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 582, in wrapper
    return inner_fn(self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1602, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 830, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/user_defined.py", line 928, in call_function
    return self.call_method(tx, "__call__", args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/user_defined.py", line 788, in call_method
    return UserMethodVariable(method, self, source=source).call_function(
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 385, in call_function
    return super().call_function(tx, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 324, in call_function
    return super().call_function(tx, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 111, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 836, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3011, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3139, in inline_call_
    tracer.run()
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 983, in run
    while self.step():
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 895, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 582, in wrapper
    return inner_fn(self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1602, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 830, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 111, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 836, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3011, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3139, in inline_call_
    tracer.run()
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 983, in run
    while self.step():
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 895, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 582, in wrapper
    return inner_fn(self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1602, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 830, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 111, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 836, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3011, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3139, in inline_call_
    tracer.run()
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 983, in run
    while self.step():
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 895, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 582, in wrapper
    return inner_fn(self, inst)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1602, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 830, in call_function
    self.push(fn.call_function(self, args, kwargs))  # type: ignore[arg-type]
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 727, in call_function
    unimplemented(msg)
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/torch/_dynamo/exc.py", line 297, in unimplemented
    raise Unsupported(msg, case_name=case_name)
torch._dynamo.exc.Unsupported: Graph break due to unsupported builtin None.morphologyEx. This function is either a Python builtin (e.g. _warnings.warn) or a third-party C/C++ Python extension (perhaps created with pybind). If it is a Python builtin, please file an issue on GitHub so the PyTorch team can add support for it and see the next case for a workaround. If it is a third-party C/C++ Python extension, please either wrap it into a PyTorch-understood custom operator (see https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html for more details) or, if it is traceable, use torch.compiler.allow_in_graph.
from user code:
   File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/doctr/models/detection/differentiable_binarization/pytorch.py", line 211, in forward
    for preds in self.postprocessor(prob_map.detach().cpu().permute((0, 2, 3, 1)).numpy())
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/doctr/models/detection/core.py", line 90, in __call__
    bin_map = [
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/doctr/models/detection/core.py", line 91, in <listcomp>
    [
  File "/home/ivankobzarev/local/a/pytorch-env/lib/python3.10/site-packages/doctr/models/detection/core.py", line 92, in <listcomp>
    cv2.morphologyEx(bmap[..., idx], cv2.MORPH_OPEN, self._opening_kernel)
Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information
TorchDynamo optimized model failed to run because of following error
fail_to_run
```

### Error logs

_No response_

### Versions

torch main Jan 17

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4