Skip to content

Commit b21b302

Browse files
Do not export 'CompositeArrayBuffer' from tfjs-core
1 parent 4d22064 commit b21b302

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

tfjs-converter/src/executor/graph_model_test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ describe('Model', () => {
586586
expect(handler.savedArtifacts.modelTopology).toEqual(CUSTOM_OP_MODEL);
587587
expect(handler.savedArtifacts.weightSpecs).toEqual(weightsManifest);
588588
tfc.test_util.expectArraysClose(
589-
new Int32Array(new io.CompositeArrayBuffer(
590-
handler.savedArtifacts.weightData).slice()), bias.dataSync());
589+
new Int32Array(io.concatenateArrayBuffers(
590+
handler.savedArtifacts.weightData)), bias.dataSync());
591591
});
592592
});
593593
});
@@ -617,8 +617,8 @@ describe('Model', () => {
617617
});
618618
expect(handler.savedArtifacts.weightSpecs).toEqual(weightsManifest);
619619
tfc.test_util.expectArraysClose(
620-
new Int32Array(new io.CompositeArrayBuffer(
621-
handler.savedArtifacts.weightData).slice()), bias.dataSync());
620+
new Int32Array(io.concatenateArrayBuffers(
621+
handler.savedArtifacts.weightData)), bias.dataSync());
622622
});
623623
});
624624

@@ -906,8 +906,8 @@ describe('Model', () => {
906906
});
907907
expect(handler.savedArtifacts.weightSpecs).toEqual(weightsManifest);
908908
tfc.test_util.expectArraysClose(
909-
new Int32Array(new io.CompositeArrayBuffer(handler.savedArtifacts
910-
.weightData).slice()), bias.dataSync());
909+
new Int32Array(io.concatenateArrayBuffers(handler.savedArtifacts
910+
.weightData)), bias.dataSync());
911911
});
912912
});
913913

tfjs-converter/src/operations/executors/spy_ops.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,11 @@
1515
* =============================================================================
1616
*/
1717

18-
// The opposite of Extract<T, U>
19-
type Without<T, U> = T extends U ? never : T;
20-
21-
// Do not spy on CompositeArrayBuffer because it is a class constructor.
22-
type NotSpiedOn = 'CompositeArrayBuffer';
23-
2418
export type RecursiveSpy<T> =
25-
T extends Function ? jasmine.Spy :
26-
{[K in Without<keyof T, NotSpiedOn>]: RecursiveSpy<T[K]>} &
27-
{[K in Extract<keyof T, NotSpiedOn>]: T[K]};
19+
T extends Function ? jasmine.Spy : {[K in keyof T]: RecursiveSpy<T[K]>};
2820

