MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Initialize

Method Initialize

tensorflow/stream_executor/rocm/rocm_fft.cc:157–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155} // namespace
156
157port::Status ROCMFftPlan::Initialize(
158 GpuExecutor *parent, Stream *stream, int rank, uint64 *elem_count,
159 uint64 *input_embed, uint64 input_stride, uint64 input_distance,
160 uint64 *output_embed, uint64 output_stride, uint64 output_distance,
161 fft::Type type, int batch_count, ScratchAllocator *scratch_allocator) {
162 if (IsInitialized()) {
163 LOG(FATAL) << "Try to repeatedly initialize.";
164 }
165 is_initialized_ = true;
166 int elem_count_[3], input_embed_[3], output_embed_[3];
167 for (int i = 0; i < rank; ++i) {
168 elem_count_[i] = elem_count[i];
169 if (input_embed) {
170 input_embed_[i] = input_embed[i];
171 }
172 if (output_embed) {
173 output_embed_[i] = output_embed[i];
174 }
175 }
176 parent_ = parent;
177 fft_type_ = type;
178 if (batch_count == 1 && input_embed == nullptr && output_embed == nullptr) {
179 hipfftResult_t ret;
180 if (scratch_allocator == nullptr) {
181 switch (rank) {
182 case 1:
183 // hipfftPlan1d
184 ret = wrap::hipfftPlan1d(parent, &plan_, elem_count_[0],
185 ROCMFftType(type), 1 /* = batch */);
186 if (ret != HIPFFT_SUCCESS) {
187 LOG(ERROR) << "failed to create rocFFT 1d plan:" << ret;
188 return port::Status{port::error::INTERNAL,
189 "Failed to create rocFFT 1d plan."};
190 }
191 return port::Status::OK();
192 case 2:
193 // hipfftPlan2d
194 ret = wrap::hipfftPlan2d(parent, &plan_, elem_count_[0],
195 elem_count_[1], ROCMFftType(type));
196 if (ret != HIPFFT_SUCCESS) {
197 LOG(ERROR) << "failed to create rocFFT 2d plan:" << ret;
198 return port::Status{port::error::INTERNAL,
199 "Failed to create rocFFT 2d plan."};
200 }
201 return port::Status::OK();
202 case 3:
203 // hipfftPlan3d
204 ret =
205 wrap::hipfftPlan3d(parent, &plan_, elem_count_[0], elem_count_[1],
206 elem_count_[2], ROCMFftType(type));
207 if (ret != HIPFFT_SUCCESS) {
208 LOG(ERROR) << "failed to create rocFFT 3d plan:" << ret;
209 return port::Status{port::error::INTERNAL,
210 "Failed to create rocFFT 3d plan."};
211 }
212 return port::Status::OK();
213 default:
214 LOG(ERROR) << "Invalid rank value for hipfftPlan. "

Calls 6

ROCMFftTypeFunction · 0.85
opaqueMethod · 0.80
InitializeFunction · 0.50
AllocateBytesMethod · 0.45
okMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected