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.

CApiTest.cs 2.4 kB

6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using Tensorflow;
  4. namespace TensorFlowNET.UnitTest
  5. {
  6. public class CApiTest
  7. {
  8. protected TF_Code TF_OK = TF_Code.TF_OK;
  9. protected TF_DataType TF_FLOAT = TF_DataType.TF_FLOAT;
  10. protected void EXPECT_TRUE(bool expected, string msg = "")
  11. => Assert.IsTrue(expected, msg);
  12. protected void EXPECT_EQ(object expected, object actual, string msg = "")
  13. => Assert.AreEqual(expected, actual, msg);
  14. protected void CHECK_EQ(object expected, object actual, string msg = "")
  15. => Assert.AreEqual(expected, actual, msg);
  16. protected void EXPECT_NE(object expected, object actual, string msg = "")
  17. => Assert.AreNotEqual(expected, actual, msg);
  18. protected void EXPECT_GE(int expected, int actual, string msg = "")
  19. => Assert.IsTrue(expected >= actual, msg);
  20. protected void ASSERT_EQ(object expected, object actual, string msg = "")
  21. => Assert.AreEqual(expected, actual, msg);
  22. protected void ASSERT_TRUE(bool condition, string msg = "")
  23. => Assert.IsTrue(condition, msg);
  24. protected OperationDescription TF_NewOperation(Graph graph, string opType, string opName)
  25. => c_api.TF_NewOperation(graph, opType, opName);
  26. protected void TF_AddInput(OperationDescription desc, TF_Output input)
  27. => c_api.TF_AddInput(desc, input);
  28. protected Operation TF_FinishOperation(OperationDescription desc, Status s)
  29. => c_api.TF_FinishOperation(desc, s);
  30. protected void TF_SetAttrTensor(OperationDescription desc, string attrName, Tensor value, Status s)
  31. => c_api.TF_SetAttrTensor(desc, attrName, value, s);
  32. protected void TF_SetAttrType(OperationDescription desc, string attrName, TF_DataType dtype)
  33. => c_api.TF_SetAttrType(desc, attrName, dtype);
  34. protected void TF_SetAttrBool(OperationDescription desc, string attrName, bool value)
  35. => c_api.TF_SetAttrBool(desc, attrName, value);
  36. protected TF_Code TF_GetCode(Status s)
  37. => s.Code;
  38. protected TF_Code TF_GetCode(IntPtr s)
  39. => c_api.TF_GetCode(s);
  40. protected string TF_Message(IntPtr s)
  41. => c_api.StringPiece(c_api.TF_Message(s));
  42. }
  43. }