diff --git a/include/aidge/backend/cuda.hpp b/include/aidge/backend/cuda.hpp index a6bae174471e665f229d08a489d6b9f7911a6e9f..cfae53b64115aa7946580d00f45be56f17163d7f 100644 --- a/include/aidge/backend/cuda.hpp +++ b/include/aidge/backend/cuda.hpp @@ -14,5 +14,6 @@ #include "aidge/backend/cuda/data/TensorImpl.hpp" #include "aidge/backend/cuda/operator/ConvImpl.hpp" +#include "aidge/backend/cuda/operator/ProducerImpl.hpp" #endif /* AIDGE_BACKEND_CUDA_IMPORTS_H_ */ \ No newline at end of file diff --git a/include/aidge/backend/cuda/operator/ProducerImpl.hpp b/include/aidge/backend/cuda/operator/ProducerImpl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9912133072e23181df8f384841660bf89a829b60 --- /dev/null +++ b/include/aidge/backend/cuda/operator/ProducerImpl.hpp @@ -0,0 +1,40 @@ +/******************************************************************************** + * 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_CUDA_OPERATOR_PRODUCERIMPL_H_ +#define AIDGE_CUDA_OPERATOR_PRODUCERIMPL_H_ + +#include <memory> + +#include "aidge/backend/OperatorImpl.hpp" +#include "aidge/operator/Producer.hpp" +#include "aidge/utils/Registrar.hpp" +#include "aidge/utils/Types.h" + +namespace Aidge { +class ProducerImpl_cuda : public OperatorImpl { +public: + ProducerImpl_cuda(const Producer_Op &op) : OperatorImpl(op) {} + + static std::unique_ptr<ProducerImpl_cuda> create(const Producer_Op &op) { + return std::make_unique<ProducerImpl_cuda>(op); + } + + NbElts_t getNbProducedData(const IOIndex_t outputIdx) const override final; + void forward() override; +}; + +namespace { +static Registrar<Producer_Op> registrarProducerImpl_cuda("cuda", Aidge::ProducerImpl_cuda::create); +} // namespace +} // namespace Aidge + +#endif /* AIDGE_CUDA_OPERATOR_PRODUCERIMPL_H_ */ diff --git a/src/operator/ProducerImpl.cpp b/src/operator/ProducerImpl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aca3c4945e357be13017e302cb6e7f12ba61237c --- /dev/null +++ b/src/operator/ProducerImpl.cpp @@ -0,0 +1,34 @@ +/******************************************************************************** + * 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 <vector> + +#include "aidge/data/Tensor.hpp" +#include "aidge/operator/Producer.hpp" +#include "aidge/utils/Types.h" + +#include "aidge/backend/cuda/operator/ProducerImpl.hpp" + +Aidge::DimSize_t Aidge::ProducerImpl_cuda::getNbProducedData( + Aidge::IOIndex_t outputIdx) const +{ + // Requires the whole tensors, regardless of available data on inputs + assert(outputIdx == 0 && "operator has only one output"); + (void) outputIdx; + + return std::static_pointer_cast<Tensor>(mOp.getRawOutput(0))->size(); +} + +void Aidge::ProducerImpl_cuda::forward() +{ +}