Skip to content

Commit

Permalink
[Toolchain] Implement inference function in ToolchainEnv (#1574)
Browse files Browse the repository at this point in the history
This commit implements inference function in ToolchainEnv.

ONE-vscode-DCO-1.0-Signed-off-by: Jiyoung Yun <[email protected]>
  • Loading branch information
jyoungyun authored Jun 1, 2023
1 parent ed89c8e commit 3b1a92f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Tests/Toolchain/ToolchainEnv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,17 @@ suite("Toolchain", function () {
);
});
});

suite("#inference()", function () {
test("NEG: requests unimplemented inference", async function () {
let env = new ToolchainEnv(compiler);
const invalidToolchain = env.listInstalled();
assert.isAbove(invalidToolchain.length, 0);
const model = "model.bin";
await env.inference(invalidToolchain[0], model).catch(() => {
assert.isTrue(true);
});
});
});
});
});
16 changes: 16 additions & 0 deletions src/Toolchain/ToolchainEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ class ToolchainEnv extends Env {
this.executeEnv(jobs);
});
}

public inference(
toolchain: Toolchain,
model: string,
options?: Map<string, string>
): Promise<string> {
return new Promise<string>((resolve, reject) => {
const jobs: Array<Job> = [];
const job = new JobConfig(toolchain.runInference(model, options));
job.workDir = path.dirname(model);
job.successCallback = () => resolve(job.result ? job.result : "");
job.failureCallback = () => reject();
jobs.push(job);
this.executeEnv(jobs);
});
}
}

/**
Expand Down

0 comments on commit 3b1a92f

Please sign in to comment.