1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var __assign = (this && this.__assign) || function () {
|
19 | __assign = Object.assign || function(t) {
|
20 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
21 | s = arguments[i];
|
22 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
23 | t[p] = s[p];
|
24 | }
|
25 | return t;
|
26 | };
|
27 | return __assign.apply(this, arguments);
|
28 | };
|
29 | function __export(m) {
|
30 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
31 | }
|
32 | Object.defineProperty(exports, "__esModule", { value: true });
|
33 | var tf = require("@tensorflow/tfjs");
|
34 | var path = require("path");
|
35 | var callbacks_1 = require("./callbacks");
|
36 | var file_system_1 = require("./io/file_system");
|
37 | var nodeIo = require("./io/index");
|
38 | var nodejs_kernel_backend_1 = require("./nodejs_kernel_backend");
|
39 | var nodeVersion = require("./version");
|
40 |
|
41 | require("./kernels/all_kernels");
|
42 |
|
43 | var binary = require('node-pre-gyp');
|
44 | var bindingPath = binary.find(path.resolve(path.join(__dirname, '/../package.json')));
|
45 |
|
46 |
|
47 | var fs = require('fs');
|
48 | if (!fs.existsSync(bindingPath)) {
|
49 | throw new Error("The Node.js native addon module (tfjs_binding.node) can not "
|
50 | + "be found at path: " + String(bindingPath)
|
51 | + ". \nPlease run command "
|
52 | + "'npm rebuild @tensorflow/tfjs-node build-addon-from-source' to rebuild "
|
53 | + "the native addon module. \nIf you have problem with building the addon "
|
54 | + "module, please check https://github.com/tensorflow/tfjs/blob/master"
|
55 | + "/tfjs-node/WINDOWS_TROUBLESHOOTING.md or file an issue.");
|
56 | }
|
57 |
|
58 | var bindings = require(bindingPath);
|
59 |
|
60 | exports.version = __assign({}, tf.version, { 'tfjs-node': nodeVersion.version });
|
61 | exports.io = __assign({}, tf.io, nodeIo);
|
62 |
|
63 | __export(require("@tensorflow/tfjs"));
|
64 | __export(require("./node"));
|
65 |
|
66 | var pjson = require('../package.json');
|
67 | tf.registerBackend('tensorflow', function () {
|
68 | return new nodejs_kernel_backend_1.NodeJSKernelBackend(bindings, pjson.name);
|
69 | }, 3 );
|
70 | var success = tf.setBackend('tensorflow');
|
71 | if (!success) {
|
72 | throw new Error("Could not initialize TensorFlow backend.");
|
73 | }
|
74 |
|
75 | tf.io.registerLoadRouter(file_system_1.nodeFileSystemRouter);
|
76 | tf.io.registerSaveRouter(file_system_1.nodeFileSystemRouter);
|
77 |
|
78 | tf.registerCallbackConstructor(1, callbacks_1.ProgbarLogger);
|