From 04f33a1ccf813e97466decb98af452f69a66926e Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 16 Oct 2020 15:21:10 +0200 Subject: [PATCH] Save eval info in file --- cli/src/cli.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cli/src/cli.ts b/cli/src/cli.ts index 8ef9f0e..6eb385e 100644 --- a/cli/src/cli.ts +++ b/cli/src/cli.ts @@ -9,7 +9,6 @@ import { Options, sampleModel, testAllModels, testFloatConv } from '../..' -import { op } from '@tensorflow/tfjs' interface CmdOptions { debug?: boolean @@ -164,19 +163,24 @@ async function processModelFile(modelFile: string) { write(".js", cres.js) write(".ml4f", cres.machineCode) + let evalInfo = `\n*** ${built(options.basename + ".ml4f")}\n\n` + if (options.eval) { const ev = evalModel(cres, JSON.parse(fs.readFileSync(options.eval, "utf8"))) - console.log(`\n*** ${built(options.basename + ".ml4f")}\n${ev}`) + evalInfo += ev + "\n" } - console.log(cres.memInfo) - console.log(cres.timeInfo) + evalInfo += cres.memInfo + "\n" + evalInfo += cres.timeInfo + "\n" + + write(".txt", evalInfo + "\n") + + console.log("\n" + evalInfo) function write(ext: string, buf: string | Uint8Array) { const fn = built(options.basename + ext) const binbuf = typeof buf == "string" ? Buffer.from(buf, "utf8") : buf - if (!options.eval) - console.log(`write ${fn} (${binbuf.length} bytes)`) + console.log(`write ${fn} (${binbuf.length} bytes)`) fs.writeFileSync(fn, binbuf) } }