Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions KLR/Compile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ open Pass (CompileResult)

private partial def uniqueName (dst : String) (base : String) : IO String := do
let fName := s!"{dst}/{base}.npy"
if ← FilePath.pathExists (FilePath.mk fName) then
let suffix ← IO.rand 0 (2^64 - 1)
uniqueName dst s!"{base}_{suffix}"
else
if !(← FilePath.pathExists (FilePath.mk fName)) then
return base
let entries ← System.FilePath.readDir (FilePath.mk dst)
let count := entries.filter (fun e =>
e.fileName.startsWith s!"{base}_" && e.fileName.endsWith ".npy") |>.size
let gen := mkStdGen count
let (suffix, _) := RandomGen.next gen
let suffix := suffix % (2^64)
uniqueName dst s!"{base}_{suffix}"

private def sharedConstant
(outfolder : String)
Expand Down