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

Commit

Permalink
set context for aux handle
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxihu committed Mar 12, 2019
1 parent 1f4626b commit 142ddcf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/mxnet/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,10 @@ class NDArray {
}
size_t aux_bytes = shape.Size() * mshadow::mshadow_sizeof(aux_types[i]);
if (aux_handles[i].size < aux_bytes) {
// set the context for aux handle to make sure we free it to the right device.
if (aux_handles[i].ctx.dev_type != ctx.dev_type) {
aux_handles[i].ctx = ctx;
}
// free storage and alloc again
Storage::Get()->Free(aux_handles[i]);
aux_handles[i] = Storage::Get()->Alloc(aux_bytes, ctx);
Expand Down

0 comments on commit 142ddcf

Please sign in to comment.