You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/04/02 08:01:44 UTC

[GitHub] [tvm] eleflea commented on issue #7782: Floating point exception when deploying model with C++ API

eleflea commented on issue #7782:
URL: https://github.com/apache/tvm/issues/7782#issuecomment-812401353


   Don't know why but i solved it. We should hold both `lib_factory` and `gmod`. Which means:
   
   ```C++
   class YoloDetection
   {
   public:
       YoloDetection() {}
       ~YoloDetection();
       YoloDetection(string, string);
       vector<Det> predict(const cv::Mat &);
       void load(string, string);
   
       float conf_thresh = 0.4;
       float nms_thresh = 0.6;
       int max_dets = 300;
       int max_wh = 4096;
   
   protected:
       string lib_path = "";
       DLContext device;
       DLTensor *input_tensor = nullptr;
       tvm::runtime::Module lib_factory;
       tvm::runtime::Module gmod;
   };
   
   YoloDetection::~YoloDetection()
   {
       if (input_tensor != nullptr)
           TVMArrayFree(input_tensor);
   }
   
   YoloDetection::YoloDetection(string lib_path, string device) : lib_path(lib_path)
   {
       this->device = device == "gpu" ? DLContext{kDLGPU, 0} : DLContext{kDLCPU, 0};
       lib_factory = tvm::runtime::Module::LoadFromFile(lib_path);
       gmod = lib_factory.GetFunction("default")(this->device);
       int64_t in_shape[4] = {1, 3, IN_SIZE_H, IN_SIZE_W};
       TVMArrayAlloc(in_shape, 4, kDLFloat, 32, 1, kDLGPU, 0, &input_tensor);
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org