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.0 kB

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