Browse Source

fix(imperative): destruct dnn handles at last

GitOrigin-RevId: 7a67c68c55
tags/v1.9.0
Megvii Engine Team 3 years ago
parent
commit
1ce78aa09b
2 changed files with 9 additions and 1 deletions
  1. +2
    -1
      dnn/src/common/opr_delegate.h
  2. +7
    -0
      imperative/python/src/module.cpp

+ 2
- 1
dnn/src/common/opr_delegate.h View File

@@ -24,7 +24,8 @@ namespace megdnn {
* Usually used for calling other opr impls from some opr impl. You probably
* want to use CpuOprDelegationStorage instead.
*/
const std::shared_ptr<Handle>& inplace_cpu_handle(int debug_level = 0);
MGE_WIN_DECLSPEC_FUC const std::shared_ptr<Handle>& inplace_cpu_handle(
int debug_level = 0);

/*!
* \brief storage for oprs on inplace CPU handle


+ 7
- 0
imperative/python/src/module.cpp View File

@@ -14,6 +14,7 @@
#define DO_IMPORT_ARRAY
#include "./helper.h"
#include "./numpy_dtypes.h"
#include "megdnn/handle.h"

#include "./common.h"
#include "./graph_rt.h"
@@ -30,6 +31,10 @@ using namespace mgb::imperative::python;
#define MODULE_NAME imperative_rt
#endif

namespace megdnn {
extern const std::shared_ptr<Handle>& inplace_cpu_handle(int debug_level = 0);
}

PYBIND11_MODULE(MODULE_NAME, m) {
// initialize numpy
if ([]() {
@@ -39,6 +44,8 @@ PYBIND11_MODULE(MODULE_NAME, m) {
throw py::error_already_set();
}

megdnn::inplace_cpu_handle();

py::module::import("sys").attr("modules")[m.attr("__name__")] = m;

m.attr("__package__") = m.attr("__name__");


Loading…
Cancel
Save