MCPcopy Index your code
hub / github.com/tensorflow/tfjs / setupFakeWeightFiles

Function setupFakeWeightFiles

tfjs-node/src/io/node_http_test.ts:66–88  ·  view source on GitHub ↗
(fileBufferMap: {
    [filename: string]: string|Float32Array|Int32Array|ArrayBuffer|Uint8Array|
    Uint16Array
  })

Source from the content-addressed store, hash-verified

64describe('nodeHTTPRequest-load', () => {
65 let requestInits: RequestInit[];
66 const setupFakeWeightFiles = (fileBufferMap: {
67 [filename: string]: string|Float32Array|Int32Array|ArrayBuffer|Uint8Array|
68 Uint16Array
69 }) => {
70 spyOn(tf.env().platform, 'fetch')
71 .and.callFake((path: string, init: RequestInit) => {
72 return new Promise((resolve, reject) => {
73 let contentType = '';
74 if (path.endsWith('model.json')) {
75 contentType = JSON_TYPE;
76 } else if (
77 path.endsWith('weightfile0') || path.endsWith('weightfile1')) {
78 contentType = OCTET_STREAM_TYPE;
79 } else {
80 reject(new Error(`Invalid path: ${path}`));
81 }
82 requestInits.push(init);
83 resolve(new fetch.Response(
84 fileBufferMap[path],
85 {'headers': {'Content-Type': contentType}}));
86 });
87 });
88 };
89
90 beforeEach(() => {
91 requestInits = [];

Callers 1

node_http_test.tsFile · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…