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.

CApi.Eager.Context.cs 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using Tensorflow;
  4. using Tensorflow.Eager;
  5. namespace TensorFlowNET.UnitTest.Eager
  6. {
  7. public partial class CApiEagerTest
  8. {
  9. /// <summary>
  10. /// TEST(CAPI, Context)
  11. /// </summary>
  12. [TestMethod]
  13. public void Context()
  14. {
  15. var status = c_api.TF_NewStatus();
  16. var opts = c_api.TFE_NewContextOptions();
  17. var ctx = c_api.TFE_NewContext(opts, status);
  18. c_api.TFE_DeleteContextOptions(opts);
  19. var devices = c_api.TFE_ContextListDevices(ctx, status);
  20. EXPECT_EQ(TF_OK, TF_GetCode(status), TF_Message(status));
  21. c_api.TFE_DeleteContext(ctx);
  22. EXPECT_EQ(TF_OK, TF_GetCode(status), TF_Message(status));
  23. int num_devices = c_api.TF_DeviceListCount(devices);
  24. EXPECT_GE(num_devices, 1, TF_Message(status));
  25. for (int i = 0; i < num_devices; ++i)
  26. {
  27. EXPECT_NE("", c_api.TF_DeviceListName(devices, i, status), TF_Message(status));
  28. EXPECT_EQ(TF_OK, TF_GetCode(status), TF_Message(status));
  29. }
  30. c_api.TF_DeleteDeviceList(devices);
  31. c_api.TF_DeleteStatus(status);
  32. }
  33. }
  34. }