Skip to content

Comments

refactor(deps): migrate @tensorflow/tfjs from 3.4.0 to 4.22.0#7061

Open
digital-wizard48 wants to merge 1 commit intotensorflow:masterfrom
digital-wizard48:deps/upgrade--tensorflow-tfjs-4.22.0
Open

refactor(deps): migrate @tensorflow/tfjs from 3.4.0 to 4.22.0#7061
digital-wizard48 wants to merge 1 commit intotensorflow:masterfrom
digital-wizard48:deps/upgrade--tensorflow-tfjs-4.22.0

Conversation

@digital-wizard48
Copy link

Changes

Dependency version bumps

  • @tensorflow/tfjs: 3.4.0 → 4.22.0
  • @tensorflow/tfjs-backend-cpu: 3.4.0 → 4.22.0
  • @tensorflow/tfjs-backend-webgl: 3.4.0 → 4.22.0
  • @tensorflow/tfjs-core: 3.4.0 → 4.22.0

All @tensorflow/tfjs-* packages must share the same version in TF.js 4.x to avoid runtime conflicts from mismatched kernel registries.

Source code migrations

tensorboard/plugins/projector/vz_projector/knn.ts

  • tf.tensor()tf.tensor2d(): In TF.js 4.x the generic tf.tensor() with a shape argument still works but tf.tensor2d() is the preferred typed constructor for rank-2 tensors and avoids implicit any tensor type downstream.
  • tf.sub(1, ...)tf.sub(tf.scalar(1), ...): TF.js 4.x tightened the overload resolution for tf.sub; the first argument must be a Tensor or TensorLike value explicitly. Wrapping the numeric literal in tf.scalar() satisfies the updated type constraints.
  • Array<[number, number]>number[][]: The padding parameter type for tf.pad() changed from a tuple-array Array<[number, number]> to the more permissive number[][] in TF.js 4.x type definitions. Updated the annotation and added a as tf.Tensor2D cast after the call since tf.pad returns the base Tensor type.
  • tf.split second argument: Explicitly typed as number[] to match the updated overload signature in 4.x.
  • maybePaddedCosDistMatrix type annotation: Now explicitly typed as tf.Tensor2D to propagate the rank information through the padding branch; requires a cast after tf.pad which returns the base Tensor type.

tensorboard/webapp/third_party/tfjs.ts

  • Added a comment noting TF.js 4.x's expectation that callers explicitly call tf.setBackend('webgl') or tf.setBackend('cpu') before running operations when the default automatic backend resolution is insufficient. The side-effect imports of the backend packages still register the backends, but explicit selection via setBackend is the recommended pattern in 4.x.

This PR was auto-generated by Gittensor upgrade bot using Claude AI

@google-cla
Copy link

google-cla bot commented Feb 21, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@digital-wizard48
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants