apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators

Home Page:https://tvm.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

fhys opened this issue · comments

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 {