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

[Numpy] fix invalid ndarray dispose #14657

Merged
merged 1 commit into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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