Skip to content

Commit 466d26f

Browse files
committed
sample: Add output file option
Some dependencies erroneously print diagnostic messages to stdout, mixing them with sampling result. -file option allows workaround this
1 parent 690036d commit 466d26f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sample.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ cmd:option('-temperature', 1)
1313
cmd:option('-gpu', 0)
1414
cmd:option('-gpu_backend', 'cuda')
1515
cmd:option('-verbose', 0)
16+
cmd:option('-output', '-')
1617
local opt = cmd:parse(arg)
1718

1819

@@ -39,4 +40,11 @@ if opt.verbose == 1 then print(msg) end
3940
model:evaluate()
4041

4142
local sample = model:sample(opt)
42-
print(sample)
43+
if opt.output == "-" then
44+
print(sample)
45+
else
46+
require 'io'
47+
local outfile = io.open(opt.output, "w")
48+
outfile:write(sample)
49+
outfile:close()
50+
end

0 commit comments

Comments
 (0)