| 136 | } |
| 137 | |
| 138 | Maybe<Tensor> LocalTensor::clone() const { |
| 139 | std::shared_ptr<Tensor> input = std::const_pointer_cast<Tensor>(shared_from_this()); |
| 140 | const bool pin_memory = JUST(JUST(input->AsLocalTensor())->is_pinned()); |
| 141 | return JUST(functional::Copy(input, JUST(this->device()), /*pin_memory=*/pin_memory)); |
| 142 | } |
| 143 | |
| 144 | Maybe<void> LocalTensor::set_data(const std::shared_ptr<Tensor>& other) { |
| 145 | CHECK_OR_RETURN(this->is_leaf()) << "Can only set leaf tensor's data."; |