Repository: pytorch
Issue: Getting NotImplementedError when trying to implement E2E support for `prim::is_nested` Op in torch-mlir.
Labels: triaged,module: nestedtensor

### 🐛 Describe the bug

Hello, I am trying to add support for the Prim::is_nested Op in torch-mlir. I have posted a similar issue in torch-mlir: https://github.com/llvm/torch-mlir/issues/880 and this PR https://github.com/llvm/torch-mlir/pull/881 points to the commit in question. It has the corresponding lowering code and E2E test code. When trying to run the nested test case I get the following error summary. Kindly advice on the best way to debug the error.

```Unexpected outcome summary:

****** Failed tests - 1 tests
    FAIL - "PrimIsNestedOpModule_nested"
        Compilation error: Traceback (most recent call last):
          File "/home/vidush/nodAI/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/torchscript/framework.py", line 282, in compile_and_run_test
            golden_trace = generate_golden_trace(test)
          File "/home/vidush/nodAI/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/torchscript/framework.py", line 276, in generate_golden_trace
            test.program_invoker(tracer, TestUtils())
          File "/home/vidush/nodAI/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/test_suite/basic.py", line 1922, in PrimIsNestedOpModule_nested
            module.forward(nested_basic)
          File "/home/vidush/nodAI/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/torchscript/framework.py", line 255, in __call__
            inputs = [clone_torch_script_value(arg) for arg in args]
          File "/home/vidush/nodAI/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/torchscript/framework.py", line 255, in <listcomp>
            inputs = [clone_torch_script_value(arg) for arg in args]
          File "/home/vidush/nodAI/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/torchscript/framework.py", line 60, in clone_torch_script_value
            return v.clone()
        NotImplementedError: Could not run 'aten::clone' with arguments from the 'NestedTensorCPU' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. 'aten::clone' is only available for these backends: [Dense, FPGA, ORT, Vulkan, Metal, Meta, Quantized, CustomRNGKeyId, MkldnnCPU, Sparse, SparseCsrCPU, SparseCsrCUDA, NestedTensor, BackendSelect, Python, Fake, Named, Conjugate, Negative, ZeroTensor, FuncTorchDynamicLayerBackMode, ADInplaceOrView, AutogradOther, AutogradFunctionality, AutogradNestedTensor, Tracer, AutocastCPU, AutocastXPU, Autocast, FuncTorchBatched, FuncTorchVmapMode, Batched, VmapMode, FuncTorchGradWrapper, Functionalize, DeferredInit, PythonTLSSnapshot, FuncTorchDynamicLayerFrontMode, TESTING_ONLY_GenericWrapper, TESTING_ONLY_GenericMode, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, CPU, CUDA, HIP, XLA, MPS, IPU, UNKNOWN_TENSOR_TYPE_ID, QuantizedXPU, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, SparseCPU, SparseCUDA, SparseHIP, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, SparseXPU, UNKNOWN_TENSOR_TYPE_ID, SparseVE, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, NestedTensorCUDA, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID, UNKNOWN_TENSOR_TYPE_ID].

        Undefined: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        CPU: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        CUDA: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        HIP: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        XLA: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        MPS: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        IPU: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        XPU: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        HPU: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        VE: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        Lazy: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        PrivateUse1: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        PrivateUse2: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        PrivateUse3: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        FPGA: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        ORT: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        Vulkan: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        Metal: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        Meta: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        QuantizedCPU: registered at aten/src/ATen/RegisterQuantizedCPU.cpp:1294 [kernel]
        QuantizedCUDA: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        QuantizedXPU: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        CustomRNGKeyId: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        MkldnnCPU: registered at aten/src/ATen/RegisterMkldnnCPU.cpp:690 [kernel]
        SparseCPU: registered at aten/src/ATen/RegisterSparseCPU.cpp:1858 [kernel]
        SparseCUDA: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        SparseHIP: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        SparseXPU: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        SparseVE: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        SparseCsrCPU: registered at aten/src/ATen/RegisterSparseCsrCPU.cpp:1507 [kernel]
        SparseCsrCUDA: registered at aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:29545 [default backend kernel]
        BackendSelect: fallthrough registered at ../aten/src/ATen/core/BackendSelectFallbackKernel.cpp:3 [backend fallback]
        Python: registered at ../aten/src/ATen/core/PythonFallbackKernel.cpp:133 [backend fallback]
        Named: fallthrough registered at ../aten/src/ATen/core/NamedRegistrations.cpp:11 [kernel]
        Conjugate: fallthrough registered at ../aten/src/ATen/ConjugateFallback.cpp:22 [kernel]
        Negative: fallthrough registered at ../aten/src/ATen/native/NegateFallback.cpp:22 [kernel]
        ZeroTensor: fallthrough registered at ../aten/src/ATen/ZeroTensorFallback.cpp:90 [kernel]
        ADInplaceOrView: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:64 [backend fallback]
        AutogradOther: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradCPU: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradCUDA: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradXLA: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradMPS: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradIPU: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradXPU: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradHPU: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        UNKNOWN_TENSOR_TYPE_ID: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradLazy: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradPrivateUse1: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradPrivateUse2: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        AutogradPrivateUse3: registered at ../torch/csrc/autograd/generated/VariableType_1.cpp:12167 [autograd kernel]
        Tracer: registered at ../torch/csrc/autograd/generated/TraceType_1.cpp:12753 [kernel]
        AutocastCPU: fallthrough registered at ../aten/src/ATen/autocast_mode.cpp:481 [backend fallback]
        Autocast: fallthrough registered at ../aten/src/ATen/autocast_mode.cpp:324 [backend fallback]
        Batched: registered at ../aten/src/ATen/BatchingRegistrations.cpp:1068 [kernel]
        VmapMode: fallthrough registered at ../aten/src/ATen/VmapModeRegistrations.cpp:33 [backend fallback]
        Functionalize: registered at ../aten/src/ATen/FunctionalizeFallbackKernel.cpp:89 [backend fallback]
        PythonTLSSnapshot: registered at ../aten/src/ATen/core/PythonFallbackKernel.cpp:137 [backend fallback]```


### Versions

Collecting environment information...
PyTorch version: 1.13.0.dev20220523+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-5ubuntu1) 9.4.0
Clang version: 13.0.0
CMake version: version 3.22.4
Libc version: glibc-2.35

Python version: 3.9.0 (default, May 19 2022, 12:51:15)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.16.0-051600-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.22.4
[pip3] torch==1.13.0.dev20220523+cpu
[pip3] torchvision==0.13.0.dev20220523+cpu
[conda] Could not collect

cc @cpuhrsch @jbschlosser @bhosmer