| 23 | namespace singa { |
| 24 | |
| 25 | void* Block::mutable_data() { |
| 26 | if (data_ == nullptr && size_ > 0) { |
| 27 | data_ = device_->Malloc((int)size_); |
| 28 | } |
| 29 | initialized_ = true; |
| 30 | return static_cast<char*>(data_) + offset_; |
| 31 | } |
| 32 | |
| 33 | const void* Block::data() const { |
| 34 | CHECK(initialized_) << "Must initialize data before reading it"; |