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

BugFix on Operators not updating streams in temp space #74

Merged
merged 2 commits into from
Sep 14, 2015
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
15 changes: 9 additions & 6 deletions src/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ inline int MXAPIGetFunctionRegInfo(const FunRegType *e,
API_END();
}

int MXEngineWaitAll() {
API_BEGIN();
Engine::Get()->WaitForAll();
API_END();
}

// NOTE: return value is added in API_END
int MXNDArrayCreateNone(NDArrayHandle *out) {
API_BEGIN();
Expand Down Expand Up @@ -323,12 +329,6 @@ int MXNDArrayListLoad(const char* fname,
API_END();
}

int MXNDArrayWaitAll() {
API_BEGIN();
Engine::Get()->WaitForAll();
API_END();
}

int MXNDArrayFree(NDArrayHandle handle) {
API_BEGIN();
delete static_cast<NDArray*>(handle);
Expand Down Expand Up @@ -817,6 +817,9 @@ int MXDataIterBeforeFirst(DataIterHandle handle) {

int MXDataIterNext(DataIterHandle handle, int *out) {
API_BEGIN();
// TODO(tianjun): remove this after having prefetcher by default.
// and call NArray.WaitForWrite instead.
Engine::Get()->WaitForAll();
*out = static_cast<IIterator<DataBatch>* >(handle)->Next();
API_END();
}
Expand Down
4 changes: 2 additions & 2 deletions src/operator/batch_norm-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ class BatchNormOp : public Operator {
// TODO(bing): use global memory allocator
inline void Init(const OpContext &ctx,
const mshadow::Shape<4> &dshape) {
if (is_init) return;
is_init = true;
mshadow::Stream<xpu> *s = ctx.get_stream<xpu>();
tmp_.set_stream(s);
if (is_init) return;
is_init = true;
tmp_.Resize(mshadow::Shape2(3, dshape[1]));
}
mshadow::TensorContainer<xpu, 2> tmp_;
Expand Down
2 changes: 1 addition & 1 deletion src/operator/cudnn_convolution-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ class CuDNNConvolutionOp : public Operator {
size_t expected = param_.no_bias ? 2 : 3;
CHECK_EQ(in_data.size(), expected);
CHECK_EQ(out_data.size(), 1);
temp_.set_stream(s);
if (!init_cudnn_) {
init_cudnn_ = true;
temp_.set_stream(s);
size_t workspace = static_cast<size_t>(param_.workspace);
size_t back_size = 0;
size_t back_size_w = 0;
Expand Down