Skip to content

Commit cb246fc

Browse files
authored
fix mask rcnn error when run twice, test=develop (#2675) (#2709)
add clear for tensor
1 parent d56f25d commit cb246fc

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

lite/core/memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class Buffer {
120120
if (space_ > 0) {
121121
TargetFree(target_, data_);
122122
}
123+
data_ = nullptr;
123124
target_ = TargetType::kHost;
124125
space_ = 0;
125126
}

lite/core/tensor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ class TensorLite {
176176
(static_cast<char *>(buffer_->data()) + offset_));
177177
}
178178

179+
void clear() {
180+
buffer_->Free();
181+
offset_ = 0;
182+
}
179183
size_t data_size() const { return this->dims().production(); }
180184

181185
size_t memory_size() const { return memory_size_; }

lite/kernels/arm/conditional_block_compute.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ void ConditionalBlockCompute::PrepareForRun() {
3434
}
3535
void ConditionalBlockCompute::Run() {
3636
auto& param = Param<operators::ConditionalBlockParam>();
37+
for (auto& out : param.outs) {
38+
out->clear();
39+
}
3740
bool need_run = true;
3841
if (param.is_scalar_condition) {
3942
auto* cond = param.cond;

lite/kernels/arm/split_lod_tensor_compute.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ void SplitLodTensorCompute::Run() {
8282
ranges.begin(), ranges.end(), 0UL, [](size_t a, const CopyRange &b) {
8383
return a + b.end - b.begin;
8484
});
85+
if (height == 0) {
86+
out->clear();
87+
continue;
88+
}
8589
auto x_dim = x->dims();
8690
x_dim[0] = static_cast<int64_t>(height);
8791
out->Resize(x_dim);

0 commit comments

Comments
 (0)