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

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