diff --git a/include/aidge/operator/ShiftGELU.hpp b/include/aidge/operator/ShiftGELU.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6e27cd6532db0e17751f6c664d14665909fb14b4 --- /dev/null +++ b/include/aidge/operator/ShiftGELU.hpp @@ -0,0 +1,75 @@ +/******************************************************************************** + * Copyright (c) 2024 Thales + * + * 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 + * Author: Lucas RAKOTOARIVONY, Thales Research & Technology France + * Date: 25.06.2024 + * + ********************************************************************************/ + +#ifndef AIDGE_CORE_OPERATOR_SHIFTGELU_H_ +#define AIDGE_CORE_OPERATOR_SHIFTGELU_H_ + +#include <cassert> +#include <memory> +#include <vector> + +#include "aidge/backend/OperatorImpl.hpp" +#include "aidge/graph/Node.hpp" +#include "aidge/operator/OperatorTensor.hpp" +#include "aidge/utils/ErrorHandling.hpp" +#include "aidge/utils/Registrar.hpp" +#include "aidge/utils/Types.h" + +namespace Aidge { + +class ShiftGELU_Op : public OperatorTensor, + public Registrable<ShiftGELU_Op, std::string, std::shared_ptr<OperatorImpl>(const ShiftGELU_Op&)> { +public: + static const std::string Type; + + ShiftGELU_Op() : OperatorTensor(Type, 1, 0, 1) {} + + /** + * @brief Copy-constructor. Copy the operator attributes and its output tensor(s), but not its input tensors (the new operator has no input associated). + * @param op Operator to copy. + */ + ShiftGELU_Op(const ShiftGELU_Op& op) + : OperatorTensor(op) + { + if (op.mImpl){ + SET_IMPL_MACRO(ShiftGELU_Op, *this, op.backend()); + }else{ + mImpl = nullptr; + } + } + + /** + * @brief Clone the operator using its copy-constructor. + * @see Operator::ShiftGELU_Op + */ + std::shared_ptr<Operator> clone() const override { + return std::make_shared<ShiftGELU_Op>(*this); + } + + + void setBackend(const std::string& name, DeviceIdx_t device = 0) override final; + + static const std::vector<std::string> getInputsName(){ + return {"data_input"}; + } + static const std::vector<std::string> getOutputsName(){ + return {"data_output"}; + } +}; + +inline std::shared_ptr<Node> ShiftGELU(const std::string& name = "") { + return std::make_shared<Node>(std::make_shared<ShiftGELU_Op>(), name); +} +} + +#endif /* AIDGE_CORE_OPERATOR_SHIFTGELU_H_ */ diff --git a/include/aidge/operator/ShiftMax.hpp b/include/aidge/operator/ShiftMax.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bb54d55ba609239e74b40f4ca96b646860e83a3a --- /dev/null +++ b/include/aidge/operator/ShiftMax.hpp @@ -0,0 +1,75 @@ +/******************************************************************************** + * Copyright (c) 2024 Thales + * + * 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 + * Author: Lucas RAKOTOARIVONY, Thales Research & Technology France + * Date: 25.06.2024 + * + ********************************************************************************/ + +#ifndef AIDGE_CORE_OPERATOR_SHIFTMAX_H_ +#define AIDGE_CORE_OPERATOR_SHIFTMAX_H_ + +#include <cassert> +#include <memory> +#include <vector> + +#include "aidge/backend/OperatorImpl.hpp" +#include "aidge/graph/Node.hpp" +#include "aidge/operator/OperatorTensor.hpp" +#include "aidge/utils/ErrorHandling.hpp" +#include "aidge/utils/Registrar.hpp" +#include "aidge/utils/Types.h" + +namespace Aidge { + +class ShiftMax_Op : public OperatorTensor, + public Registrable<ShiftMax_Op, std::string, std::shared_ptr<OperatorImpl>(const ShiftMax_Op&)> { +public: + static const std::string Type; + + ShiftMax_Op() : OperatorTensor(Type, 1, 0, 1) {} + + /** + * @brief Copy-constructor. Copy the operator attributes and its output tensor(s), but not its input tensors (the new operator has no input associated). + * @param op Operator to copy. + */ + ShiftMax_Op(const ShiftMax_Op& op) + : OperatorTensor(op) + { + if (op.mImpl){ + SET_IMPL_MACRO(ShiftMax_Op, *this, op.backend()); + }else{ + mImpl = nullptr; + } + } + + /** + * @brief Clone the operator using its copy-constructor. + * @see Operator::ShiftMax_Op + */ + std::shared_ptr<Operator> clone() const override { + return std::make_shared<ShiftMax_Op>(*this); + } + + + void setBackend(const std::string& name, DeviceIdx_t device = 0) override final; + + static const std::vector<std::string> getInputsName(){ + return {"data_input"}; + } + static const std::vector<std::string> getOutputsName(){ + return {"data_output"}; + } +}; + +inline std::shared_ptr<Node> ShiftMax(const std::string& name = "") { + return std::make_shared<Node>(std::make_shared<ShiftMax_Op>(), name); +} +} + +#endif /* AIDGE_CORE_OPERATOR_SHIFTMAX_H_ */ diff --git a/src/operator/ShiftGELU.cpp b/src/operator/ShiftGELU.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ede83e291bd1670885192e3ac8f4958e185c28e2 --- /dev/null +++ b/src/operator/ShiftGELU.cpp @@ -0,0 +1,27 @@ +/******************************************************************************** + * Copyright (c) 2024 Thales + * + * 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 + * Author: Lucas RAKOTOARIVONY, Thales Research & Technology France + * Date: 25.06.2024 + * + ********************************************************************************/ + +#include "aidge/operator/ShiftGELU.hpp" + +#include <memory> +#include <string> + +#include "aidge/data/Tensor.hpp" +#include "aidge/utils/Types.h" + +const std::string Aidge::ShiftGELU_Op::Type = "ShiftGELU"; + +void Aidge::ShiftGELU_Op::setBackend(const std::string& name, DeviceIdx_t device) { + SET_IMPL_MACRO(ShiftGELU_Op, *this, name); + mOutputs[0]->setBackend(name, device); +} \ No newline at end of file diff --git a/src/operator/ShiftMax.cpp b/src/operator/ShiftMax.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eb77ae655354eac03fbdc0f1a84a44391795ee8c --- /dev/null +++ b/src/operator/ShiftMax.cpp @@ -0,0 +1,27 @@ +/******************************************************************************** + * Copyright (c) 2024 Thales + * + * 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 + * Author: Lucas RAKOTOARIVONY, Thales Research & Technology France + * Date: 25.06.2024 + * + ********************************************************************************/ + +#include "aidge/operator/ShiftMax.hpp" + +#include <memory> +#include <string> + +#include "aidge/data/Tensor.hpp" +#include "aidge/utils/Types.h" + +const std::string Aidge::ShiftMax_Op::Type = "ShiftMax"; + +void Aidge::ShiftMax_Op::setBackend(const std::string& name, DeviceIdx_t device) { + SET_IMPL_MACRO(ShiftMax_Op, *this, name); + mOutputs[0]->setBackend(name, device); +} \ No newline at end of file