[Model] Add skip valid backend check option -> FastDeployModel (#1445)

* [Model] Add skip valid backend check option -> FastDeployModel

* [Model] Add skip valid backend check option -> FastDeployModel

* [Model] Add skip valid backend check option -> FastDeployModel
This commit is contained in:
DefTruth
2023-02-27 15:37:01 +08:00
committed by GitHub
parent 6f8d4d14c2
commit 7e5e690367
2 changed files with 23 additions and 1 deletions

View File

@@ -49,9 +49,20 @@ bool FastDeployModel::IsSupported(const std::vector<Backend>& backends,
<< "the backend [" << backend << "the backend [" << backend
<< "] is supported for current model!" << std::endl; << "] is supported for current model!" << std::endl;
return true; return true;
} else if (!enable_valid_backend_check_) {
FDWARNING << "Checking for valid backend is disable, we don't"
<< " check to see if the backend [" << backend
<< "] is supported for current model!" << std::endl;
return true;
} }
return CheckBackendSupported(backends, backend); return CheckBackendSupported(backends, backend);
#else #else
if (!enable_valid_backend_check_) {
FDWARNING << "Checking for valid backend is disable, we don't"
<< " check to see if the backend [" << backend
<< "] is supported for current model!" << std::endl;
return true;
}
return CheckBackendSupported(backends, backend); return CheckBackendSupported(backends, backend);
#endif #endif
} }

View File

@@ -121,7 +121,16 @@ class FASTDEPLOY_DECL FastDeployModel {
virtual double GetProfileTime() { virtual double GetProfileTime() {
return runtime_->GetProfileTime(); return runtime_->GetProfileTime();
} }
/** \brief Enable to check if current backend set by user can be found at valid_xxx_backend.
*/
virtual void EnableValidBackendCheck() {
enable_valid_backend_check_ = true;
}
/** \brief Disable to check if current backend set by user can be found at valid_xxx_backend.
*/
virtual void DisableValidBackendCheck() {
enable_valid_backend_check_ = false;
}
/** \brief Release reused input/output buffers /** \brief Release reused input/output buffers
*/ */
virtual void ReleaseReusedBuffer() { virtual void ReleaseReusedBuffer() {
@@ -170,6 +179,8 @@ class FASTDEPLOY_DECL FastDeployModel {
// whether to record inference time // whether to record inference time
bool enable_record_time_of_runtime_ = false; bool enable_record_time_of_runtime_ = false;
std::vector<double> time_of_runtime_; std::vector<double> time_of_runtime_;
// enable the check for valid backend, default true.
bool enable_valid_backend_check_ = true;
}; };
} // namespace fastdeploy } // namespace fastdeploy