| 1873 | |
| 1874 | template <typename T> |
| 1875 | void CheckToTensor(const std::shared_ptr<Array>& array, const std::vector<int64_t>& shape, |
| 1876 | std::initializer_list<T> values) { |
| 1877 | const auto value_type = CTypeTraits<T>::type_singleton(); |
| 1878 | ASSERT_OK_AND_ASSIGN( |
| 1879 | auto expected, |
| 1880 | Tensor::Make(value_type, Buffer::Wrap(values.begin(), values.size()), shape)); |
| 1881 | |
| 1882 | ASSERT_OK_AND_ASSIGN(auto tensor, array->ToTensor()); |
| 1883 | ASSERT_OK(tensor->Validate()); |
| 1884 | |
| 1885 | AssertTypeEqual(*value_type, *tensor->type()); |
| 1886 | ASSERT_EQ(shape, tensor->shape()); |
| 1887 | ASSERT_TRUE(tensor->is_row_major()); |
| 1888 | ASSERT_TRUE(tensor->Equals(*expected)); |
| 1889 | |
| 1890 | // The tensor shares the values buffer, it does not copy |
| 1891 | const auto leaf = LeafValues(array); |
| 1892 | ASSERT_EQ(leaf->data()->buffers[1]->data() + leaf->offset() * sizeof(T), |
| 1893 | tensor->data()->data()); |
| 1894 | } |
| 1895 | |
| 1896 | } // namespace |
| 1897 |
nothing calls this directly
no test coverage detected