|
8 | 8 | * ============================================================================= |
9 | 9 | */ |
10 | 10 |
|
11 | | -import {DataType, io, memory, ones, randomNormal, Scalar, scalar, serialization, sum, Tensor, tensor1d, tensor2d, tensor3d, train, zeros, util} from '@tensorflow/tfjs-core'; |
| 11 | +import {DataType, ENV, io, memory, ones, randomNormal, Scalar, scalar, serialization, sum, Tensor, tensor1d, tensor2d, tensor3d, train, zeros} from '@tensorflow/tfjs-core'; |
12 | 12 | import {ConfigDict} from '@tensorflow/tfjs-core/dist/serialization'; |
13 | 13 |
|
14 | 14 | import {LayersModel} from './engine/training'; |
@@ -549,7 +549,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
549 | 549 | const setupFakeWeightFiles = |
550 | 550 | (fileBufferMap: |
551 | 551 | {[filename: string]: Float32Array|Int32Array|ArrayBuffer}) => { |
552 | | - spyOn(util, 'fetch') |
| 552 | + spyOn(ENV.platform, 'fetch') |
553 | 553 | .and.callFake((path: string) => new Promise(resolve => { |
554 | 554 | resolve(new Response(fileBufferMap[path], { |
555 | 555 | 'headers': {'Content-Type': OCTET_STREAM_TYPE} |
@@ -631,7 +631,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
631 | 631 | } |
632 | 632 | ]; |
633 | 633 |
|
634 | | - spyOn(util, 'fetch').and.callFake((path: string) => { |
| 634 | + spyOn(ENV.platform, 'fetch').and.callFake((path: string) => { |
635 | 635 | return new Promise((resolve, reject) => { |
636 | 636 | if (path === 'model/model.json') { |
637 | 637 | resolve(new Response( |
@@ -683,7 +683,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
683 | 683 | } |
684 | 684 | ]; |
685 | 685 |
|
686 | | - spyOn(util, 'fetch').and.callFake((path: string) => { |
| 686 | + spyOn(ENV.platform, 'fetch').and.callFake((path: string) => { |
687 | 687 | return new Promise((resolve, reject) => { |
688 | 688 | if (path === 'model/model.json') { |
689 | 689 | resolve(new Response( |
@@ -743,7 +743,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
743 | 743 | } |
744 | 744 | ]; |
745 | 745 |
|
746 | | - spyOn(util, 'fetch').and.callFake((path: string) => { |
| 746 | + spyOn(ENV.platform, 'fetch').and.callFake((path: string) => { |
747 | 747 | return new Promise((resolve, reject) => { |
748 | 748 | if (path === 'https://url/to/model/model.json') { |
749 | 749 | resolve(new Response( |
@@ -806,7 +806,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
806 | 806 |
|
807 | 807 | const kernelData = ones([32, 32], 'float32').dataSync() as Float32Array; |
808 | 808 | const biasData = zeros([32], 'float32').dataSync() as Float32Array; |
809 | | - spyOn(util, 'fetch').and.callFake((path: string) => { |
| 809 | + spyOn(ENV.platform, 'fetch').and.callFake((path: string) => { |
810 | 810 | return new Promise((resolve, reject) => { |
811 | 811 | if (path === 'model/model.json') { |
812 | 812 | resolve(new Response( |
@@ -871,7 +871,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
871 | 871 | [{'name': `dense_2/bias`, 'dtype': 'float32', 'shape': [1]}], |
872 | 872 | } |
873 | 873 | ]; |
874 | | - spyOn(util, 'fetch').and.callFake((path: string) => { |
| 874 | + spyOn(ENV.platform, 'fetch').and.callFake((path: string) => { |
875 | 875 | return new Promise((resolve, reject) => { |
876 | 876 | if (path === 'model/model.json') { |
877 | 877 | resolve(new Response( |
@@ -940,7 +940,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
940 | 940 | 'weights': [{'name': `dense_2/bias`, 'dtype': 'float32', 'shape': [1]}], |
941 | 941 | } |
942 | 942 | ]; |
943 | | - spyOn(util, 'fetch').and.callFake((path: string) => { |
| 943 | + spyOn(ENV.platform, 'fetch').and.callFake((path: string) => { |
944 | 944 | return new Promise((resolve, reject) => { |
945 | 945 | if (path === 'model/model.json') { |
946 | 946 | resolve(new Response( |
@@ -1007,7 +1007,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
1007 | 1007 |
|
1008 | 1008 | const requestHeaders: Array<{[key: string]: string | {}}> = []; |
1009 | 1009 | const requestCredentials: string[] = []; |
1010 | | - spyOn(util, 'fetch') |
| 1010 | + spyOn(ENV.platform, 'fetch') |
1011 | 1011 | .and.callFake((path: string, requestInit?: RequestInit) => { |
1012 | 1012 | if (requestInit != null) { |
1013 | 1013 | requestHeaders.push(requestInit.headers as {}); |
@@ -1085,7 +1085,7 @@ describeMathCPU('loadLayersModel from URL', () => { |
1085 | 1085 | [{'name': `dense_6/bias`, 'dtype': 'float32', 'shape': [32]}], |
1086 | 1086 | } |
1087 | 1087 | ]; |
1088 | | - spyOn(util, 'fetch').and.callFake((path: string) => { |
| 1088 | + spyOn(ENV.platform, 'fetch').and.callFake((path: string) => { |
1089 | 1089 | return new Promise((resolve, reject) => { |
1090 | 1090 | if (path === `${protocol}localhost:8888/models/model.json`) { |
1091 | 1091 | resolve(new Response( |
|
0 commit comments