Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel 'executorch_prim::et_view.default' not found. #7459

Open
dinusha94 opened this issue Dec 30, 2024 · 6 comments
Open

kernel 'executorch_prim::et_view.default' not found. #7459

dinusha94 opened this issue Dec 30, 2024 · 6 comments
Assignees
Labels
module: doc Related to our documentation, both in docs/ and docblocks

Comments

@dinusha94
Copy link

🐛 Describe the bug

I am trying to use mobilenet v2 pte with the executorch module extension. but getting the following error. I have followed the setting up tutorial and set up the executorch environment.

I am trying to incorporate the executorch into my simple application using the following CMakeList.txt

cmake_minimum_required(VERSION 3.19)
project(SimpleProject)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Add the main executable
add_executable(SimpleApp src/main.cpp)

# Link against the ExecuTorch library and additional dependencies
target_link_libraries(SimpleApp PRIVATE
    /usr/local/lib/libexecutorch.a
    /usr/local/lib/libextension_module_static.a
    /usr/local/lib/libexecutorch_no_prim_ops.a
    /usr/local/lib/libextension_data_loader.a
    /usr/local/lib/libextension_tensor.a
    -Wl,--whole-archive /usr/local/lib/libportable_ops_lib.a -Wl,--no-whole-archive
    /usr/local/lib/libportable_kernels.a
)

# Include directories for ExecuTorch
target_include_directories(SimpleApp PRIVATE
    /usr/local/include/executorch
)

I exported the mobilent v2 into a pte file using the following python script

import torch
import torchvision
import executorch.exir as exir

from torch._export import capture_pre_autograd_graph
from torch.export import export, ExportedProgram

m = torchvision.models.MobileNetV2()
m.eval()

example_args = (torch.randn(1, 3, 224, 224),)
pre_autograd_aten_dialect = capture_pre_autograd_graph(m, example_args)

aten_dialect: ExportedProgram = export(pre_autograd_aten_dialect, example_args)
edge_program: exir.EdgeProgramManager = exir.to_edge(aten_dialect)

executorch_program: exir.ExecutorchProgramManager = edge_program.to_executorch(
    exir.ExecutorchBackendConfig(
        passes=[],  # User-defined passes
    )
)

with open("./models/mobilenet_v2.pte", "wb") as file:
    file.write(executorch_program.buffer)

Following in my main.cpp script where I use the executorch module extension to run an inference.


#include <iostream>
#include <executorch/extension/module/module.h>
#include <executorch/extension/tensor/tensor.h>
#include <executorch/runtime/core/evalue.h>

using namespace ::executorch::extension;
using namespace ::executorch::runtime;

using executorch::runtime::Result;


int main() {

    // Create a Module.
    Module module("../models/mobilenet_v2.pte");

    // Wrap the input data with a Tensor.
    const int size = 1 * 3 * 224 * 224; // Total size of the array
    float input[size]; // Declare the array

    // Populate the array with a constant value of 2
    for (int i = 0; i < size; ++i) {
        input[i] = 2.0f;
    }

    auto tensor = from_blob(input, {1, 3, 224, 224});

    // Perform an inference.
    const auto result = module.forward(tensor);

    // Check for success or failure.
    if (result.ok()) {

        const auto& vec = *result;
        size_t length = vec.size();
        std::cout << "Vector length: " << length << std::endl;

        const auto num_dim = result->at(0).toTensor().dim();
        std::cout << "num dim : " << num_dim << std::endl; 

        const auto ze_dim_ = result->at(0).toTensor().size(1);
        std::cout << "size dim : " << ze_dim_ << std::endl;   
        
        const auto num_elements = result->at(0).toTensor().numel();
        std::cout << "num elements in bits : " << num_elements << std::endl; 

        // Retrieve the output data.
        const auto output = result->at(0).toTensor().const_data_ptr<float>();

        std::cout << "Tensor data: ";
        for (int i = 0; i < num_elements; ++i) {
            std::cout << output[i] << " ";
        }
        std::cout << std::endl;
    }

    return 0;
}


after make and run ./SimpleApp I get the following error. when I try the add.pte and the SimpleConv model shown in the exporting tutorial I get no such issues and works fine.

when I inspect the libexcutorch.a with nm tool I see the following et_view definition, not the one shown in the error

nm -C libexecutorch.a | grep et_view

0000000000000000 T torch::executor::function::et_view(executorch::runtime::KernelRuntimeContext&, executorch::runtime::EValue**)
                 U torch::executor::function::et_view(executorch::runtime::KernelRuntimeContext&, executorch::runtime::EValue**)
