// // CPURasterDiff.cpp // MNN // // Created by MNN on 2023/07/03. // Copyright © 2018, Alibaba Group Holding Limited // #include "../CPUBackend.hpp" #include "../compute/CommonOptFunction.h" namespace MNN { #ifdef MNN_SUPPORT_RENDER class CPURasterDiff : public Execution { public: CPURasterDiff(Backend* bn) : Execution(bn) { // Do nothing } virtual ~ CPURasterDiff() { // Do nothing } virtual ErrorCode onExecute(const std::vector &inputs, const std::vector &outputs) override { auto width = inputs[0]->length(2); auto height = inputs[0]->length(1); auto batch = inputs[0]->length(0); auto unit = inputs[0]->length(3); for (int b=0; bhost() + b * width * height * unit; auto dyPtr = outputs[1]->host() + b * width * height * unit; auto inputPtr = inputs[0]->host() + b * width * height * unit; // Compute Dx for (int y=0; y &inputs, const std::vector &outputs) override { MNN_ASSERT(inputs.size() == 2); MNN_ASSERT(outputs.size() == 1); auto width = inputs[0]->length(2); auto height = inputs[0]->length(1); auto batch = inputs[0]->length(0); auto unit = inputs[0]->length(3); ::memset(outputs[0]->host(), 0, width * height * batch * unit * sizeof(float)); for (int b=0; bhost() + b * width * height * unit; auto dyPtr = inputs[1]->host() + b * width * height * unit; auto inputPtr = outputs[0]->host() + b * width * height * unit; // Compute Dx for (int y=0; y &inputs, const std::vector &outputs, const MNN::Op *op, Backend *backend) const { if (nullptr != op->main_as_Extra()) { return new CPURasterDiffGrad(backend); } return new CPURasterDiff(backend); } }; #endif REGISTER_CPU_OP_CREATOR_RENDER(CPURasterDiffCreator, OpType_RasterDiff); } // namespace MNN