Skip to content

Commit c8d2283

Browse files
authored
Fix array pointers releasing with delete operator (#11328)
It may be safe to release POD-types array with `delete` operator, but `delete[]` is always better.
1 parent 07d91fa commit c8d2283

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/contrib/tf_op/tvm_dso_op_kernels.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class TVMDSOOpTrait<GPUDevice> {
207207
tensorflow::int64* dims = new tensorflow::int64[num_dims];
208208
cudaMemcpy(dims, flat, sizeof(tensorflow::int64) * num_dims, cudaMemcpyDeviceToHost);
209209
tensorflow::TensorShapeUtils::MakeShape(dims, num_dims, output_shape);
210-
delete dims;
210+
delete[] dims;
211211
}
212212
};
213213
#endif

src/target/metadata.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ class InMemoryMetadataNode : public ::tvm::target::metadata::VisitableMetadataNo
134134
}
135135

136136
private:
137-
::std::unique_ptr<struct TVMTensorInfo> inputs_;
137+
::std::unique_ptr<struct TVMTensorInfo[]> inputs_;
138138
std::vector<::tvm::runtime::metadata::TensorInfo> inputs_objs_;
139-
::std::unique_ptr<struct TVMTensorInfo> outputs_;
139+
::std::unique_ptr<struct TVMTensorInfo[]> outputs_;
140140
std::vector<::tvm::runtime::metadata::TensorInfo> outputs_objs_;
141-
::std::unique_ptr<struct TVMTensorInfo> pools_;
141+
::std::unique_ptr<struct TVMTensorInfo[]> pools_;
142142
std::vector<::tvm::runtime::metadata::TensorInfo> pools_objs_;
143143
::std::string mod_name_;
144144
struct ::TVMMetadata storage_;
@@ -186,7 +186,7 @@ class InMemoryTensorInfoNode : public ::tvm::target::metadata::VisitableTensorIn
186186

187187
private:
188188
::std::string name_;
189-
::std::unique_ptr<int64_t> shape_;
189+
::std::unique_ptr<int64_t[]> shape_;
190190
struct ::TVMTensorInfo storage_;
191191
};
192192

0 commit comments

Comments
 (0)