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

Use AllowSharedBufferSource for MLGraphBuilder.constant() #790

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

huningxin
Copy link
Contributor

@huningxin huningxin commented Nov 16, 2024

Fix #788


Preview | Diff

index.bs Show resolved Hide resolved
@huningxin
Copy link
Contributor Author

@a-sully , PTAL?

index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
@@ -1503,9 +1504,6 @@ Build a composed graph up to a given output operand into a computational graph a
1. Set |graph|.{{MLGraph/[[context]]}} to [=this=].{{MLGraphBuilder/[[context]]}}.
1. [=set/For each=] |operand| in |inputs|:
1. Set |graph|.{{MLGraph/[[inputDescriptors]]}}[|operand|.{{MLOperand/[[name]]}}] to |operand|.{{MLOperand/[[descriptor]]}}.

Issue(566): If {{MLGraphBuilder/constant(descriptor, bufferView)|constants'}} {{ArrayBuffer}}s are not [=ArrayBuffer/transferred=], make copies for [=MLGraphBuilder/graph=]'s [=computational graph/constants=] here.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: this issue is closed and not relevant.

</summary>
1. If [=this=].{{MLGraphBuilder/[[hasBuilt]]}} is true, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. If [=MLOperandDescriptor/checking dimensions=] given |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
1. If [=validating buffer with descriptor=] given |bufferView| and |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
1. If [=validating buffer with descriptor=] given |bufferSource| and |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: This depends on #787 for supporting AllowSharedBufferSource in "validate buffer with descriptor" algorithm.

@huningxin huningxin changed the title Allow shared array buffer view for MLGraphBuilder.constant() Use AllowSharedBufferSource for MLGraphBuilder.constant() Nov 21, 2024
@@ -1341,7 +1341,8 @@ interface MLGraphBuilder {
MLOperand input(USVString name, MLOperandDescriptor descriptor);

// Create an operand for a graph constant.
MLOperand constant(MLOperandDescriptor descriptor, ArrayBufferView bufferView);
MLOperand constant(MLOperandDescriptor descriptor,
AllowSharedBufferSource bufferSource);
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about just using buffer, at least in the IDL?

Suggested change
AllowSharedBufferSource bufferSource);
AllowSharedBufferSource buffer);

Copy link
Contributor

@a-sully a-sully left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

MLGraphBuilder.constant() should take an AllowSharedBufferSource
2 participants