This commit is contained in:
Michal Moskal 2020-10-16 15:21:10 +02:00
Родитель 48988a31f1
Коммит 04f33a1ccf
1 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -9,7 +9,6 @@ import {
Options, sampleModel, testAllModels, Options, sampleModel, testAllModels,
testFloatConv testFloatConv
} from '../..' } from '../..'
import { op } from '@tensorflow/tfjs'
interface CmdOptions { interface CmdOptions {
debug?: boolean debug?: boolean
@ -164,19 +163,24 @@ async function processModelFile(modelFile: string) {
write(".js", cres.js) write(".js", cres.js)
write(".ml4f", cres.machineCode) write(".ml4f", cres.machineCode)
let evalInfo = `\n*** ${built(options.basename + ".ml4f")}\n\n`
if (options.eval) { if (options.eval) {
const ev = evalModel(cres, JSON.parse(fs.readFileSync(options.eval, "utf8"))) 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) evalInfo += cres.memInfo + "\n"
console.log(cres.timeInfo) evalInfo += cres.timeInfo + "\n"
write(".txt", evalInfo + "\n")
console.log("\n" + evalInfo)
function write(ext: string, buf: string | Uint8Array) { function write(ext: string, buf: string | Uint8Array) {
const fn = built(options.basename + ext) const fn = built(options.basename + ext)
const binbuf = typeof buf == "string" ? Buffer.from(buf, "utf8") : buf 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) fs.writeFileSync(fn, binbuf)
} }
} }