Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix invalid ndarray dispose (#14657)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhliu authored and reminisce committed Apr 10, 2019
1 parent da53b37 commit b096988
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Executor private[mxnet](private[mxnet] val handle: ExecutorHandle,
protected var monitorCallback: MXMonitorCallback = null
private val logger: Logger = LoggerFactory.getLogger(classOf[Executor])

private var reshaped = false

override def nativeAddress: CPtrAddress = handle
override def nativeDeAllocator: (CPtrAddress => Int) = _LIB.mxExecutorFree
// cannot determine the off-heap size of this object
Expand All @@ -71,12 +73,12 @@ class Executor private[mxnet](private[mxnet] val handle: ExecutorHandle,
if (!super.isDisposed) {
super.dispose()
outputs.foreach(o => o.dispose())
if (argArrays != null) {argArrays.foreach(a => a.dispose())}
if (gradArrays != null) {gradArrays.foreach(
if (reshaped && argArrays != null) {argArrays.foreach(a => a.dispose())}
if (reshaped && gradArrays != null) {gradArrays.foreach(
// Symbol will sometimes fill this with nulls so we've got to check the elements too
a => if (a != null) {a.dispose()})
}
if (auxArrays != null) {auxArrays.foreach(a => a.dispose())}
if (reshaped && auxArrays != null) {auxArrays.foreach(a => a.dispose())}
}
}

Expand Down Expand Up @@ -146,6 +148,7 @@ class Executor private[mxnet](private[mxnet] val handle: ExecutorHandle,
executor.argArrays = argArrays
executor.gradArrays = gradArrays
executor.auxArrays = auxArrays
executor.reshaped = true
executor
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ FCompType GetFCompute(const nnvm::Op* op, const std::string& name,
} else if (ctx.dev_mask() == gpu::kDevMask) {
return fcompute_gpu.get(op, nullptr);
} else {
LOG(FATAL) << "Unknown device mask";
LOG(FATAL) << "Unknown device mask " << ctx.dev_mask();
return nullptr;
}
}
Expand Down

0 comments on commit b096988

Please sign in to comment.