File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,14 @@ import {isArray, isNullOrUndefined} from 'util';
21
21
import { NodeJSKernelBackend } from '../nodejs_kernel_backend' ;
22
22
import { TFEOpAttr } from '../tfjs_binding' ;
23
23
24
+ let gBackend : NodeJSKernelBackend = null ;
25
+
24
26
/** Returns an instance of the Node.js backend. */
25
27
export function nodeBackend ( ) : NodeJSKernelBackend {
26
- return ( tfc . ENV . findBackend ( 'tensorflow' ) as NodeJSKernelBackend ) ;
28
+ if ( gBackend === null ) {
29
+ gBackend = ( tfc . ENV . findBackend ( 'tensorflow' ) as NodeJSKernelBackend ) ;
30
+ }
31
+ return gBackend ;
27
32
}
28
33
29
34
/** Returns the TF dtype for a given DataType. */
Original file line number Diff line number Diff line change @@ -22,22 +22,15 @@ Error.stackTraceLimit = Infinity;
22
22
23
23
// tslint:disable-next-line:no-require-imports
24
24
const jasmineCtor = require ( 'jasmine' ) ;
25
-
26
25
// tslint:disable-next-line:no-require-imports
27
- import bindings = require( 'bindings' ) ;
28
- import { TFJSBinding } from './tfjs_binding' ;
29
- import { NodeJSKernelBackend } from './nodejs_kernel_backend' ;
26
+ import { nodeBackend } from './ops/op_utils' ;
30
27
31
28
process . on ( 'unhandledRejection' , e => {
32
29
throw e ;
33
30
} ) ;
34
31
35
- jasmine_util . setTestEnvs ( [ {
36
- name : 'test-tensorflow' ,
37
- factory : ( ) =>
38
- new NodeJSKernelBackend ( bindings ( 'tfjs_binding.node' ) as TFJSBinding ) ,
39
- features : { }
40
- } ] ) ;
32
+ jasmine_util . setTestEnvs (
33
+ [ { name : 'test-tensorflow' , factory : ( ) => nodeBackend ( ) , features : { } } ] ) ;
41
34
42
35
const IGNORE_LIST : string [ ] = [
43
36
// See https://github.com/tensorflow/tfjs/issues/161
@@ -72,6 +65,6 @@ env.specFilter = spec => {
72
65
} ;
73
66
74
67
// TODO(kreeger): Consider moving to C-code.
75
- console . log ( `Running tests against TensorFlow: ${
76
- ( bindings ( 'tfjs_binding.node' ) as TFJSBinding ) . TF_Version } `) ;
68
+ console . log (
69
+ `Running tests against TensorFlow: ${ nodeBackend ( ) . binding . TF_Version } `) ;
77
70
runner . execute ( ) ;
You can’t perform that action at this time.
0 commit comments