Skip to content
Snippets Groups Projects
Commit 108727b7 authored by Cyril Moineau's avatar Cyril Moineau Committed by Maxence Naud
Browse files

Update every binded operator to be registrable.

parent 299e7a40
No related branches found
No related tags found
2 merge requests!105version 0.2.0,!85Initial working python registrar.
Showing
with 46 additions and 45 deletions
......@@ -28,7 +28,7 @@
namespace Aidge {
class Add_Op : public OperatorTensor,
public Registrable<Add_Op, std::string, std::unique_ptr<OperatorImpl>(const Add_Op&)> {
public Registrable<Add_Op, std::string, std::shared_ptr<OperatorImpl>(const Add_Op&)> {
public:
static const std::string Type;
......@@ -71,7 +71,7 @@ public:
void computeOutputDims() override final;
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Add_Op>::create(name)(*this);
SET_IMPL_MACRO(Add_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -30,7 +30,7 @@ enum class AvgPoolingAttr { StrideDims, KernelDims };
template <DimIdx_t DIM>
class AvgPooling_Op : public OperatorTensor,
public Registrable<AvgPooling_Op<DIM>, std::string, std::unique_ptr<OperatorImpl>(const AvgPooling_Op<DIM> &)>,
public Registrable<AvgPooling_Op<DIM>, std::string, std::shared_ptr<OperatorImpl>(const AvgPooling_Op<DIM> &)>,
public StaticAttributes<AvgPoolingAttr,
std::array<DimSize_t, DIM>,
std::array<DimSize_t, DIM>> {
......@@ -137,7 +137,7 @@ public:
void setBackend(const std::string &name, DeviceIdx_t device = 0) override {
mImpl = Registrar<AvgPooling_Op<DIM>>::create(name)(*this);
SET_IMPL_MACRO(AvgPooling_Op<DIM>, *this, name);
mOutputs[0]->setBackend(name, device);
}
......@@ -177,4 +177,4 @@ const char *const EnumStrings<Aidge::AvgPoolingAttr>::data[] = {"StrideDims",
"KernelDims"};
}
#endif /* AIDGE_CORE_OPERATOR_AVGPOOLING_H_ */
\ No newline at end of file
#endif /* AIDGE_CORE_OPERATOR_AVGPOOLING_H_ */
......@@ -30,7 +30,7 @@ enum class BatchNormAttr { Epsilon, Momentum };
template <DimIdx_t DIM>
class BatchNorm_Op : public OperatorTensor,
public Registrable<BatchNorm_Op<DIM>, std::string, std::unique_ptr<OperatorImpl>(const BatchNorm_Op<DIM> &)>,
public Registrable<BatchNorm_Op<DIM>, std::string, std::shared_ptr<OperatorImpl>(const BatchNorm_Op<DIM> &)>,
public StaticAttributes<BatchNormAttr, float, float> {
public:
static const std::string Type;
......@@ -95,7 +95,7 @@ public:
}
void setBackend(const std::string &name, DeviceIdx_t device = 0) override {
mImpl = Registrar<BatchNorm_Op<DIM>>::create(name)(*this);
SET_IMPL_MACRO(BatchNorm_Op<DIM>, *this, name);
mOutputs[0]->setBackend(name, device);
// By default, automatically set backend for scale, shift, mean and variance
......@@ -136,4 +136,4 @@ template <>
const char *const EnumStrings<Aidge::BatchNormAttr>::data[] = { "Epsilon", "Momentum" };
}
#endif //AIDGE_CORE_OPERATOR_BATCHNORM_H_
\ No newline at end of file
#endif //AIDGE_CORE_OPERATOR_BATCHNORM_H_
......@@ -29,7 +29,7 @@ namespace Aidge {
enum class ConcatAttr { Axis };
class Concat_Op : public OperatorTensor,
public Registrable<Concat_Op, std::string, std::unique_ptr<OperatorImpl>(const Concat_Op&)>,
public Registrable<Concat_Op, std::string, std::shared_ptr<OperatorImpl>(const Concat_Op&)>,
public StaticAttributes<ConcatAttr, DimSize_t> {
public:
static const std::string Type;
......@@ -108,7 +108,7 @@ public:
}
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Concat_Op>::create(name)(*this);
SET_IMPL_MACRO(Concat_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -30,7 +30,7 @@ enum class ConvDepthWiseAttr { StrideDims, DilationDims, Channels, KernelDims };
template <DimIdx_t DIM>
class ConvDepthWise_Op : public OperatorTensor,
public Registrable<ConvDepthWise_Op<DIM>, std::string, std::unique_ptr<OperatorImpl>(const ConvDepthWise_Op<DIM> &)>,
public Registrable<ConvDepthWise_Op<DIM>, std::string, std::shared_ptr<OperatorImpl>(const ConvDepthWise_Op<DIM> &)>,
public StaticAttributes<ConvDepthWiseAttr,
std::array<DimSize_t, DIM>,
std::array<DimSize_t, DIM>,
......@@ -168,7 +168,7 @@ public:
}
void setBackend(const std::string &name, DeviceIdx_t device = 0) override {
mImpl = Registrar<ConvDepthWise_Op<DIM>>::create(name)(*this);
SET_IMPL_MACRO(ConvDepthWise_Op<DIM>, *this, name);
mOutputs[0]->setBackend(name, device);
// By default, automatically set backend for weight and bias inputs
......
......@@ -26,7 +26,7 @@
namespace Aidge {
class Div_Op : public OperatorTensor,
public Registrable<Div_Op, std::string, std::unique_ptr<OperatorImpl>(const Div_Op&)> {
public Registrable<Div_Op, std::string, std::shared_ptr<OperatorImpl>(const Div_Op&)> {
public:
static const std::string Type;
......@@ -55,7 +55,7 @@ public:
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Div_Op>::create(name)(*this);
SET_IMPL_MACRO(Div_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -27,7 +27,7 @@
namespace Aidge {
class Erf_Op : public OperatorTensor,
public Registrable<Erf_Op, std::string, std::unique_ptr<OperatorImpl>(const Erf_Op&)> {
public Registrable<Erf_Op, std::string, std::shared_ptr<OperatorImpl>(const Erf_Op&)> {
public:
static const std::string Type;
......@@ -52,7 +52,7 @@ public:
}
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Erf_Op>::create(name)(*this);
SET_IMPL_MACRO(Erf_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -32,7 +32,7 @@ enum class FCAttr { OutChannels, NoBias };
class FC_Op : public OperatorTensor,
public Registrable<FC_Op,
std::string,
std::unique_ptr<OperatorImpl>(const FC_Op &)>,
std::shared_ptr<OperatorImpl>(const FC_Op &)>,
public StaticAttributes<FCAttr, DimSize_t, bool> {
public:
static const std::string Type;
......@@ -97,7 +97,7 @@ public:
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<FC_Op>::create(name)(*this);
SET_IMPL_MACRO(FC_Op, *this, name);
mOutputs[0]->setBackend(name, device);
// By default, automatically set backend for weight and bias inputs
......@@ -128,4 +128,4 @@ const char *const EnumStrings<Aidge::FCAttr>::data[] = {"OutChannels",
"NoBias"};
}
#endif /* AIDGE_CORE_OPERATOR_FC_H_ */
\ No newline at end of file
#endif /* AIDGE_CORE_OPERATOR_FC_H_ */
......@@ -32,7 +32,7 @@ enum class GatherAttr { Indices, GatheredShape, Axis };
class Gather_Op : public OperatorTensor,
public Registrable<Gather_Op,
std::string,
std::unique_ptr<OperatorImpl>(const Gather_Op&)>,
std::shared_ptr<OperatorImpl>(const Gather_Op&)>,
public StaticAttributes<GatherAttr, std::vector<std::int64_t>, std::vector<DimSize_t>, std::int64_t> {
public:
......@@ -72,7 +72,7 @@ public:
void computeOutputDims() override final;
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Gather_Op>::create(name)(*this);
SET_IMPL_MACRO(Gather_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -30,7 +30,7 @@ enum class LeakyReLUAttr {
};
class LeakyReLU_Op : public OperatorTensor,
public Registrable<LeakyReLU_Op, std::string, std::unique_ptr<OperatorImpl>(const LeakyReLU_Op&)>,
public Registrable<LeakyReLU_Op, std::string, std::shared_ptr<OperatorImpl>(const LeakyReLU_Op&)>,
public StaticAttributes<LeakyReLUAttr, float> {
public:
static const std::string Type;
......@@ -69,6 +69,7 @@ public:
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<LeakyReLU_Op>::create(name)(*this);
SET_IMPL_MACRO(LeakyReLU_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -27,7 +27,7 @@ namespace Aidge {
class MatMul_Op : public OperatorTensor,
public Registrable<MatMul_Op,
std::string,
std::unique_ptr<OperatorImpl>(const MatMul_Op &)> {
std::shared_ptr<OperatorImpl>(const MatMul_Op &)> {
public:
static const std::string Type;
......@@ -65,7 +65,7 @@ public:
void setBackend(const std::string& name, DeviceIdx_t device = 0) override final {
mImpl = Registrar<MatMul_Op>::create(name)(*this);
SET_IMPL_MACRO(MatMul_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -30,7 +30,7 @@ enum class MaxPoolingAttr { StrideDims, KernelDims, CeilMode };
template <DimIdx_t DIM>
class MaxPooling_Op : public OperatorTensor,
public Registrable<MaxPooling_Op<DIM>, std::string, std::unique_ptr<OperatorImpl>(const MaxPooling_Op<DIM> &)>,
public Registrable<MaxPooling_Op<DIM>, std::string, std::shared_ptr<OperatorImpl>(const MaxPooling_Op<DIM> &)>,
public StaticAttributes<MaxPoolingAttr,
std::array<DimSize_t, DIM>,
std::array<DimSize_t, DIM>,
......@@ -105,7 +105,7 @@ public:
void setBackend(const std::string &name, DeviceIdx_t device = 0) override {
mImpl = Registrar<MaxPooling_Op<DIM>>::create(name)(*this);
SET_IMPL_MACRO(MaxPooling_Op<DIM>, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -29,7 +29,7 @@ namespace Aidge {
* @brief Tensor element-wise multiplication.
*/
class Mul_Op : public OperatorTensor,
public Registrable<Mul_Op, std::string, std::unique_ptr<OperatorImpl>(const Mul_Op&)> {
public Registrable<Mul_Op, std::string, std::shared_ptr<OperatorImpl>(const Mul_Op&)> {
public:
static const std::string Type;
......@@ -57,7 +57,7 @@ public:
void computeOutputDims() override final;
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Mul_Op>::create(name)(*this);
SET_IMPL_MACRO(Mul_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......@@ -74,4 +74,4 @@ inline std::shared_ptr<Node> Mul(const std::string& name = "") {
}
} // namespace Aidge
#endif /* AIDGE_CORE_OPERATOR_MUL_H_ */
\ No newline at end of file
#endif /* AIDGE_CORE_OPERATOR_MUL_H_ */
......@@ -31,7 +31,7 @@ enum class PadBorderType { Constant, Edge, Reflect, Wrap };
template <DimIdx_t DIM>
class Pad_Op : public OperatorTensor,
public Registrable<Pad_Op<DIM>, std::string, std::unique_ptr<OperatorImpl>(const Pad_Op<DIM> &)>,
public Registrable<Pad_Op<DIM>, std::string, std::shared_ptr<OperatorImpl>(const Pad_Op<DIM> &)>,
public StaticAttributes<PadAttr,
std::array<DimSize_t, 2*DIM>,
PadBorderType,
......@@ -98,7 +98,7 @@ public:
}
void setBackend(const std::string &name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Pad_Op<DIM>>::create(name)(*this);
SET_IMPL_MACRO(Pad_Op<DIM>, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -27,7 +27,7 @@
namespace Aidge {
class Pow_Op : public OperatorTensor,
public Registrable<Pow_Op, std::string, std::unique_ptr<OperatorImpl>(const Pow_Op&)> {
public Registrable<Pow_Op, std::string, std::shared_ptr<OperatorImpl>(const Pow_Op&)> {
public:
static const std::string Type;
......@@ -55,7 +55,7 @@ public:
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Pow_Op>::create(name)(*this);
SET_IMPL_MACRO(Pow_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......@@ -72,4 +72,4 @@ inline std::shared_ptr<Node> Pow(const std::string& name = "") {
}
} // namespace Aidge
#endif /* AIDGE_CORE_OPERATOR_POW_H_ */
\ No newline at end of file
#endif /* AIDGE_CORE_OPERATOR_POW_H_ */
......@@ -26,7 +26,7 @@
namespace Aidge {
class ReLU_Op : public OperatorTensor,
public Registrable<ReLU_Op, std::string, std::unique_ptr<OperatorImpl>(const ReLU_Op&)> {
public Registrable<ReLU_Op, std::string, std::shared_ptr<OperatorImpl>(const ReLU_Op&)> {
public:
static const std::string Type;
......@@ -52,7 +52,7 @@ public:
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<ReLU_Op>::create(name)(*this);
SET_IMPL_MACRO(ReLU_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......@@ -69,4 +69,4 @@ inline std::shared_ptr<Node> ReLU(const std::string& name = "") {
}
}
#endif /* AIDGE_CORE_OPERATOR_RELU_H_ */
\ No newline at end of file
#endif /* AIDGE_CORE_OPERATOR_RELU_H_ */
......@@ -32,7 +32,7 @@ enum class ReduceMeanAttr { Axes, KeepDims };
template <DimIdx_t DIM>
class ReduceMean_Op : public OperatorTensor,
public Registrable<ReduceMean_Op<DIM>, std::string, std::unique_ptr<OperatorImpl>(const ReduceMean_Op<DIM> &)>,
public Registrable<ReduceMean_Op<DIM>, std::string, std::shared_ptr<OperatorImpl>(const ReduceMean_Op<DIM> &)>,
public StaticAttributes<ReduceMeanAttr, std::array<std::int32_t, DIM>, DimSize_t> {
public:
......@@ -99,7 +99,7 @@ class ReduceMean_Op : public OperatorTensor,
}
void setBackend(const std::string &name, DeviceIdx_t device = 0) override {
mImpl = Registrar<ReduceMean_Op<DIM>>::create(name)(*this);
SET_IMPL_MACRO(ReduceMean_Op<DIM>, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -28,7 +28,7 @@ namespace Aidge {
enum class ReshapeAttr { Shape };
class Reshape_Op : public OperatorTensor,
public Registrable<Reshape_Op, std::string, std::unique_ptr<OperatorImpl>(const Reshape_Op&)>,
public Registrable<Reshape_Op, std::string, std::shared_ptr<OperatorImpl>(const Reshape_Op&)>,
public StaticAttributes<ReshapeAttr, std::vector<std::int64_t>> {
public:
......@@ -67,7 +67,7 @@ public:
void computeOutputDims() override final;
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Reshape_Op>::create(name)(*this);
SET_IMPL_MACRO(Reshape_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -28,7 +28,7 @@ enum class SliceAttr { Starts, Ends, Axes };
class Slice_Op
: public OperatorTensor,
public Registrable<Slice_Op, std::string, std::unique_ptr<OperatorImpl>(const Slice_Op &)>,
public Registrable<Slice_Op, std::string, std::shared_ptr<OperatorImpl>(const Slice_Op &)>,
public StaticAttributes<SliceAttr, std::vector<std::int64_t>, std::vector<std::int64_t>, std::vector<std::int64_t>> {
public:
static const std::string Type;
......@@ -69,7 +69,7 @@ public:
void computeOutputDims() override final;
void setBackend(const std::string &name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Slice_Op>::create(name)(*this);
SET_IMPL_MACRO(Slice_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
......@@ -33,7 +33,7 @@ enum class SoftmaxAttr { AxisIdx };
class Softmax_Op : public OperatorTensor,
public Registrable<Softmax_Op,
std::string,
std::unique_ptr<OperatorImpl>(const Softmax_Op&)>,
std::shared_ptr<OperatorImpl>(const Softmax_Op&)>,
public StaticAttributes<SoftmaxAttr, int> {
public:
......@@ -67,7 +67,7 @@ public:
}
void setBackend(const std::string& name, DeviceIdx_t device = 0) override {
mImpl = Registrar<Softmax_Op>::create(name)(*this);
SET_IMPL_MACRO(Softmax_Op, *this, name);
mOutputs[0]->setBackend(name, device);
}
......
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