| 56 | }; |
| 57 | |
| 58 | TEST_F(SaveOpTest, Simple) { |
| 59 | const string filename = io::JoinPath(testing::TmpDir(), "tensor_simple"); |
| 60 | const string tensornames[] = { |
| 61 | "tensor_bool", "tensor_int", "tensor_float", "tensor_double", |
| 62 | "tensor_qint8", "tensor_qint32", "tensor_uint8", "tensor_int8", |
| 63 | "tensor_int16", "tensor_int64", "tensor_string", "tensor_complex64", |
| 64 | "tensor_complex128", "tensor_half"}; |
| 65 | |
| 66 | MakeOp(); |
| 67 | // Add a file name |
| 68 | AddInput<tstring>(TensorShape({}), |
| 69 | [&filename](int x) -> tstring { return filename; }); |
| 70 | |
| 71 | // Add the tensor names |
| 72 | AddInput<tstring>(TensorShape({14}), [&tensornames](int x) -> tstring { |
| 73 | return tensornames[x]; |
| 74 | }); |
| 75 | |
| 76 | // Add a 1-d bool tensor |
| 77 | AddInput<bool>(TensorShape({2}), [](int x) -> bool { return x != 0; }); |
| 78 | |
| 79 | // Add a 1-d integer tensor |
| 80 | AddInput<int32>(TensorShape({10}), [](int x) -> int32 { return x + 1; }); |
| 81 | |
| 82 | // Add a 2-d float tensor |
| 83 | AddInput<float>(TensorShape({2, 4}), |
| 84 | [](int x) -> float { return static_cast<float>(x) / 10; }); |
| 85 | |
| 86 | // Add a 2-d double tensor |
| 87 | AddInput<double>(TensorShape({2, 4}), |
| 88 | [](int x) -> double { return static_cast<double>(x) / 20; }); |
| 89 | |
| 90 | // Add a 2-d qint8 tensor |
| 91 | AddInput<qint8>(TensorShape({3, 2}), |
| 92 | [](int x) -> qint8 { return *reinterpret_cast<qint8*>(&x); }); |
| 93 | |
| 94 | // Add a 2-d qint32 tensor |
| 95 | AddInput<qint32>(TensorShape({2, 3}), [](int x) -> qint32 { |
| 96 | return *reinterpret_cast<qint32*>(&x) * qint8(2); |
| 97 | }); |
| 98 | |
| 99 | // Add a 1-d uint8 tensor |
| 100 | AddInput<uint8>(TensorShape({11}), [](int x) -> uint8 { return x + 1; }); |
| 101 | |
| 102 | // Add a 1-d int8 tensor |
| 103 | AddInput<int8>(TensorShape({7}), [](int x) -> int8 { return x - 7; }); |
| 104 | |
| 105 | // Add a 1-d int16 tensor |
| 106 | AddInput<int16>(TensorShape({7}), [](int x) -> int16 { return x - 8; }); |
| 107 | |
| 108 | // Add a 1-d int64 tensor |
| 109 | AddInput<int64>(TensorShape({9}), [](int x) -> int64 { return x - 9; }); |
| 110 | |
| 111 | // Add a 1-d string tensor |
| 112 | AddInput<tstring>(TensorShape({2}), |
| 113 | [](int x) -> tstring { return x ? "yes" : "no"; }); |
| 114 | |
| 115 | // Add a 2-d complex64 tensor |
nothing calls this directly
no test coverage detected