Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Run TF and DL tests without restarting process #422

Open
ry opened this issue Mar 22, 2018 · 0 comments
Open

Run TF and DL tests without restarting process #422

ry opened this issue Mar 22, 2018 · 0 comments

Comments

@ry
Copy link
Contributor

ry commented Mar 22, 2018

Currently to switch backends, we need to restart Node with different environmental variables:

propel/tools/test.js

Lines 9 to 11 in 8b570f0

// Node.js tests
run.tsnode("tools/test_node.ts", {"PROPEL": "dl"}); // DL backend
run.tsnode("tools/test_node.ts", {"PROPEL": "tf"}); // TF backend

This could be done during runtime by improving this bit of code

propel/src/backend.ts

Lines 27 to 48 in 8b570f0

// These globals will be set by onLoad
export let backend: string;
export let bo: types.BackendOps;
let onLoadCalled = false;
(function onLoad() {
if (onLoadCalled) {
console.warn("Warning: backend.onLoad called more than once.");
return;
}
onLoadCalled = true;
if (preferTF() && tf.loadBinding()) {
console.log("Using TF backend.");
bo = new tf.OpsTF();
backend = "tf";
} else {
console.log("Using DL backend.");
bo = new dl.OpsDL();
backend = "dl";
}
})();

Once we can run both backends without restarting the process, it will be possible to augment the tester to run tests for both. That would be done here:

propel/tools/tester.ts

Lines 49 to 59 in 8b570f0

export function test(t: TestDefinition | TestFunction): void {
const fn: TestFunction = typeof t === "function" ? t : t.fn;
const name: string = t.name;
if (!name) {
throw new Error("Test function may not be anonymous");
}
if (filter(name)) {
tests.push({ fn, name });
}
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant