Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Implement ModelBuilder and update the execution API #23

Merged
merged 15 commits into from
Oct 25, 2020

Conversation

huningxin
Copy link
Contributor

@huningxin huningxin commented Oct 16, 2020

fix #22

Implement the WebNN API change introduced by webmachinelearning/webnn#94.

Preview:

Detailed changes include:

  1. Support optional outputs and optional input shapes.
  2. Implement ModelBuilder interface for state separation between context state and graph state.
  3. Fold the execution interface into the compilation interface by adding compute method.
  4. Remove quantization-related params from the operand descriptor.
  5. Simplify operand type enum.
  6. Add 86 new test cases.
  7. Update the version to 0.1.0

@anssiko @wchao1115 @pyu10055 @BruceDai , please take a look. Thanks!

@huningxin
Copy link
Contributor Author

Thanks @BruceDai for contributing the nhwc conv2d and depthwise conv2d test cases. It helped me to find an issue of filter layout for nhwc depthwise conv2d. I pushed new comments to fix it. Please take a look.

Copy link
Member

@anssiko anssiko left a comment

Choose a reason for hiding this comment

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

Thanks! I defer to other reviewers for a detailed look.

Copy link

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

thanks for aligning with the API changes, I had a couple high level questions in the comments.

const nn = navigator.ml.getNeuralNetworkContext();
const builder = nn.createModelBuilder();
const desc = {type: 'float32', dimensions: [2, 2]};
const a = builder.input('a', desc);

Choose a reason for hiding this comment

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

operands seem to contain builder, can it provide chained API?
i.e. a.matmul(b)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created webmachinelearning/webnn#106 to follow-up in spec.

const expectedE = [3, 3, 3, 3];

it('Compilation should have compute method', async () => {
const model = builder.createModel({c});

Choose a reason for hiding this comment

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

this is bit confusing, the builder creates models, but the topology is created before the model is created, and how made the topology immutable for the model?

Copy link
Contributor Author

@huningxin huningxin Oct 20, 2020

Choose a reason for hiding this comment

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

The model should be immutable after createModel. As discussed with @pyu10055 , it needs to add details of the createModel method into the spec. Created webmachinelearning/webnn#107 to follow up.

Copy link
Contributor Author

@huningxin huningxin Oct 20, 2020

Choose a reason for hiding this comment

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

I added a new commit cb283bd. It includes a test case for immutable model and fixes a bug that the constant operand is not immutable. Please take another look.

@huningxin
Copy link
Contributor Author

@BruceDai , could you please verify whether the depthwise conv2d issue was fixed? Thanks!

@BruceDai
Copy link
Collaborator

@huningxin I verified with three test cases converted from Android NNAPI CTS tests, now these test cases were all PASS, thanks for fixing this issue.

BTW, I'm planning to submit a PR of adding some test cases converted from Android NNAPI CTS tests and the converter scripts to this repo, and hope to get some feedback from you and also the community, thanks.

Copy link
Collaborator

@BruceDai BruceDai left a comment

Choose a reason for hiding this comment

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

Thanks @huningxin , this PR looks good to me.

@anssiko
Copy link
Member

anssiko commented Oct 22, 2020

@huningxin I believe this PR has received adequate review and we can merge this now.

@huningxin
Copy link
Contributor Author

@anssiko @BruceDai @pyu10055 , I believe all the comments have been addressed by either adding new commits or filing new issues. With that, I am going to merge this PR. Thanks much!

@huningxin huningxin merged commit 05abc83 into webmachinelearning:master Oct 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the ModelBuilder and update the execution API
4 participants