Skip to content
Snippets Groups Projects
Commit c557230f authored by Lucas RAKOTOARIVONY's avatar Lucas RAKOTOARIVONY
Browse files

Add operator ShiftMax and ShiftGELU

parent 928cb238
No related branches found
No related tags found
2 merge requests!146Thales Contribution,!125Operator resize
/********************************************************************************
* 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_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_ */
/********************************************************************************
* 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_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_ */
/********************************************************************************
* 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 "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
/********************************************************************************
* 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 "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
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