Unable to convert simplest PyTorch model

Hey @ivanstepanovftw,

Welcome to the Hailo Community!

It looks like the Hailo Dataflow Compiler might not natively support the nn.Embedding layer or the Gather operation from PyTorch during the ONNX translation process. This is likely because embedding layers and gather operations are more common in NLP models, while Hailo’s hardware and tools are more optimized for vision-based models.

Here’s how you can approach this:

  1. Embedding/Gather Workaround:
    Since Hailo doesn’t directly support these layers, you can preprocess the embeddings outside the Hailo pipeline. Instead of using nn.Embedding, convert your inputs into a one-hot encoded representation or use a precomputed embedding matrix before passing the data to Hailo. You can simulate the embedding behavior with a fully connected layer and export the modified model to ONNX.

  2. Input Shape Error:
    The error you’re seeing:

    UnsupportedGraphInputError: Couldn't find predecessors for node /0/Gather in the given model.
    

    suggests an issue with how the Gather node is structured. When you adjust the model to replace Gather, make sure the input tensor shape is explicitly defined and aligned with Hailo’s input requirements during the ONNX export.

  3. Alternative Approach:
    If modifying the embedding operation isn’t feasible, consider simplifying the model by removing unsupported layers, handling them as a preprocessing step, and only feeding compatible layers into the Hailo Dataflow Compiler.

Let me know if you’d like more details on how to implement these adjustments! I’d be happy to assist.

Best regards