2921
export function spyOnAllFunctions<T>(obj: T): RecursiveSpy<T> {
3022
return Object.fromEntries(Object.entries(obj).map(([key, val]) => {
31-
// TODO(mattSoulanille): Do not hard code this
32-
if (key === 'CompositeArrayBuffer') {
33-
return val;
34-
}
3523
if (val instanceof Function) {
3624
return [key, jasmine.createSpy(`${key} spy`, val).and.callThrough()];
3725
} else if (val instanceof Array) {

tfjs-core/src/io/io.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ import {fromMemory, fromMemorySync, withSaveHandler, withSaveHandlerSync} from '
2727
import {getLoadHandlers, getSaveHandlers, registerLoadRouter, registerSaveRouter} from './router_registry';
2828
import {IOHandler, IOHandlerSync, LoadHandler, LoadOptions, ModelArtifacts, ModelArtifactsInfo, ModelJSON, ModelStoreManager, OnProgressCallback, RequestDetails, SaveConfig, SaveHandler, SaveResult, TrainingConfig, WeightGroup, WeightsManifestConfig, WeightsManifestEntry, WeightData} from './types';
2929
import {loadWeights, weightsLoaderFactory} from './weights_loader';
30-
import {CompositeArrayBuffer} from './composite_array_buffer';
3130

3231
export {copyModel, listModels, moveModel, removeModel} from './model_management';
3332
export {
3433
browserFiles,
3534
browserHTTPRequest,
36-
CompositeArrayBuffer,
3735
concatenateArrayBuffers,
3836
decodeWeights,
3937
encodeWeights,

tfjs-layers/src/models_test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ describeMathCPUAndWebGL2('Saving+loading model with optimizer', () => {
12931293
// The second part comes from the bias of the dense layer, which has 1
12941294
// element and is also 4 bytes.
12951295
const weightData = savedArtifacts.weightData;
1296-
expect(new io.CompositeArrayBuffer(weightData).byteLength)
1296+
expect(io.concatenateArrayBuffers(weightData).byteLength)
12971297
.toEqual(4 * 8 + 4 * 1 + 4);
12981298

12991299
// Load the model back, with the optimizer.
@@ -1353,7 +1353,7 @@ describeMathCPUAndWebGL2('Saving+loading model with optimizer', () => {
13531353
// The second part comes from the bias of the dense layer, which has 1
13541354
// element and is also 4 bytes.
13551355
const weightData = savedArtifacts.weightData;
1356-
expect(new io.CompositeArrayBuffer(weightData)
1356+
expect(io.concatenateArrayBuffers(weightData)
13571357
.byteLength).toEqual(4 + 4 * 8 * 3 + 4 * 1 * 3);
13581358

13591359
// Load the model back, with the optimizer.
@@ -1413,7 +1413,7 @@ describeMathCPUAndWebGL2('Saving+loading model with optimizer', () => {
14131413
// The second part comes from the bias of the dense layer, which has 1
14141414
// element and is also 4 bytes.
14151415
const weightData = savedArtifacts.weightData;
1416-
expect(new io.CompositeArrayBuffer(weightData).byteLength)
1416+
expect(io.concatenateArrayBuffers(weightData).byteLength)
14171417
.toEqual(4 + 4 * 8 * 3 + 4 * 1 * 3);
14181418

14191419
// Load the model back, with the optimizer.
@@ -1471,7 +1471,7 @@ describeMathCPUAndWebGL2('Saving+loading model with optimizer', () => {
14711471
// The second part comes from the bias of the dense layer, which has 1
14721472
// element and is also 4 bytes.
14731473
const weightData = savedArtifacts.weightData;
1474-
expect(new io.CompositeArrayBuffer(weightData).byteLength)
1474+
expect(io.concatenateArrayBuffers(weightData).byteLength)
14751475
.toEqual(4 + 4 * 8 * 2 + 4 * 1 * 2);
14761476

14771477
// Load the model back, with the optimizer.
@@ -1534,7 +1534,7 @@ describeMathCPUAndWebGL2('Saving+loading model with optimizer', () => {
15341534
// The second part comes from the bias of the dense layer, which has 1
15351535
// element and is also 4 bytes.
15361536
const weightData = savedArtifacts.weightData;
1537-
expect(new io.CompositeArrayBuffer(weightData).byteLength)
1537+
expect(io.concatenateArrayBuffers(weightData).byteLength)
15381538
.toEqual(4 + 4 * 8 * 3 + 4 * 1 * 3);
15391539

15401540
// Load the model back, with the optimizer.
@@ -1593,7 +1593,7 @@ describeMathCPUAndWebGL2('Saving+loading model with optimizer', () => {
15931593
// The second part comes from the bias of the dense layer, which has 1
15941594
// element and is also 4 bytes.
15951595
const weightData = savedArtifacts.weightData;
1596-
expect(new io.CompositeArrayBuffer(weightData).byteLength)
1596+
expect(io.concatenateArrayBuffers(weightData).byteLength)
15971597
.toEqual(4 + 4 * 8 * 3 + 4 * 1 * 3);
15981598

15991599
// Load the model back, with the optimizer.
@@ -1651,7 +1651,7 @@ describeMathCPUAndWebGL2('Saving+loading model with optimizer', () => {
16511651
// The second part comes from the bias of the dense layer, which has 1
16521652
// element and is also 4 bytes.
16531653
const weightData = savedArtifacts.weightData;
1654-
expect(new io.CompositeArrayBuffer(weightData).byteLength)
1654+
expect(io.concatenateArrayBuffers(weightData).byteLength)
16551655
.toEqual(4 + 4 * 8 * 2 + 4 * 1 * 2);
16561656

16571657
// Load the model back, with the optimizer.

0 commit comments

Comments
 (0)