E 00:00:00.031327 executorch:operator_registry.cpp:185] kernel 'executorch_prim::et_view.default' not found.
E 00:00:00.031451 executorch:operator_registry.cpp:186] dtype: 6 | dim order: [
E 00:00:00.031467 executorch:operator_registry.cpp:186] 0,
E 00:00:00.031476 executorch:operator_registry.cpp:186] 1,
E 00:00:00.031483 executorch:operator_registry.cpp:186] 2,
E 00:00:00.031491 executorch:operator_registry.cpp:186] 3,
E 00:00:00.031498 executorch:operator_registry.cpp:186] ]
E 00:00:00.031506 executorch:operator_registry.cpp:186] dtype: 6 | dim order: [
E 00:00:00.031513 executorch:operator_registry.cpp:186] 0,
E 00:00:00.031521 executorch:operator_registry.cpp:186] 1,
E 00:00:00.031528 executorch:operator_registry.cpp:186] ]
E 00:00:00.031536 executorch:method.cpp:542] Missing operator: [5] executorch_prim::et_view.default
E 00:00:00.031557 executorch:method.cpp:736] There are 1 instructions don't have corresponding operator registered. See logs for details

Any help on this would be highly appreciated
Thank you

Versions

Collecting environment information...
PyTorch version: 2.5.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.31.2
Libc version: glibc-2.31

Python version: 3.10.0 (default, Mar  3 2022, 09:58:08) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.15.0-127-generic-x86_64-with-glibc2.31
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
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

CPU:
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Byte Order:                           Little Endian
Address sizes:                        45 bits physical, 48 bits virtual
CPU(s):                               4
On-line CPU(s) list:                  0-3
Thread(s) per core:                   1
Core(s) per socket:                   1
Socket(s):                            4
NUMA node(s):                         1
Vendor ID:                            GenuineIntel
CPU family:                           6
Model:                                154
Model name:                           12th Gen Intel(R) Core(TM) i7-1255U
Stepping:                             4
CPU MHz:                              2611.209
BogoMIPS:                             5222.41
Hypervisor vendor:                    VMware
Virtualization type:                  full
L1d cache:                            192 KiB
L1i cache:                            128 KiB
L2 cache:                             5 MiB
L3 cache:                             48 MiB
NUMA node0 CPU(s):                    0-3
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Mitigation; PTE Inversion
Vulnerability Mds:                    Mitigation; Clear CPU buffers; SMT Host state unknown
Vulnerability Meltdown:               Mitigation; PTI
Vulnerability Mmio stale data:        Not affected
Vulnerability Reg file data sampling: Vulnerable: No microcode
Vulnerability Retbleed:               Mitigation; IBRS
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; IBRS; IBPB conditional; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI SW loop, KVM SW loop
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni arat umip gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] executorch==0.4.0a0+6a085ff
[pip3] numpy==1.21.3
[pip3] torch==2.5.0+cpu
[pip3] torchaudio==2.5.0+cpu
[pip3] torchsr==1.0.4
[pip3] torchvision==0.20.0+cpu
[conda] executorch                0.4.0a0+6a085ff          pypi_0    pypi
[conda] numpy                     1.21.3                   pypi_0    pypi
[conda] torch                     2.5.0+cpu                pypi_0    pypi
[conda] torchaudio                2.5.0+cpu                pypi_0    pypi
[conda] torchsr                   1.0.4                    pypi_0    pypi
[conda] torchvision               0.20.0+cpu               pypi_0    pypi

@dinusha94
Copy link
Author

After I use another implementation of mobilenetv2 it worked, don't know why

@kimishpatel
Copy link
Contributor

So if you add /usr/local/lib/libexecutorch.a to be linked whole as well, similar to /usr/local/lib/libportable_ops_lib.a, it might work. Can you try?

@kimishpatel kimishpatel added the module: doc Related to our documentation, both in docs/ and docblocks label Jan 3, 2025
@kimishpatel
Copy link
Contributor

@dbort to update our docs to showcase how to use executorch libs into your custom cpp apps

@jpeng2012
Copy link

@dinusha94
I am not able to find
/usr/local/lib/libextension_module_static.a
/usr/local/lib/libextension_data_loader.a
/usr/local/lib/libextension_tensor.a
following the setup build method from the tutorial.

@SS-JIA SS-JIA self-assigned this Jan 6, 2025
@SS-JIA
Copy link
Contributor

SS-JIA commented Jan 6, 2025

@jpeng2012 in order for those libraries to be built, you need to enable them in your cmake command. For example:

(rm -rf cmake-out && \
  cmake . \
  -DCMAKE_INSTALL_PREFIX=cmake-out \
  -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
  -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
  -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
  -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
  -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
  -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
  -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
  -DEXECUTORCH_BUILD_TESTS=ON \
  -Bcmake-out && \
  cmake --build cmake-out -j64 --target install)

@SS-JIA
Copy link
Contributor

SS-JIA commented Jan 6, 2025

After I use another implementation of mobilenetv2 it worked, don't know why

@dinusha94 just curious, what other implementation of mobilenetv2 did you try that resulted in it working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: doc Related to our documentation, both in docs/ and docblocks
Projects
None yet
Development

No branches or pull requests

4 participants