| 160 | } |
| 161 | |
| 162 | std::vector<VARP> StableDiffusion::forwardWithResizeCache(int index, const std::vector<VARP>& inputs) { |
| 163 | if (index < 0 || index >= mModules.size() || !mModules[index]) { |
| 164 | MNN_ERROR("Invalid diffusion module index: %d\n", index); |
| 165 | return {}; |
| 166 | } |
| 167 | if (mResizeCachePrepared.size() != mModules.size()) { |
| 168 | mResizeCachePrepared.assign(mModules.size(), false); |
| 169 | } |
| 170 | if (!mResizeCachePrepared[index]) { |
| 171 | auto code = mModules[index]->traceOrOptimize(MNN::Interpreter::Session_Resize_Check); |
| 172 | if (code != 0) { |
| 173 | MNN_PRINT("Resize check is not supported for diffusion module %d, code = %d\n", index, code); |
| 174 | } else { |
| 175 | mModules[index]->onForward(inputs); |
| 176 | code = mModules[index]->traceOrOptimize(MNN::Interpreter::Session_Resize_Fix); |
| 177 | if (code != 0) { |
| 178 | MNN_PRINT("Resize fix is not supported for diffusion module %d, code = %d\n", index, code); |
| 179 | } |
| 180 | } |
| 181 | mResizeCachePrepared[index] = true; |
| 182 | } |
| 183 | return mModules[index]->onForward(inputs); |
| 184 | } |
| 185 | |
| 186 | VARP StableDiffusion::text_encoder(const std::vector<int>& ids) { |
| 187 | AUTOTIME; |
nothing calls this directly
no test coverage detected