Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support loading models from ModelArtifacts and ModelJSON in loadGraphModelSync #6847

Merged
merged 7 commits into from
Sep 30, 2022

Conversation

mattsoulanille
Copy link
Member

@mattsoulanille mattsoulanille commented Sep 22, 2022

Let users pass inputs of type ModelArtifacts or [ModelJSON, ArrayBuffer] to loadGraphModelSync instead of requiring them to construct a synchronous IOHandler. In the case of ModelArtifacts, the model weights are contained in the object. In the case of [ModelJSON, ArrayBuffer], the ArrayBuffer is a list of concatenated weights for the model.

This change turns this code:

const modelJson = JSON.parse(modelString);
const weights = ...
modelJson.weightData = weights;
modelJson.weightSpecs = modelJson.weightsManifest[0].weights;
const ioHandler = tf.io.fromMemorySync(modelJson);
const model = tf.loadGraphModelSync(ioHandler);

... into this simpler code

const modelJson = JSON.parse(modelString);
const weights = ...
const model = tf.loadGraphModelSync([modelJson, weights]);

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@mattsoulanille mattsoulanille marked this pull request as ready for review September 22, 2022 20:42
Copy link
Contributor

@ahmedsabie ahmedsabie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 2 of 1 approvals obtained

@mattsoulanille mattsoulanille merged commit 0d31b72 into tensorflow:master Sep 30, 2022
@mattsoulanille mattsoulanille deleted the load_sync_simpler branch September 30, 2022 18:36
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.

3 participants