Skip to content
Snippets Groups Projects
GatherImpl.cpp 1.4 KiB
Newer Older
Houssem ROUIS's avatar
Houssem ROUIS 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
 *
 ********************************************************************************/

Maxence Naud's avatar
Maxence Naud committed
#include "aidge/backend/cpu/operator/GatherImpl.hpp"

#include <memory>
Houssem ROUIS's avatar
Houssem ROUIS committed
#include <vector>

Maxence Naud's avatar
Maxence Naud committed
#include "aidge/backend/cpu/operator/GatherImpl_forward_kernels.hpp"
#include "aidge/data/Data.hpp"
#include "aidge/data/Tensor.hpp"
Houssem ROUIS's avatar
Houssem ROUIS committed
#include "aidge/operator/Gather.hpp"
#include "aidge/utils/Types.h"

Aidge::NbElts_t Aidge::GatherImpl_cpu::getNbRequiredProtected(const Aidge::IOIndex_t /*inputIdx*/) const {
    // this implementation can be in-place
    return 0;
}

void Aidge::GatherImpl_cpu::forward() {
Maxence Naud's avatar
Maxence Naud committed
    const Gather_Op& op = static_cast<const Gather_Op&>(mOp);
Houssem ROUIS's avatar
Houssem ROUIS committed

    auto kernelFunc = Registrar<GatherImplForward_cpu>::create({
Maxence Naud's avatar
Maxence Naud committed
                            op.getInput(0)->dataType(),
                            op.getOutput(0)->dataType()
                        });
Houssem ROUIS's avatar
Houssem ROUIS committed

    // Call kernel
    kernelFunc(dynamic_cast<const Gather_Op&>(mOp).getStaticAttributes(),
Maxence Naud's avatar
Maxence Naud committed
            op.getInput(0)->dims(),
            op.getInput(0)->getImpl()->rawPtr(),
            op.getOutput(0)->getImpl()->rawPtr()
        );
Houssem ROUIS's avatar
Houssem ROUIS committed
}