@@ -317,27 +317,18 @@ internal void _add_outputs(TF_DataType[] types, Shape[] shapes)
317
317
{
318
318
Debug . Assert ( types . Length == shapes . Length ) ;
319
319
int orig_num_outputs = this . outputs . Length ;
320
- //var new_outputs = new List<Tensor>(_outputs);
321
-
322
- var old_outputs = _outputs ;
323
- _outputs = new Tensor [ orig_num_outputs + types . Length ] ;
324
- for ( int i = 0 ; i < orig_num_outputs ; i ++ )
325
- {
326
- _outputs [ i ] = old_outputs [ i ] ;
327
- }
320
+ var new_outputs = new List < Tensor > ( _outputs ) ;
328
321
329
322
// Since the `_outputs` is defined as `Array`, when we add new output, we
330
323
// have to create a new array, which brings some performance concerns.
331
324
// In the future maybe the type of `outputs` should be reconsidered.
332
325
for ( int i = 0 ; i < types . Length ; i ++ )
333
326
{
334
- var t = new Tensor ( this , orig_num_outputs + 1 , types [ i ] ) ;
335
- _outputs [ i ] = t ;
336
- //t = tf.ensure_shape(t, shapes[i]);
327
+ var t = new Tensor ( this , orig_num_outputs + i , types [ i ] ) ;
337
328
t . shape = shapes [ i ] ;
338
- // new_outputs.Add(t);
329
+ new_outputs . Add ( t ) ;
339
330
}
340
- // _outputs = new_outputs.ToArray();
331
+ _outputs = new_outputs . ToArray ( ) ;
341
332
}
342
333
343
334
internal void _set_func_attr ( string attr_name , string func_name )
@@ -372,23 +363,9 @@ internal void _set_attr(string attr_name, AttrValue attr_value)
372
363
373
364
internal void _set_attr_with_buf ( string attr_name , Buffer attr_buf )
374
365
{
375
- //if(_op_desc is null)
376
- //{
377
- // //var new_node_def = NodeDef.Parser.ParseFrom(node_def.ToByteArray());
378
- // //new_node_def.Name += "_temp";
379
- // //var op = new Operation(new_node_def, graph, inputs, _output_types, control_inputs, _input_types);
380
- // //Status status = new();
381
- // //c_api.TF_SetAttrBool(op._op_desc, "trainable", true);
382
- // ////c_api.TF_SetAttrValueProto(op._op_desc, attr_name, attr_buf.ToArray(), attr_buf.Length, status);
383
- // //status.Check(true);
384
- // // TODO(Rinne): deal with it. Give a warning or make the Operation always contains `op_desc`.
385
- //}
386
- //else
387
- //{
388
- // //Status status = new();
389
- // //c_api.TF_SetAttrValueProto(_op_desc, attr_name, attr_buf.ToArray(), attr_buf.Length, status);
390
- // //status.Check(true);
391
- //}
366
+ Status status = new ( ) ;
367
+ c_api . TFC_SetAttr ( graph , _handle , attr_name , attr_buf , status ) ;
368
+ status . Check ( true ) ;
392
369
}
393
370
}
394
371
}
0 commit comments