| 999 | } |
| 1000 | |
| 1001 | ZipEnhancerGraphOutput run(const Tensor4 & input) const { |
| 1002 | if (input.b != 1 || input.c != 2 || input.t != frames_ || input.f != kFreqBins) { |
| 1003 | throw std::runtime_error("ZipEnhancer forward graph input shape changed without rebuild"); |
| 1004 | } |
| 1005 | ggml_backend_tensor_set(input_, input.v.data(), 0, input.v.size() * sizeof(float)); |
| 1006 | const auto status = core::compute_backend_graph(backend_, graph_, plan_, "ZipEnhancer forward"); |
| 1007 | ggml_backend_synchronize(backend_); |
| 1008 | if (status != GGML_STATUS_SUCCESS) { |
| 1009 | throw std::runtime_error("ZipEnhancer forward graph compute failed"); |
| 1010 | } |
| 1011 | ZipEnhancerGraphOutput output; |
| 1012 | output.magnitude = Tensor4(magnitude_shape_.dims[0], magnitude_shape_.dims[1], magnitude_shape_.dims[2], magnitude_shape_.dims[3]); |
| 1013 | output.phase_real = Tensor4(phase_shape_.dims[0], phase_shape_.dims[1], phase_shape_.dims[2], phase_shape_.dims[3]); |
| 1014 | output.phase_imag = Tensor4(phase_shape_.dims[0], phase_shape_.dims[1], phase_shape_.dims[2], phase_shape_.dims[3]); |
| 1015 | ggml_backend_tensor_get(magnitude_, output.magnitude.v.data(), 0, output.magnitude.v.size() * sizeof(float)); |
| 1016 | ggml_backend_tensor_get(phase_real_, output.phase_real.v.data(), 0, output.phase_real.v.size() * sizeof(float)); |
| 1017 | ggml_backend_tensor_get(phase_imag_, output.phase_imag.v.data(), 0, output.phase_imag.v.size() * sizeof(float)); |
| 1018 | return output; |
| 1019 | } |
| 1020 | |
| 1021 | private: |
| 1022 | ggml_backend_t backend_ = nullptr; |
no test coverage detected