Newer
Older
/********************************************************************************
* 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 <numeric> // std::accumulate
#include "aidge/data/Tensor.hpp"
#include "aidge/operator/Producer.hpp"
#include "aidge/utils/Types.h"
#include "aidge/operator/ProducerImpl.hpp"
std::size_t Aidge::ProducerImpl_cpu::getNbRequiredData(
Aidge::IOIndex_t /*inputIdx*/) const
{
return 0;
}
Aidge::DimSize_t Aidge::ProducerImpl_cpu::getNbConsumedData(
Aidge::IOIndex_t /*inputIdx*/) const
{
return 0;
}
std::size_t Aidge::ProducerImpl_cpu::getNbRequiredProtected(
Aidge::IOIndex_t /*inputIdx*/) const
{
return 0;
}
std::size_t Aidge::ProducerImpl_cpu::getRequiredMemory(
__attribute__((unused)) const IOIndex_t outputIdx, __attribute__((unused)) const std::vector<DimSize_t> &inputsSize) const
{
// Requires the whole tensors, regardless of available data on inputs
assert(outputIdx == 0 && "operator has only one output");
const auto &outputDims = std::static_pointer_cast<Tensor>(mOp.getOutput(0))->dims();
return std::accumulate(
outputDims.begin(),
outputDims.end(),
NbElts_t(1),
std::multiplies<NbElts_t>());
}
Aidge::DimSize_t Aidge::ProducerImpl_cpu::getNbProducedData(
Aidge::IOIndex_t /*outputIdx*/) const
{
return getRequiredMemory(0, {});
}
void Aidge::ProducerImpl_cpu::forward()
{
}
void Aidge::ProducerImpl_cpu::backward()
{
printf("Not implemented yet.\n");
}