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.

NDArray.Implicit.cs 4.3 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Tensorflow.NumPy
  5. {
  6. public partial class NDArray
  7. {
  8. public void Deconstruct(out byte blue, out byte green, out byte red)
  9. {
  10. var data = ToArray<byte>();
  11. blue = data[0];
  12. green = data[1];
  13. red = data[2];
  14. }
  15. public static implicit operator NDArray(int[] array)
  16. => new NDArray(array);
  17. public static implicit operator NDArray(byte[] array)
  18. => new NDArray(array);
  19. public static implicit operator NDArray(float[] array)
  20. => new NDArray(array);
  21. public static implicit operator NDArray(double[] array)
  22. => new NDArray(array);
  23. public static implicit operator NDArray(long[] array)
  24. => new NDArray(array);
  25. public static implicit operator NDArray(bool[] array)
  26. => new NDArray(array);
  27. public static implicit operator NDArray(uint[] array)
  28. => new NDArray(array);
  29. public static implicit operator NDArray(ulong[] array)
  30. => new NDArray(array);
  31. public static implicit operator NDArray(int[,] array)
  32. => new NDArray(array);
  33. public static implicit operator NDArray(byte[,] array)
  34. => new NDArray(array);
  35. public static implicit operator NDArray(float[,] array)
  36. => new NDArray(array);
  37. public static implicit operator NDArray(double[,] array)
  38. => new NDArray(array);
  39. public static implicit operator NDArray(long[,] array)
  40. => new NDArray(array);
  41. public static implicit operator NDArray(bool[,] array)
  42. => new NDArray(array);
  43. public static implicit operator NDArray(uint[,] array)
  44. => new NDArray(array);
  45. public static implicit operator NDArray(ulong[,] array)
  46. => new NDArray(array);
  47. public static implicit operator NDArray(int[,,] array)
  48. => new NDArray(array);
  49. public static implicit operator NDArray(byte[,,] array)
  50. => new NDArray(array);
  51. public static implicit operator NDArray(float[,,] array)
  52. => new NDArray(array);
  53. public static implicit operator NDArray(double[,,] array)
  54. => new NDArray(array);
  55. public static implicit operator NDArray(long[,,] array)
  56. => new NDArray(array);
  57. public static implicit operator NDArray(bool[,,] array)
  58. => new NDArray(array);
  59. public static implicit operator NDArray(uint[,,] array)
  60. => new NDArray(array);
  61. public static implicit operator NDArray(ulong[,,] array)
  62. => new NDArray(array);
  63. public unsafe static implicit operator bool(NDArray nd)
  64. => nd.dtype == TF_DataType.TF_BOOL ? *(bool*)nd.data : NDArrayConverter.Scalar<bool>(nd);
  65. public unsafe static implicit operator byte(NDArray nd)
  66. => nd.dtype == TF_DataType.TF_UINT8 ? *(byte*)nd.data : NDArrayConverter.Scalar<byte>(nd);
  67. public unsafe static implicit operator int(NDArray nd)
  68. => nd.dtype == TF_DataType.TF_INT32 ? *(int*)nd.data : NDArrayConverter.Scalar<int>(nd);
  69. public unsafe static implicit operator long(NDArray nd)
  70. => nd.dtype == TF_DataType.TF_INT64 ? *(long*)nd.data : NDArrayConverter.Scalar<long>(nd);
  71. public unsafe static implicit operator float(NDArray nd)
  72. => nd.dtype == TF_DataType.TF_FLOAT ? *(float*)nd.data : NDArrayConverter.Scalar<float>(nd);
  73. public unsafe static implicit operator double(NDArray nd)
  74. => nd.dtype == TF_DataType.TF_DOUBLE ? *(double*)nd.data : NDArrayConverter.Scalar<double>(nd);
  75. public static implicit operator NDArray(bool value)
  76. => new NDArray(value);
  77. public static implicit operator NDArray(byte value)
  78. => new NDArray(value);
  79. public static implicit operator NDArray(int value)
  80. => new NDArray(value);
  81. public static implicit operator NDArray(long value)
  82. => new NDArray(value);
  83. public static implicit operator NDArray(float value)
  84. => new NDArray(value);
  85. public static implicit operator NDArray(double value)
  86. => new NDArray(value);
  87. }
  88. }