Git Product home page Git Product logo

Comments (12)

antkillerfarm avatar antkillerfarm commented on August 29, 2024 1

Thanks. I can reproduce this bug now.
I find that the the rules for generate TVM IR are different between tflite and pytorch. I will fix it ASAP.

from tim-vx.

sunshinemyson avatar sunshinemyson commented on August 29, 2024

which model get this error ? and which branch of tvm you are using? Thanks

from tim-vx.

sidphbot avatar sidphbot commented on August 29, 2024

the vsi_npu branch of github.com/VeriSilicon/tvm fork, the model is a modification of mobilenet pytorch, errors while building with relay from both quantized and normal versions are given above, linux build works fine when not using vsi_npu partitioning

from tim-vx.

antkillerfarm avatar antkillerfarm commented on August 29, 2024

Could you give me your pytorch model file? Random weights is good enough for our debug.

from tim-vx.

sidphbot avatar sidphbot commented on August 29, 2024

Apologies for the delay, Unfortunately i cannot provide you the exact model however I could reproduce the same behaviour difference with/without vsi_npu with a quantized mobilenetv2 from torchvision, here is the full code for reproducing the issue,

tvm: vsi_npu branch of github.com/VeriSilicon/tvm fork

import torch
import torchvision
import tvm
from tvm import relay
from tvm.relay.op.contrib import vsi_npu


model_quantized = torchvision.models.quantization.mobilenet_v2(pretrained=True, quantize=True)
dummy_input = torch.rand(1, 3, 224, 224)
scripted_model = torch.jit.trace(model_quantized, dummy_input).eval()
mod, params = relay.frontend.from_pytorch(scripted_model, [('input', dummy_input.shape)])

'''
working alternative code without vsi_npu

target_string = "llvm -mtriple=x86_64-linux-gnu"              # linux host-triple
with tvm.transform.PassContext(opt_level=3, disabled_pass=None):
        lib = relay.build(mod, target_string, params=params)      # no error #
lib.export_library('deploy_test.so')
'''

target_string = "llvm  -mtriple=aarch64-linux-gnu"              # imx8 host-triple
kwargs = {"cc": "aarch64-linux-gnu-gcc", 'fcompile': False}
disabled_passes = ["AlterOpLayout"]                                     # same error with None
with tvm.transform.PassContext(opt_level=3, disabled_pass=disabled_passes):
        mod = vsi_npu.partition_for_vsi_npu(mod, params)           # runs fine
        lib = relay.build(mod, target_string, params=params)        # error #
lib.export_library('deploy_failed.so',  **kwargs)

from tim-vx.

antkillerfarm avatar antkillerfarm commented on August 29, 2024

Could you give me your pip list? I meet some error when run:

mod, params = relay.frontend.from_pytorch(scripted_model, [('input', dummy_input.shape)])

error info:

RuntimeError       (note: full exception trace is shown but execution is paused at: <module>)
ArrayRef: invalid index Index = 6; Length = 6
  File "/lhome/tangjing/my/antkillerfarm_crazy/python/ml/pytorch/pytorch2tvm.py", line 13, in <module> (Current frame)
    mod, params = relay.frontend.from_pytorch(scripted_model, [('input', dummy_input.shape)])

from tim-vx.

sidphbot avatar sidphbot commented on August 29, 2024

piplist.txt
however the error for you could be due to torchvision version or originating from tvm, which I have installed from source using cmake instructions from https://github.com/VeriSilicon/tvm/blob/vsi_npu/README.VSI.md - i have also attached my build script here for tim-vx and tvm (change ext from .txt to .sh and execute with bash)
tvm-install.txt

from tim-vx.

sunshinemyson avatar sunshinemyson commented on August 29, 2024

@antkillerfarm ,

Maybe we should add some rule in TVM framework, not in the codegen part, because:
Same convolution is expressed in different ways in PyTorch and tflite, this could be aligned in tvm, so that we can handle it with single pattern.

from tim-vx.

sidphbot avatar sidphbot commented on August 29, 2024

@antkillerfarm @sunshinemyson did you get a chance to look into this?

from tim-vx.

antkillerfarm avatar antkillerfarm commented on August 29, 2024

I am handling this issue from last two weeks, but still have some problems on pytorch import...

from tim-vx.

sidphbot avatar sidphbot commented on August 29, 2024

thank you for looking into it..
i don't know if this may help(maybe comparable or can be rebased with supervision) but the vsi_npu partitioning module works for pytorch(un-quantized) models from NXP tvm fork
this fork however is still on tvm stable version 0.7.0 meaning it does not have pytorch changes that allow quantized models as well, hence we are depending on versilicon's fork of tvm as it has vsi_npu module along with the latest tvm pytorch changes

from tim-vx.

antkillerfarm avatar antkillerfarm commented on August 29, 2024

@sidphbot You can try this branch:
https://github.com/VeriSilicon/tvm/tree/upstream/vsi_npu
with latest TIM-VX.
torchvision.models.quantization.mobilenet_v2 is OK now.

Our old tvm branch is not maintained now. We update the code base, and plan to upstream our code to official tvm repo.

from tim-vx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.