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

[Bug] [VTA] A type error of vta::dpi::DPIModule::GetFunction' parameters #16853

Open
fhys opened this issue Apr 7, 2024 · 0 comments
Open

[Bug] [VTA] A type error of vta::dpi::DPIModule::GetFunction' parameters #16853

fhys opened this issue Apr 7, 2024 · 0 comments
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@fhys
Copy link

fhys commented Apr 7, 2024

The TVM version I used: a156181ee3242407aa3c0e1565c18896b9d2f06b

I tried to follow the VTA installation tutorial and enable the USE_VTA_FSIM and USE_VTA_TSIM option. However, I encountered an error while compiling the VTA-related parts, which does not occur when the VTA corresponding option is disabled. The error message given by the compiler is as follows:

 /home/lhw/softwares/tvm/3rdparty/vta-hw/src/dpi/module.cc:284:14: error: ‘tvm::runtime::PackedFunc vta::dpi::DPIModule::GetFunction(const std::string&, const tvm::runtime::ObjectPtr<tvm::runtime::Object>&)’ marked ‘final’, but is not virtual
  284 |   PackedFunc GetFunction(
      |              ^~~~~~~~~~~
In file included from /home/lhw/softwares/tvm/include/tvm/runtime/container/base.h:29,
                 from /home/lhw/softwares/tvm/include/tvm/runtime/container/string.h:29,
                 from /home/lhw/softwares/tvm/include/tvm/runtime/module.h:31,
                 from /home/lhw/softwares/tvm/3rdparty/vta-hw/src/dpi/module.cc:21:
/home/lhw/softwares/tvm/include/tvm/runtime/memory.h: In instantiation of ‘static T* tvm::runtime::SimpleObjAllocator::Handler<T>::New(tvm::runtime::SimpleObjAllocator*, Args&& ...) [with Args = {}; T = vta::dpi::DPIModule]’:
/home/lhw/softwares/tvm/include/tvm/runtime/memory.h:72:26:   required from ‘tvm::runtime::ObjectPtr<U> tvm::runtime::ObjAllocatorBase< <template-parameter-1-1> >::make_object(Args&& ...) [with T = vta::dpi::DPIModule; Args = {}; Derived = tvm::runtime::SimpleObjAllocator]’
/home/lhw/softwares/tvm/include/tvm/runtime/memory.h:196:45:   required from ‘tvm::runtime::ObjectPtr<U> tvm::runtime::make_object(Args&& ...) [with T = vta::dpi::DPIModule; Args = {}]’
/home/lhw/softwares/tvm/3rdparty/vta-hw/src/dpi/module.cc:520:34:   required from here
/home/lhw/softwares/tvm/include/tvm/runtime/memory.h:122:7: error: invalid new-expression of abstract class type ‘vta::dpi::DPIModule’
  122 |       new (data) T(std::forward<Args>(args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/lhw/softwares/tvm/3rdparty/vta-hw/src/dpi/module.cc:274:7: note:   because the following virtual functions are pure within ‘vta::dpi::DPIModule’:
  274 | class DPIModule final : public DPIModuleNode {
      |       ^~~~~~~~~
/home/lhw/softwares/tvm/include/tvm/runtime/module.h:168:22: note:     ‘virtual tvm::runtime::PackedFunc tvm::runtime::ModuleNode::GetFunction(const tvm::runtime::String&, const tvm::runtime::ObjectPtr<tvm::runtime::Object>&)’
  168 |   virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>& sptr_to_self) = 0;

I have identified that the cause of this error is due to the type of parameter name in GetFunction. On include/tvm/runtime/module.h line 168, in the definition of the pure virtual function GetFunction, the type of 'name' is specified as 'tvm::runtime::String'.

virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>& sptr_to_self) = 0;

However, in the vta runtime file '3rdparty/vta-hw/src/dpi/module.cc' on line 285, the type of 'name' is 'std::string'. This inconsistency causes the compiler to believe that the pure virtual function GetFunction has not been implemented.

  PackedFunc GetFunction(
      const std::string& name,
      const ObjectPtr<Object>& sptr_to_self) final {
    if (name == "WriteReg") {
      return TypedPackedFunc<void(int, int)>(
        [this](int addr, int value){
           this->WriteReg(addr, value);
        });
    } else {
      LOG(FATAL) << "Member " << name << "does not exists";
      return nullptr;
    }
  }

According to the implementation of GetFunction in apps/dso_plugin_module/plugin_module.cc, I modified the type of name to 'tvm::runtime::String' in VTA, and then successfully compiled it.

  PackedFunc GetFunction(
      const String& name,
      const ObjectPtr<Object>& sptr_to_self) final {
@fhys fhys added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

No branches or pull requests

1 participant