Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@
"@polymer/paper-toolbar": "^3.0.1",
"@polymer/paper-tooltip": "^3.0.1",
"@polymer/polymer": "^3.4.1",
"@tensorflow/tfjs": "3.4.0",
"@tensorflow/tfjs-backend-cpu": "3.4.0",
"@tensorflow/tfjs-backend-webgl": "3.4.0",
"@tensorflow/tfjs-core": "3.4.0",
"@tensorflow/tfjs": "4.22.0",
"@tensorflow/tfjs-backend-cpu": "4.22.0",
"@tensorflow/tfjs-backend-webgl": "4.22.0",
"@tensorflow/tfjs-core": "4.22.0",
"@vaadin/vaadin-grid": "^20.0.2",
"d3": "5.7.0",
"dagre": "^0.8.5",
Expand Down
14 changes: 7 additions & 7 deletions tensorboard/plugins/projector/vz_projector/knn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,26 @@ export function findKNNGPUCosDistNorm<T>(
let piece = 0;

const typedArray = vector.toTypedArray(dataPoints, accessor);
const bigMatrix = tf.tensor(typedArray, [N, dim]);
const bigMatrix = tf.tensor2d(typedArray, [N, dim]);
const bigMatrixTransposed = tf.transpose(bigMatrix);
// 1 - A * A^T.
const bigMatrixSquared = tf.matMul(bigMatrix, bigMatrixTransposed);
const cosDistMatrix = tf.sub(1, bigMatrixSquared);
const cosDistMatrix = tf.sub(tf.scalar(1), bigMatrixSquared);

let maybePaddedCosDistMatrix = cosDistMatrix;
let maybePaddedCosDistMatrix: tf.Tensor2D = cosDistMatrix;
if (actualPieceSize * numPieces > N) {
// Expect the input to be rank 2 (though it is not typed that way) so we
// want to pad the first dimension so we split very evenly (all splitted
// tensor have exactly the same dimesion).
const padding: Array<[number, number]> = [
const padding: number[][] = [
[0, actualPieceSize * numPieces - N],
[0, 0],
];
maybePaddedCosDistMatrix = tf.pad(cosDistMatrix, padding);
maybePaddedCosDistMatrix = tf.pad(cosDistMatrix, padding) as tf.Tensor2D;
}
const splits = tf.split(
maybePaddedCosDistMatrix,
new Array(numPieces).fill(actualPieceSize),
maybePaddedCosDistMatrix as tf.Tensor,
new Array(numPieces).fill(actualPieceSize) as number[],
0
);

Expand Down
5 changes: 5 additions & 0 deletions tensorboard/webapp/third_party/tfjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ export * from '@tensorflow/tfjs-core';

import '@tensorflow/tfjs-backend-cpu';
import '@tensorflow/tfjs-backend-webgl';

// TF.js 4.x requires explicitly setting/registering a backend.
// setBackend is re-exported from tfjs-core above; callers should invoke
// tf.setBackend('webgl') or tf.setBackend('cpu') before running operations
// if the default backend resolution is not sufficient.