TODO(zhoushunjie): need to remove it for general space
| 123 | |
| 124 | // TODO(zhoushunjie): need to remove it for general space |
| 125 | void StringTensor::init_holder() { |
| 126 | void* ptr = holder_->ptr(); |
| 127 | auto& place = holder_->place(); |
| 128 | auto bytes_size = holder_->size(); |
| 129 | VLOG(6) << "Init StringTensor data with bytes:" << bytes_size; |
| 130 | if (place.GetType() == AllocationType::CPU) { |
| 131 | std::memset(ptr, 0, bytes_size); |
| 132 | } else if (place.GetType() == AllocationType::GPU) { |
| 133 | #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) |
| 134 | #ifdef PADDLE_WITH_HIP |
| 135 | hipMemset(ptr, 0, bytes_size); |
| 136 | #else |
| 137 | cudaMemset(ptr, 0, bytes_size); |
| 138 | #endif |
| 139 | #endif |
| 140 | } else { |
| 141 | // TODO(zhoushunjie): Need to support more places |
| 142 | PADDLE_THROW( |
| 143 | errors::Unimplemented("StringTensor can only be created in CPU or GPU " |
| 144 | "place. But now attempts to " |
| 145 | "create StringTensor on %s", |
| 146 | place.DebugString())); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void* StringTensor::AllocateFrom(Allocator* allocator, |
| 151 | DataType dtype, |
nothing calls this directly
no test coverage detected