Create an empty tensor of type 'dtype'. 'shape' can be arbitrary, but has to result in a zero-sized tensor.
| 390 | // Create an empty tensor of type 'dtype'. 'shape' can be arbitrary, but has to |
| 391 | // result in a zero-sized tensor. |
| 392 | static TF_Tensor* EmptyTensor(TF_DataType dtype, |
| 393 | const tensorflow::TensorShape& shape) { |
| 394 | static char empty; |
| 395 | tensorflow::int64 nelems = 1; |
| 396 | std::vector<tensorflow::int64> dims; |
| 397 | for (int i = 0; i < shape.dims(); ++i) { |
| 398 | dims.push_back(shape.dim_size(i)); |
| 399 | nelems *= shape.dim_size(i); |
| 400 | } |
| 401 | CHECK_EQ(nelems, 0); |
| 402 | static_assert(sizeof(int64_t) == sizeof(tensorflow::int64), |
| 403 | "64-bit int types should match in size"); |
| 404 | return TF_NewTensor( |
| 405 | dtype, reinterpret_cast<const int64_t*>(dims.data()), shape.dims(), |
| 406 | reinterpret_cast<void*>(&empty), 0, [](void*, size_t, void*) {}, nullptr); |
| 407 | } |
| 408 | |
| 409 | static void TF_Run_Helper( |
| 410 | Session* session, const char* handle, const TF_Buffer* run_options, |
no test coverage detected