Skip to content

Commit 7c07aa9

Browse files
committed
added explicit flush api call
1 parent 9c7ceb0 commit 7c07aa9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sample.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ public class TensorBoardFileWriter
2626

2727
[DllImport("TensorBoardFileWriter.dll")]
2828
public static extern void WriteValue(IntPtr writer, [MarshalAs(UnmanagedType.LPWStr)] string name, float value, long step);
29+
30+
[DllImport("TensorBoardFileWriter.dll")]
31+
public static extern void Flush(IntPtr writer);
2932

3033
private readonly IntPtr writer;
3134
public TensorBoardFileWriter(string dir) => this.writer = OpenWriter(dir);
3235

3336
~TensorBoardFileWriter() => CloseWriter(this.writer);
3437

35-
public void WriteValue(string name, float value, long step) => WriteValue (this.writer, name, value, step);
38+
public void WriteValue(string name, float value, long step) => WriteValue(this.writer, name, value, step);
39+
40+
public void Flush() => Flush(this.writer);
3641

3742
// create ProgressWriterVector with attached native progress writer
3843
public static ProgressWriterVector CreateVector(string path, Function network)
@@ -102,6 +107,7 @@ static public void TrainAndEvaluate(DeviceDescriptor device)
102107

103108
progressWriter.WriteValue("random1", (float)random.Next(), minibatchCount);
104109
progressWriter.WriteValue("random2", (float)random.Next(), minibatchCount);
110+
progressWriter.Flush();
105111
}
106112

107113
// test and validate the model

TensorBoardFileWriter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,10 @@ extern "C"
113113
auto ptr = (CNTK::Internal::TensorBoardFileWriter*)fileWriter;
114114
ptr->WriteValue(name, value, step);
115115
}
116+
117+
API void Flush(void* fileWriter)
118+
{
119+
auto ptr = (CNTK::Internal::TensorBoardFileWriter*)fileWriter;
120+
ptr->Flush();
121+
}
116122
}

0 commit comments

Comments
 (0)