Skip to content

Commit 8f75825

Browse files
authored
Merge pull request #86 from danieldk/run-leak
Session runs leak memory
2 parents 701d5ec + 88fc163 commit 8f75825

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/session.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,6 @@ impl Session {
8484

8585
/// Runs the graph, feeding the inputs and then fetching the outputs requested in the step.
8686
pub fn run(&mut self, step: &mut StepWithGraph) -> Result<()> {
87-
// Copy the input tensors because TF_Run consumes them.
88-
let mut input_tensors = Vec::with_capacity(step.input_tensors.len());
89-
for &input_tensor in &step.input_tensors {
90-
unsafe {
91-
let mut dims = Vec::with_capacity(tf::TF_NumDims(input_tensor) as usize);
92-
for i in 0..dims.capacity() {
93-
dims.push(tf::TF_Dim(input_tensor, i as c_int));
94-
}
95-
input_tensors.push(tf::TF_NewTensor(tf::TF_TensorType(input_tensor),
96-
dims.as_ptr(),
97-
dims.len() as c_int,
98-
tf::TF_TensorData(input_tensor),
99-
tf::TF_TensorByteSize(input_tensor),
100-
Some(super::noop_deallocator),
101-
ptr::null_mut()));
102-
}
103-
}
104-
10587
// In case we're running it a second time and not all outputs were taken out.
10688
step.drop_output_tensors();
10789

@@ -110,8 +92,8 @@ impl Session {
11092
tf::TF_SessionRun(self.inner,
11193
ptr::null(),
11294
step.input_ports.as_ptr(),
113-
input_tensors.as_ptr() as *const *const tf::TF_Tensor,
114-
input_tensors.len() as c_int,
95+
step.input_tensors.as_ptr() as *const *const tf::TF_Tensor,
96+
step.input_tensors.len() as c_int,
11597
step.output_ports.as_ptr(),
11698
step.output_tensors.as_mut_ptr(),
11799
step.output_tensors.len() as c_int,

0 commit comments

Comments
 (0)