Skip to content
Snippets Groups Projects
ConvImpl.cpp 1.79 KiB
Newer Older
Cyril Moineau's avatar
Cyril Moineau committed
/********************************************************************************
 * Copyright (c) 2023 CEA-List
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 ********************************************************************************/

#include <cassert>
#include <chrono>  // std::chrono::milliseconds
#include <numeric> // std::accumulate
#include <thread>  // std::this_thread::sleep_for
Cyril Moineau's avatar
Cyril Moineau committed
#include <vector>

#include "aidge/utils/Types.h"
#include "aidge/operator/Conv.hpp"

#include "aidge/backend/cpu/operator/ConvImpl.hpp"
#include "aidge/backend/cpu/operator/ConvImpl_forward_kernels.hpp"
Cyril Moineau's avatar
Cyril Moineau committed

Aidge::NbElts_t Aidge::ConvImpl2D_cpu::getNbRequiredProtected(IOIndex_t /*inputIdx*/) const {
    // this implementation can be in-place
Cyril Moineau's avatar
Cyril Moineau committed
    return 0;
}

void Aidge::ConvImpl2D_cpu::forward() {
    // FIXME: uncomment the following code once memory handling will work
    assert(mOp.getInput(0) && "missing input #0");
    assert(mOp.getInput(1) && "missing input #1");
    assert(mOp.getInput(2) && "missing input #2");

    // Find the correct kernel type
    auto kernelFunc =
            Registrar<ConvImpl2DForward_cpu>::create({mOp.getInput(0)->dataType(), mOp.getInput(1)->dataType(),
                                                          mOp.getInput(2)->dataType(), mOp.getOutput(0)->dataType()});

    // Call kernel
    kernelFunc(dynamic_cast<const Conv_Op<2>&>(mOp).getStaticAttributes(), std::static_pointer_cast<Tensor>(mOp.getInput(0))->dims<4>(),
Cyril Moineau's avatar
Cyril Moineau committed
               mOp.getInput(0)->getImpl()->rawPtr(), mOp.getInput(1)->getImpl()->rawPtr(),
               mOp.getInput(2)->getImpl()->rawPtr(), mOp.getOutput(0)->getImpl()->rawPtr());
}