Skip to content

Commit

Permalink
fix mask rcnn error when run twice, test=develop (#2675) (#2709)
Browse files Browse the repository at this point in the history
add clear for tensor
  • Loading branch information
juncaipeng committed Dec 31, 2019
1 parent d56f25d commit cb246fc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lite/core/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Buffer {
if (space_ > 0) {
TargetFree(target_, data_);
}
data_ = nullptr;
target_ = TargetType::kHost;
space_ = 0;
}
Expand Down
4 changes: 4 additions & 0 deletions lite/core/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ class TensorLite {
(static_cast<char *>(buffer_->data()) + offset_));
}

void clear() {
buffer_->Free();
offset_ = 0;
}
size_t data_size() const { return this->dims().production(); }

size_t memory_size() const { return memory_size_; }
Expand Down
3 changes: 3 additions & 0 deletions lite/kernels/arm/conditional_block_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ void ConditionalBlockCompute::PrepareForRun() {
}
void ConditionalBlockCompute::Run() {
auto& param = Param<operators::ConditionalBlockParam>();
for (auto& out : param.outs) {
out->clear();
}
bool need_run = true;
if (param.is_scalar_condition) {
auto* cond = param.cond;
Expand Down
4 changes: 4 additions & 0 deletions lite/kernels/arm/split_lod_tensor_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ void SplitLodTensorCompute::Run() {
ranges.begin(), ranges.end(), 0UL, [](size_t a, const CopyRange &b) {
return a + b.end - b.begin;
});
if (height == 0) {
out->clear();
continue;
}
auto x_dim = x->dims();
x_dim[0] = static_cast<int64_t>(height);
out->Resize(x_dim);
Expand Down

0 comments on commit cb246fc

Please sign in to comment.