Skip to content
Snippets Groups Projects

Add GridSample impl for 1D and 2D

Merged Maxence Naud requested to merge feat_145_GridSample into dev
3 files
+ 613
0
Compare changes
  • Side-by-side
  • Inline
Files
3
/********************************************************************************
* 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
*
********************************************************************************/
#ifndef AIDGE_CPU_OPERATOR_GRIDSAMPLEIMPL_H_
#define AIDGE_CPU_OPERATOR_GRIDSAMPLEIMPL_H_
#include <array>
#include <memory>
#include <tuple>
#include <vector>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/GridSample.hpp"
#include "aidge/utils/Registrar.hpp"
#include "aidge/utils/Types.h"
#include "aidge/backend/cpu/data/GetCPUPtr.h"
namespace Aidge {
// compute kernel registry for forward and backward
class GridSampleImpl1DForward_cpu
: public Registrable<GridSampleImpl1DForward_cpu,
std::tuple<DataType, DataType>,
void(const GridSample_Op&,
const std::shared_ptr<Tensor>&,
const std::shared_ptr<Tensor>&,
const std::shared_ptr<Tensor>&)> {};
class GridSampleImpl2DForward_cpu
: public Registrable<GridSampleImpl2DForward_cpu,
std::tuple<DataType, DataType>,
void(const GridSample_Op&,
const std::shared_ptr<Tensor>&,
const std::shared_ptr<Tensor>&,
const std::shared_ptr<Tensor>&)> {};
class GridSampleImpl_cpu : public OperatorImpl {
public:
GridSampleImpl_cpu(const GridSample_Op& op) : OperatorImpl(op, "cpu") {}
static std::unique_ptr<GridSampleImpl_cpu> create(const GridSample_Op &op) {
return std::make_unique<GridSampleImpl_cpu>(op);
}
public:
Elts_t getNbRequiredProtected(const IOIndex_t inputIdx) const override final;
void forward() override;
};
namespace {
// add cpu backend to GridSample_Op<1> implementation registry
static Registrar<GridSample_Op> registrarGridSampleImpl_cpu("cpu", Aidge::GridSampleImpl_cpu::create);
} // namespace
} // namespace Aidge
#endif /* AIDGE_CPU_OPERATOR_GRIDSAMPLEIMPL_H_ */
Loading