You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

GraphOnlyOps.cs 951 B

12345678910111213141516171819202122232425
  1. using Tensorflow;
  2. internal static class GraphOnlyOps
  3. {
  4. /// <summary>
  5. /// Graph-only version of tf.compat.v1.placeholder(), for internal use only.
  6. /// </summary>
  7. /// <param name="dtyype"></param>
  8. /// <param name="shape"></param>
  9. /// <param name="name"></param>
  10. /// <returns></returns>
  11. internal static Tensor graph_placeholder(TF_DataType dtype, Shape shape, string? name = null)
  12. {
  13. var dtype_value = new AttrValue() { Type = dtype.as_datatype_enum() };
  14. var shape_value = new AttrValue() { Shape = shape.as_proto() };
  15. var g = ops.get_default_graph();
  16. Dictionary<string, AttrValue> attrs = new();
  17. attrs["dtype"] = dtype_value;
  18. attrs["shape"] = shape_value;
  19. var op = g.create_op("Placeholder", new Tensor[0], new TF_DataType[] { dtype },
  20. new TF_DataType[0], attrs: attrs, name: name);
  21. var result = op.outputs[0];
  22. return result;
  23. }
  24. }