-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd2a45a
commit ab5caa3
Showing
5 changed files
with
54 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Checkpointing" | ||
uuid = "eb46d486-4f9c-4c3d-b445-a617f2a2f1ca" | ||
authors = ["Michel Schanen <[email protected]>", "Sri Hari Krishna Narayanan <[email protected]>"] | ||
version = "0.9.6" | ||
version = "0.9.7" | ||
|
||
[deps] | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
struct ChkpDump | ||
steps::Int64 | ||
period::Int64 | ||
filename::String | ||
end | ||
|
||
ChkpDump(steps, ::Val{false}, period = 1, filename = "chkp") = nothing | ||
|
||
function ChkpDump(steps, ::Val{true}, period = 1, filename = "chkp") | ||
return ChkpDump( | ||
steps, period, filename, | ||
) | ||
end | ||
|
||
dump_prim(::Nothing, _, _) = nothing | ||
|
||
function dump_prim(chkp::ChkpDump, step, primal) | ||
if (step-1) % chkp.period == 0 | ||
blob = serialize(primal) | ||
open("prim_$(chkp.filename)_$step.chkp", "w") do file | ||
write(file, blob) | ||
end | ||
end | ||
end | ||
|
||
dump_adj(::Nothing, _, _) = nothing | ||
|
||
function dump_adj(chkp::ChkpDump, step, adjoint) | ||
@show step | ||
@show chkp.period | ||
@show step % chkp.period | ||
if (step-1) % chkp.period == 0 | ||
blob = serialize(adjoint) | ||
open("adj_$(chkp.filename)_$step.chkp", "w") do file | ||
write(file, blob) | ||
end | ||
end | ||
end | ||
|
||
read_chkp_file(filename) = deserialize(read(filename)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters