Skip to content
Snippets Groups Projects
Commit 48a0df4a authored by Maxence Naud's avatar Maxence Naud Committed by Maxence Naud
Browse files

Move generic implementations to their own files

parent c05db685
No related branches found
No related tags found
1 merge request!361Move code from header to source
Showing
with 829 additions and 58 deletions
......@@ -9,6 +9,9 @@
*
********************************************************************************/
#ifndef AIDGE_CORE_BACKEND_GENERIC_OPERATOR_CONCATIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_CONCATIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
......@@ -38,4 +41,6 @@ public:
*/
void forward() override;
};
} // namespace Aidge
\ No newline at end of file
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_CONCATIMPL_H_
......@@ -9,6 +9,9 @@
*
********************************************************************************/
#ifndef AIDGE_CORE_BACKEND_GENERIC_OPERATOR_DEPTHTOSPACEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_DEPTHTOSPACEIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
......@@ -35,3 +38,5 @@ public:
void forward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_DEPTHTOSPACEIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_FLATTENIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_FLATTENIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/scheduler/ProdConso.hpp"
namespace Aidge {
/**
* @brief Implementation of the Flatten operation.
*
* Since Flatten operation is just backend-agnostic, its implementation is located in aidge_core.
*/
class Flatten_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructor for Flatten operator implementation.
* @param op Operator instance.
* @param backend Optional. Name of the backend.
*/
Flatten_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
/**
* @brief Compute the forward pass of the Flatten operation.
*/
void forward() override;
std::shared_ptr<ProdConso> getProdConso() const override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_FLATTENIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_GATHERIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_GATHERIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
/**
* @class Gather_OpImpl
* @brief Backend implementation for the Gather operation.
*
* The Gather operation selects elements from the input tensor based on specified indices
* and an axis, producing a tensor with a gathered shape.
*/
class Gather_OpImpl : public OperatorImpl {
public:
Gather_OpImpl(const Operator& op, const std::string& backend = "")
: OperatorImpl(op, backend) {}
/**
* @brief Execute the Gather operation.
*/
void forward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_GATHERIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_IDENTITYIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_IDENTITYIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/scheduler/ProdConso.hpp"
namespace Aidge {
class Identity_OpImpl : public OperatorImpl {
public:
Identity_OpImpl(const Operator& op, const std::string& backend = "")
: OperatorImpl(op, backend) {}
void forward() override;
std::shared_ptr<ProdConso> getProdConso() const override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_IDENTITYIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_MEMORIZEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_MEMORIZEIMPL_H_
#include <memory>
#include <string>
#include <vector>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/data/Elts.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/scheduler/ProdConso.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
/**
* @class Memorize_ProdConso
* @brief Implements the producer-consumer principle for the `Memorize` operator.
*
* The `Memorize_ProdConso` class defines the logic for managing data dependencies during
* the forward process of the `Memorize` operator.
*
* This class ensures that:
* - All data produced by the `Memorize` operator is properly consumed.
* - All required outputs are correctly filled during the forward pass.
*
* It also calculates data and memory requirements specific to the `Memorize` operator.
*/
class Memorize_ProdConso : public ProdConso {
public:
/**
* @brief Constructor for the `Memorize_ProdConso` class.
* @param[in] op The operator instance for which producer-consumer relationships are managed.
*
* @details:
* - The provided `Operator` instance is used to initialize the base `ProdConso` class.
* - This operator will determine the specific requirements for data production
* and consumption during the forward process.
*/
Memorize_ProdConso(const Operator& op): ProdConso(op) {}
/**
* @brief Get the number of data elements required from an input tensor for forward computation.
* @param[in] inputIdx The index of the input tensor.
* @return The number of required elements (`Elts_t`).
*
* @details:
* - For each input tensor identified by `inputIdx`, this method calculates the
* minimum amount of data needed by the `Memorize` operator to perform its forward step.
*/
Elts_t getNbRequiredData(const IOIndex_t inputIdx) const override final;
/**
* @brief Compute the memory requirements for an output tensor.
* @param[in] outputIdx The index of the output tensor.
* @param[in] inputsSize A vector containing the dimensions of the input tensors.
* @return The memory required (`Elts_t`) for the specified output tensor.
*
* @details:
* - This method evaluates how much memory is needed for the `outputIdx` tensor
* based on the input tensor dimensions and the attributes of the `Memorize` operator.
* - Memory requirements are influenced by factors such as sequence length and
* the forward step configuration.
*/
Elts_t getRequiredMemory(const IOIndex_t outputIdx, const std::vector<DimSize_t>& inputsSize) const override final;
/**
* @brief Update the producer-consumer relationships for the `Memorize` operator.
* @details:
* - This method ensures that all data produced by the `Memorize` operator is
* appropriately consumed by downstream operators in the computational graph.
* - It also verifies that all required outputs are filled during the forward pass,
* maintaining consistency in the data flow.
* - This step is crucial for ensuring correctness in recurrent computations and
* maintaining dependencies in the graph.
*/
void updateConsummerProducer() override;
};
/**
* @brief Implementation of the Memorize operation.
*
* Since Memorize operation is just backend-agnostic, its implementation is located in aidge_core.
*/
class Memorize_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructs a Memorize_OpImpl object.
* @param[in] op The operator to be implemented.
* @param[in] backend The backend used for execution.
*/
Memorize_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
/**
* @brief Get the Producer Consumer object of the operator.
* @return A shared pointer to the ProdConso object.
*/
std::shared_ptr<ProdConso> getProdConso() const override { return std::make_shared<Memorize_ProdConso>(mOp); };
/**
* @brief Executes the forward pass for the Memorize operation.
*/
void forward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_MEMORIZEIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_MOVEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_MOVEIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
class Move_OpImpl : public OperatorImpl {
public:
Move_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
void forward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_MOVEIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_POPIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_POPIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
/**
* @class Pop_ProdConso
* @brief Implements the producer-consumer principle for the `Pop` operator.
*
* The `Pop_ProdConso` class defines the logic for managing data dependencies during
* the forward process of the `Pop` operator.
*
* This class ensures that:
* - All data consumed by the `Pop` operator is correctly handled.
* - The operator respects memory and data requirements during the forward computation.
*/
class Pop_ProdConso : public ProdConso {
public:
/**
* @brief Constructor for the `Pop_ProdConso` class.
* @param[in] op The operator instance for which producer-consumer relationships are managed.
*
* @details:
* - The provided `Operator` instance is used to initialize the base `ProdConso` class.
* - This operator determines specific requirements for data consumption during the forward process.
*/
Pop_ProdConso(const Operator& op): ProdConso(op) {}
/**
* @brief Get the number of data elements required from an input tensor for forward computation.
* @param[in] inputIdx The index of the input tensor.
* @return The number of required elements (`Elts_t`).
*
* @details:
* - For each input tensor identified by `inputIdx`, this method calculates the
* minimum amount of data needed by the `Pop` operator to perform its forward step.
*/
Elts_t getNbRequiredData(const IOIndex_t inputIdx) const override;
};
/**
* @class Pop_OpImpl
* @brief Implementation of the `Pop` operation.
*
* The `Pop_OpImpl` class defines the backend-agnostic logic for executing
* the forward pass of the `Pop` operator.
*/
class Pop_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructs a `Pop_OpImpl` object.
* @param[in] op The operator to be implemented.
* @param[in] backend The backend used for execution (optional).
*/
Pop_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
/**
* @brief Get the Producer Consumer object of the operator.
* @return A shared pointer to the `Pop_ProdConso` object.
*/
std::shared_ptr<ProdConso> getProdConso() const override { return std::make_shared<Pop_ProdConso>(mOp); }
/**
* @brief Executes the forward pass for the `Pop` operation.
*/
void forward() override;
/**
* @brief Executes the backward pass for the `Pop` operation.
*/
void backward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_POPIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_RESHAPEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_RESHAPEIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/scheduler/ProdConso.hpp"
namespace Aidge {
/**
* @brief Implementation of the Reshape operator.
* @note This operator implementation is agnostic to the backend and is located here instead of in aidge_backend.
*/
class Reshape_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructor for Reshape_OpImpl.
* @param[in] op The Operator instance.
* @param[in] backend The backend name (optional).
*/
Reshape_OpImpl(const Operator& op, const std::string& backend = "")
: OperatorImpl(op, backend) {}
/**
* @brief Perform the forward operation for the reshape.
*/
void forward() override;
void backward() override;
std::shared_ptr<ProdConso> getProdConso() const override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_RESHAPEIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_SELECTIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SELECTIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
/**
* @brief Implementation of the Select operator.
* @note This operator implementation is agnostic to the backend and is located here instead of in aidge_backend.
*/
class Select_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructor for Select_OpImpl.
* @param[in] op The Operator instance.
* @param[in] backend The backend name (optional).
*/
Select_OpImpl(const Operator& op, const std::string& backend = "")
: OperatorImpl(op, backend) {}
/**
* @brief Perform the forward operation for the reshape.
*/
void forward() override;
void backward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SELECTIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_SHAPEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SHAPEIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
/**
* @class Shape_OpImpl
* @brief Backend-agnostic implementation of the Shape operator.
*
* This implementation is responsible for extracting and returning the shape
* of the input tensor. Specific backend functionality can extend this.
*/
class Shape_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructor for the Shape_OpImpl class.
* @param[in] op The Operator instance.
* @param[in] backend The backend name (optional).
*/
Shape_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
/**
* @brief Perform the forward operation to compute the shape of the tensor.
*/
void forward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SHAPEIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_SLICEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SLICEIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
/**
* @brief Implementation of the Slice operation.
*
* Since Slice operation is just backend-agnostic, its implementation is located in aidge_core.
*/
class Slice_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructs a Slice_OpImpl object.
* @param[in] op The operator to be implemented.
* @param[in] backend The backend used for execution.
*/
Slice_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
/**
* @brief Executes the forward pass for the Slice operation.
*/
void forward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SLICEIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_STACKIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_STACKIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
/**
* @class Implementation of the Split operation.
*
* Since Split operation is just backend-agnostic, its implementation is located in aidge_core.
*/
class Split_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructor for the Split operator implementation.
* @param[in] op Operator to be implemented.
* @param[in] backend Name of the backend.
*/
Split_OpImpl(const Operator& op, const std::string& backend = "") : OperatorImpl(op, backend) {}
/**
* @brief Executes the forward pass for the Split operation.
*/
void forward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_STACKIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_SQUEEZEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SQUEEZEIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/scheduler/ProdConso.hpp"
namespace Aidge {
/**
* @brief implementation of the operator squeeze.
* @note Since this operator implementation is agnostic to the backend it is
* located here instead of in aidge_backend_cpu/cuda.
*/
class Squeeze_OpImpl : public OperatorImpl {
public:
Squeeze_OpImpl(const Operator &op, const std::string &backend = "")
: OperatorImpl(op, backend) {}
void forward() override;
std::shared_ptr<ProdConso> getProdConso() const override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_SQUEEZEIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_STACKIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_STACKIMPL_H_
#include <memory>
#include <string>
#include <vector>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
/**
* @class StackProdConso
* @brief Implements the producer-consumer principle for the `Stack` operator.
*
* The `StackProdConso` class defines the logic for managing data dependencies
* during the forward process of the `Stack` operator. It ensures proper allocation
* and consumption of resources required for stacking operations.
*/
class StackProdConso : public ProdConso {
public:
/**
* @brief Constructor for the `StackProdConso` class.
* @param[in] op The operator instance for which producer-consumer relationships are managed.
*/
StackProdConso(const Operator& op) : ProdConso(op) {}
/**
* @brief Compute the memory requirements for an output tensor.
* @param[in] outputIdx The index of the output tensor.
* @param[in] inputsSize A vector containing the dimensions of the input tensors.
* @return The memory required (`Elts_t`) for the specified output tensor.
*
* @details:
* - This method calculates how much memory is needed to store the stacked tensor.
* - Memory requirements depend on the number and size of the input tensors.
*/
Elts_t getRequiredMemory(const IOIndex_t outputIdx, const std::vector<DimSize_t>& inputsSize) const override final;
/**
* @brief Reset producer-consumer relationships for the `Stack` operator.
*
* @details:
* - This method clears and reinitializes the producer-consumer relationships,
* ensuring proper data flow and allocation for the stacking operation.
*/
void resetConsummerProducer() override;
};
/**
* @class StackOpImpl
* @brief Backend-specific implementation of the `Stack` operator.
*
* The `StackOpImpl` class handles the execution of the `Stack` operation, including
* forward computation and backend-specific optimizations.
*/
class StackOpImpl : public OperatorImpl {
public:
/**
* @brief Constructs a StackOpImpl object.
* @param[in] op The operator to be implemented.
* @param[in] backend The backend used for execution.
*/
StackOpImpl(const Operator& op, const std::string& backend = "") : OperatorImpl(op, backend) {}
/**
* @brief Get the Producer Consumer object of the operator.
* @return A shared pointer to the ProdConso object.
*/
std::shared_ptr<ProdConso> getProdConso() const override {
return std::make_shared<StackProdConso>(mOp);
}
/**
* @brief Executes the forward pass for the Stack operation.
*/
void forward() override;
/**
* @brief Executes the backward pass for the Stack operation.
*/
void backward() override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_STACKIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_UNFOLDIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_UNFOLDIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
namespace Aidge {
/**
* @brief Implementation of the Unfold operator.
* @tparam DIM Number of dimensions in the operation.
*/
template <DimIdx_t DIM>
class Unfold_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructor for Unfold_OpImpl.
* @param[in] op The Operator instance.
* @param[in] backend The backend name (optional).
*/
Unfold_OpImpl(const Operator& op, const std::string& backend = "")
: OperatorImpl(op, backend) {}
/**
* @brief Perform the forward operation for the unfold.
*/
void forward() override;
};
extern template class Unfold_OpImpl<2>;
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_UNFOLDIMPL_H_
/********************************************************************************
* 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_CORE_BACKEND_GENERIC_OPERATOR_UNSQUEEZEIMPL_H_
#define AIDGE_CORE_BACKEND_GENERIC_OPERATOR_UNSQUEEZEIMPL_H_
#include <string>
#include "aidge/backend/OperatorImpl.hpp"
#include "aidge/operator/Operator.hpp"
#include "aidge/scheduler/ProdConso.hpp"
namespace Aidge {
/**
* @brief implementation of the operator unsqueeze.
* @note Since this operator implementation is agnostic to the backend it is
* located here instead of in aidge_backend_cpu/cuda.
*/
class Unsqueeze_OpImpl : public OperatorImpl {
public:
Unsqueeze_OpImpl(const Operator &op, const std::string &backend = "")
: OperatorImpl(op, backend) {}
void forward() override;
std::shared_ptr<ProdConso> getProdConso() const override;
};
} // namespace Aidge
#endif // AIDGE_CORE_BACKEND_GENERIC_OPERATOR_UNSQUEEZEIMPL_H_
......@@ -22,32 +22,6 @@
#include "aidge/utils/StaticAttributes.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
/**
* @brief Implementation of the Flatten operation.
*
* Since Flatten operation is just backend-agnostic, its implementation is located in aidge_core.
*/
class Flatten_OpImpl : public OperatorImpl {
public:
/**
* @brief Constructor for Flatten operator implementation.
* @param op Operator instance.
* @param backend Optional. Name of the backend.
*/
Flatten_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
std::shared_ptr<ProdConso> getProdConso() const override {
return std::make_shared<ProdConso>(mOp, true); // Flatten is an in-place operation!
}
/**
* @brief Compute the forward pass of the Flatten operation.
*/
void forward() override;
};
} // namespace Aidge
#define LIST_FLATTEN_ATTR(X) \
X(Axis, "axis", std::int64_t)
......
......@@ -24,27 +24,6 @@
#include "aidge/utils/StaticAttributes.hpp"
#include "aidge/utils/Types.h"
namespace Aidge {
/**
* @class Gather_OpImpl
* @brief Backend implementation for the Gather operation.
*
* The Gather operation selects elements from the input tensor based on specified indices
* and an axis, producing a tensor with a gathered shape.
*/
class Gather_OpImpl : public OperatorImpl {
public:
Gather_OpImpl(const Operator& op, const std::string& backend = "")
: OperatorImpl(op, backend) {}
/**
* @brief Execute the Gather operation.
*/
void forward() override;
};
} // namespace Aidge
#define LIST_GATHER_ATTR(X) \
X(Axis, "axis", std::int8_t), \
......
......@@ -26,16 +26,6 @@
#include "aidge/utils/ErrorHandling.hpp"
namespace Aidge {
class Identity_OpImpl : public OperatorImpl {
public:
Identity_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {}
std::shared_ptr<ProdConso> getProdConso() const override {
return std::make_shared<ProdConso>(mOp, true); // Identity is an in-place operation!
}
void forward() override;
};
/**
* @brief Indentity_Op is an helper operator made to ease the declaration of MetaNodes.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment