You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The {{MLGraphBuilder}}.{{MLGraphBuilder/build()}} method compiles the graph builder state up to the specified output operands into a compiled graph according to the type of {{MLContext}} that creates it. When the {{MLContext/[[contextType]]}} of the {{MLContext}} is set to "[=context type/default=]", the compiled graph is initialized right before the {{MLGraph}} is returned. This graph initialization stage is important for optimal performance of the subsequent graph executions. It typically involves a process known as "weight preprocessing" where all the constant inputs to the graph are preprocessed and cached at the operating system level for subsequent graph execution calls. The initializing inputs are typically the constant weight data specified through the {{MLGraphBuilder/constant(descriptor, bufferView)|constant()}} method as constant operands during graph construction time.
1704
+
The {{MLGraphBuilder}}.{{MLGraphBuilder/build()}} method compiles the graph builder state up to the specified output operands into a compiled graph according to the type of {{MLContext}} that creates it. When the {{MLContext/[[contextType]]}} of the {{MLContext}} is set to "[=context type/default=]", the compiled graph is initialized right before the {{MLGraph}} is returned. This graph initialization stage is important for optimal performance of the subsequent graph executions. It typically involves a process known as "weight preprocessing" where all the constant inputs to the graph are preprocessed and cached at the operating system level for subsequent graph execution calls. The initializing inputs are typically the constant weight data specified through the {{MLGraphBuilder/constant(descriptor, buffer)|constant()}} method as constant operands during graph construction time.
1704
1705
</div>
1705
1706
1706
1707
<div class=internal-slots>
@@ -1764,26 +1765,26 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input
- <dfn>descriptor</dfn>: an {{MLOperandDescriptor}}. The descriptor of the output tensor.
1773
-
- <dfn>bufferView</dfn>: an {{ArrayBufferView}}. The view of the buffer containing the initializing data.
1774
+
- <dfn>buffer</dfn>: an {{AllowSharedBufferSource}}. The buffer containing the initializing data.
1774
1775
**Returns:** an {{MLOperand}}. The constant output tensor.
1775
1776
</div>
1776
1777
1777
1778
<details open algorithm>
1778
1779
<summary>
1779
-
The <dfn method for=MLGraphBuilder>constant(|descriptor|, |bufferView|)</dfn> method steps are:
1780
+
The <dfn method for=MLGraphBuilder>constant(|descriptor|, |buffer|)</dfn> method steps are:
1780
1781
</summary>
1781
1782
1. If [=this=].{{MLGraphBuilder/[[hasBuilt]]}} is true, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
1782
1783
1. If [=MLOperandDescriptor/checking dimensions=] given |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
1783
-
1. If [=validating buffer with descriptor=] given |bufferView| and |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
1784
+
1. If [=validating buffer with descriptor=] given |buffer| and |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
1784
1785
1. *Make graph connections:*
1785
1786
1. Let |operand| be the result of [=creating an MLOperand=] given [=this=] and |descriptor|.
1786
-
1. Let |bytes| be the result of [=getting a copy of the bytes held by the buffer source=] given |bufferView|.
1787
+
1. Let |bytes| be the result of [=getting a copy of the bytes held by the buffer source=] given |buffer|.
1787
1788
1. Add |operand| to [=this=]'s [=MLGraphBuilder/graph=]'s [=computational graph/constants=] with |bytes| as value.
1788
1789
1. Return |operand|.
1789
1790
</details>
@@ -1851,9 +1852,6 @@ Build a composed graph up to a given output operand into a computational graph a
1851
1852
1. Set |graph|.{{MLGraph/[[context]]}} to [=this=].{{MLGraphBuilder/[[context]]}}.
1852
1853
1. [=set/For each=] |operand| in |inputs|:
1853
1854
1. Set |graph|.{{MLGraph/[[inputDescriptors]]}}[|operand|.{{MLOperand/[[name]]}}] to |operand|.{{MLOperand/[[descriptor]]}}.
1854
-
1855
-
Issue(566): If {{MLGraphBuilder/constant(descriptor, bufferView)|constants'}}{{ArrayBuffer}}s are not [=ArrayBuffer/transferred=], make copies for [=MLGraphBuilder/graph=]'s [=computational graph/constants=] here.
1856
-
1857
1855
1. [=map/For each=] |name| → |operand| of |outputs|:
1858
1856
1. Set |graph|.{{MLGraph/[[outputDescriptors]]}}[|name|] to |operand|.{{MLOperand/[[descriptor]]}}.
0 commit comments