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.

OperationDescription.cs 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Tensorflow
  5. {
  6. public class OperationDescription
  7. {
  8. private IntPtr _handle;
  9. public IntPtr op => _handle;
  10. public OperationDescription(Graph graph, string opType, string opName)
  11. {
  12. _handle = c_api.TF_NewOperation(graph, opType, opName);
  13. }
  14. public OperationDescription(IntPtr handle)
  15. {
  16. _handle = handle;
  17. }
  18. public void AddInputList(params TF_Output[] inputs)
  19. {
  20. c_api.TF_AddInputList(_handle, inputs, inputs.Length);
  21. }
  22. public void SetAttrType(string attr_name, TF_DataType value)
  23. {
  24. c_api.TF_SetAttrType(_handle, attr_name, value);
  25. }
  26. public void SetAttrShape(string attr_name, long[] dims)
  27. {
  28. c_api.TF_SetAttrShape(_handle, attr_name, dims, dims.Length);
  29. }
  30. public Operation FinishOperation(Status status)
  31. {
  32. return c_api.TF_FinishOperation(_handle, status);
  33. }
  34. public static implicit operator OperationDescription(IntPtr handle)
  35. {
  36. return new OperationDescription(handle);
  37. }
  38. public static implicit operator IntPtr(OperationDescription desc)
  39. {
  40. return desc._handle;
  41. }
  42. }
  43. }

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。