[Diffusion] Add C++ dpm solver (#714)

* Add BetaForAlphaBar, ConvertModelOutput, SetTimesteps, and constructor for DPMSolverMultistepScheduler

* tmp

* Add DPMSolverFirstOrderUpdate

* Add ScaleModelInput

* Add MultiStepDPMSolverSecondOrderUpdate

* add MultiStepDPMSolverThirdOrderUpdate

* Add Step

* Add FASTDEPLOY_DECL

* Add AddNoise

* Fix operator

* update

* Fix DPMSolverMultistepScheduler

* Upgrade Slice

* Fix DPMSolverFirstOrderUpdate

* remove FASTDEPLOY_DECL

* Add config for dpm solver
This commit is contained in:
Jack Zhou
2022-11-30 13:41:22 +08:00
committed by GitHub
parent 3f8ed9bfee
commit d95094cfe5
14 changed files with 675 additions and 11 deletions

View File

@@ -163,5 +163,20 @@ void Slice(const FDTensor& x, const std::vector<int64_t>& axes,
}));
}
void Slice(const FDTensor& x, const std::vector<int64_t>& axes,
const std::vector<int64_t>& index, FDTensor* out) {
std::vector<int64_t> ends = index;
for (int i = 0; i < ends.size(); ++i) {
ends[i] += 1;
}
Slice(x, axes, index, ends, out);
for (int i = 0; i < axes.size(); ++i) {
if (out->Shape().size() <= 1) {
break;
}
out->Squeeze(axes[i]);
}
}
} // namespace function
} // namespace fastdeploy