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 1.3 kB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 static implicit operator NDArray(Array array)
  9. => new NDArray(array);
  10. public static implicit operator bool(NDArray nd)
  11. => nd._tensor.ToArray<bool>()[0];
  12. public static implicit operator byte[](NDArray nd)
  13. => nd.ToByteArray();
  14. public static implicit operator int(NDArray nd)
  15. => nd._tensor.ToArray<int>()[0];
  16. public static implicit operator float(NDArray nd)
  17. => nd._tensor.ToArray<float>()[0];
  18. public static implicit operator double(NDArray nd)
  19. => nd._tensor.ToArray<double>()[0];
  20. public static implicit operator NDArray(bool value)
  21. => new NDArray(value);
  22. public static implicit operator NDArray(int value)
  23. => new NDArray(value);
  24. public static implicit operator NDArray(float value)
  25. => new NDArray(value);
  26. public static implicit operator NDArray(double value)
  27. => new NDArray(value);
  28. public static implicit operator Tensor(NDArray nd)
  29. => nd._tensor;
  30. public static implicit operator NDArray(Tensor tensor)
  31. => new NDArray(tensor);
  32. }
  33. }