forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphOnlyOps.cs
More file actions
25 lines (24 loc) · 951 Bytes
/
GraphOnlyOps.cs
File metadata and controls
25 lines (24 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using Tensorflow;
internal static class GraphOnlyOps
{
/// <summary>
/// Graph-only version of tf.compat.v1.placeholder(), for internal use only.
/// </summary>
/// <param name="dtyype"></param>
/// <param name="shape"></param>
/// <param name="name"></param>
/// <returns></returns>
internal static Tensor graph_placeholder(TF_DataType dtype, Shape shape, string? name = null)
{
var dtype_value = new AttrValue() { Type = dtype.as_datatype_enum() };
var shape_value = new AttrValue() { Shape = shape.as_proto() };
var g = ops.get_default_graph();
Dictionary<string, AttrValue> attrs = new();
attrs["dtype"] = dtype_value;
attrs["shape"] = shape_value;
var op = g.create_op("Placeholder", new Tensor[0], new TF_DataType[] { dtype },
new TF_DataType[0], attrs: attrs, name: name);
var result = op.outputs[0];
return result;
}
}