@@ -51,13 +51,10 @@ pub(crate) struct MLGraphBuilder {
5151 /// Built state represented by `graph_info: Option<GraphInfo>` (None => built).
5252
5353 /// <https://webmachinelearning.github.io/webnn/#computational-graph-input>
54- // NOTE: DOM-level storage for `inputs`, `constants`, and `operand_map` was removed.
5554 // All graph bookkeeping (backend operands, input/constant ids, constant bytes, etc.)
56- // now lives in `graph_info` (the rustnn `GraphInfo`). The builder still creates and
57- // returns `MLOperand` DOM objects to callers, but it no longer keeps separate DOM
58- // lists or a mapping from backend id -> DOM operand.
55+ // lives in `graph_info` (the rustnn `GraphInfo`).
5956
60- /// Implementation-defined graph representation (rustnn `GraphInfo`) used to build backend graphs.
57+ /// <https://webmachinelearning.github.io/webnn/#computational- graph>
6158 #[ no_trace]
6259 #[ ignore_malloc_size_of = "rustnn::GraphInfo is external; skip malloc-size accounting" ]
6360 graph_info : DomRefCell < Option < GraphInfo > > ,
@@ -66,7 +63,7 @@ pub(crate) struct MLGraphBuilder {
6663 next_operand_id : Cell < u32 > ,
6764}
6865
69- /// Helper: map WebNN data type strings to binding enum variants used by descriptors.
66+ /// Map WebNN data type strings to binding enum variants used by descriptors.
7067fn data_type_enum_from_str ( data_type : & str ) -> MLOperandDataType {
7168 match data_type {
7269 "float32" => MLOperandDataType :: Float32 ,
@@ -107,8 +104,6 @@ fn static_dimensions(dimensions: &[u32]) -> Vec<rustnn_options::MLDimension> {
107104}
108105
109106fn label_from_operator_options ( options : & MLOperatorOptions ) -> Option < String > {
110- // Step 1: Read operator label.
111- // Step 2: Normalize empty labels to None.
112107 let label = options. label . clone ( ) ;
113108 if label. is_empty ( ) {
114109 None
@@ -171,16 +166,13 @@ impl MLGraphBuilder {
171166 /// This centralizes the `next_operand_id` increment + GraphInfo mutation logic
172167 /// so callers only need to construct a rustnn `Operand` and call this helper.
173168 fn push_operand_to_graph ( & self , operand : Operand , add_to_inputs : bool ) -> u32 {
174- // Step 1: Read the next backend operand id.
175169 let id = self . next_operand_id . get ( ) ;
176- // Step 2: Append the operand to GraphInfo and optionally mark it as an input operand.
177170 if let Some ( ref mut gi) = self . graph_info . borrow_mut ( ) . as_mut ( ) {
178171 gi. operands . push ( operand) ;
179172 if add_to_inputs {
180173 gi. input_operands . push ( id) ;
181174 }
182175 }
183- // Step 3: Advance the id counter and return the id assigned to this operand.
184176 self . next_operand_id . set ( id + 1 ) ;
185177 id
186178 }
@@ -194,7 +186,6 @@ impl MLGraphBuilder {
194186 kind : OperandKind ,
195187 name : Option < String > ,
196188 ) -> Operand {
197- // Step 1: Convert WebNN data type strings to rustnn graph data types.
198189 let rust_data_type = match data_type_str {
199190 "float32" => DataType :: Float32 ,
200191 "float16" => DataType :: Float16 ,
@@ -205,13 +196,11 @@ impl MLGraphBuilder {
205196 "int64" => DataType :: Int64 ,
206197 _ => DataType :: Float32 ,
207198 } ;
208- // Step 2: Construct the rustnn OperandDescriptor with converted shape dimensions.
209199 let desc = OperandDescriptor {
210200 data_type : rust_data_type,
211201 shape : rustnn:: graph:: to_dimension_vector ( & shape) ,
212202 pending_permutation : Vec :: new ( ) ,
213203 } ;
214- // Step 3: Return a rustnn Operand carrying descriptor, kind, and optional name.
215204 Operand {
216205 descriptor : desc,
217206 kind,
@@ -227,7 +216,6 @@ impl MLGraphBuilder {
227216 attributes : OperatorOptions ,
228217 label : Option < String > ,
229218 ) {
230- // Step 1: Append a unary Operation record into GraphInfo.operations.
231219 if let Some ( ref mut gi) = self . graph_info . borrow_mut ( ) . as_mut ( ) {
232220 gi. operations . push ( Operation {
233221 op_type : op_name. to_string ( ) ,
@@ -248,7 +236,6 @@ impl MLGraphBuilder {
248236 attributes : OperatorOptions ,
249237 label : Option < String > ,
250238 ) {
251- // Step 1: Append an Operation record with a dynamic input list into GraphInfo.operations.
252239 if let Some ( ref mut gi) = self . graph_info . borrow_mut ( ) . as_mut ( ) {
253240 gi. operations . push ( Operation {
254241 op_type : op_name. to_string ( ) ,
0 commit comments