| 769 | |
| 770 | template <typename I, std::int32_t D> |
| 771 | void Initialize(I const (&shape)[D], DeviceOrd device) { |
| 772 | static_assert(D <= kDim, "Invalid shape."); |
| 773 | std::copy(shape, shape + D, shape_); |
| 774 | for (auto i = D; i < kDim; ++i) { |
| 775 | shape_[i] = 1; |
| 776 | } |
| 777 | if (!device.IsCPU()) { |
| 778 | data_.SetDevice(device); |
| 779 | data_.ConstDevicePointer(); // Pull to device; |
| 780 | } |
| 781 | CHECK_EQ(data_.Size(), detail::CalcSize(shape_)); |
| 782 | } |
| 783 | |
| 784 | public: |
| 785 | Tensor() = default; |