| 66 | class TestTensorRoundTrip : public BaseTensorTest { |
| 67 | public: |
| 68 | void CheckTensorRoundTrip(const Tensor& tensor) { |
| 69 | int32_t metadata_length; |
| 70 | int64_t body_length; |
| 71 | const int elem_size = tensor.type()->byte_width(); |
| 72 | |
| 73 | ASSERT_OK(mmap_->Seek(0)); |
| 74 | |
| 75 | ASSERT_OK(WriteTensor(tensor, mmap_.get(), &metadata_length, &body_length)); |
| 76 | |
| 77 | const int64_t expected_body_length = elem_size * tensor.size(); |
| 78 | ASSERT_EQ(expected_body_length, body_length); |
| 79 | |
| 80 | ASSERT_OK(mmap_->Seek(0)); |
| 81 | |
| 82 | std::shared_ptr<Tensor> result; |
| 83 | ASSERT_OK_AND_ASSIGN(result, ReadTensor(mmap_.get())); |
| 84 | |
| 85 | ASSERT_EQ(result->data()->size(), expected_body_length); |
| 86 | ASSERT_TRUE(tensor.Equals(*result)); |
| 87 | } |
| 88 | |
| 89 | protected: |
| 90 | std::shared_ptr<io::MemoryMappedFile> mmap_; |
nothing calls this directly
no test coverage detected