| 115 | } |
| 116 | |
| 117 | void TensibleVariable::Pad( |
| 118 | int64 size, const std::function<void(Status)>& done) { |
| 119 | if (size == size_) { |
| 120 | done(Status::OK()); |
| 121 | return; |
| 122 | } |
| 123 | if (size_ - size > segment_size_ || size_ < size) { |
| 124 | done(errors::FailedPrecondition( |
| 125 | "TensibleVariable Pad size should less than 1 segment ", |
| 126 | std::to_string(size_), " ", std::to_string(size))); |
| 127 | return; |
| 128 | } |
| 129 | generator_->GetNextTensor([this, size, done](Status st, const Tensor& tensor) { |
| 130 | if (!st.ok()) { |
| 131 | done(st); |
| 132 | return; |
| 133 | } |
| 134 | if (size_ - size > segment_size_ || size_ < size) { |
| 135 | done(errors::FailedPrecondition( |
| 136 | "TensibleVariable Pad size should less than 1 segment ", |
| 137 | std::to_string(size_), " ", std::to_string(size))); |
| 138 | return; |
| 139 | } |
| 140 | int64 pad = size_ - size; |
| 141 | memcpy(const_cast<char*>( |
| 142 | tensors_.back().tensor_data().data()) + |
| 143 | (segment_size_ - pad) * slice_size_, |
| 144 | tensor.tensor_data().data(), pad * slice_size_); |
| 145 | done(Status::OK()); |
| 146 | }); |
| 147 | } |
| 148 | |
| 149 | void TensibleVariable::Clear() { |
| 150 | mutex_lock lock(structure_update_mu_); |
no test coverage detected