From 7edea134cd48244a1bf779e09408853eaf155fb1 Mon Sep 17 00:00:00 2001 From: hrouis <houssemeddine.rouis92@gmail.com> Date: Mon, 10 Mar 2025 17:43:14 +0100 Subject: [PATCH 1/2] override setDataType for Cast_op --- include/aidge/operator/Cast.hpp | 7 +++++++ src/operator/Cast.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/include/aidge/operator/Cast.hpp b/include/aidge/operator/Cast.hpp index fd05c96a2..cd37e47d8 100644 --- a/include/aidge/operator/Cast.hpp +++ b/include/aidge/operator/Cast.hpp @@ -123,6 +123,13 @@ public: */ inline DataType& targetType() const { return mAttributes->template getAttr<CastAttr::TargetType>(); } + /** + * @brief Sets the data type of the operator's tensors. + * @details This method needs to be overwritten because Cast_Op's output type needs to be set from targetType + * @param dataType Data type to set. + */ + virtual void setDataType(const DataType& dataType) const override; + /** * @brief Get the input tensor names for the Cast operator. * @return A vector containing the input tensor names. diff --git a/src/operator/Cast.cpp b/src/operator/Cast.cpp index 3c2293958..d93037721 100644 --- a/src/operator/Cast.cpp +++ b/src/operator/Cast.cpp @@ -49,6 +49,11 @@ Cast_Op::Cast_Op(const Cast_Op& op) } } +void Aidge::Cast_Op::setDataType(const DataType& dataType) const { + if (targetType() != dataType) { + Log::warn("Cannot force output dataType for Cast operator!"); + } +} void Cast_Op::setBackend(const std::string& name, DeviceIdx_t device) { if (Registrar<Cast_Op>::exists({name})) { -- GitLab From e5cafb54d66e239fca0233c0e79cb509bd718e81 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Tue, 25 Mar 2025 10:56:56 +0000 Subject: [PATCH 2/2] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Cyril Moineau <cyril.moineau@cea.fr> --- src/operator/Cast.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/operator/Cast.cpp b/src/operator/Cast.cpp index d93037721..128868dcd 100644 --- a/src/operator/Cast.cpp +++ b/src/operator/Cast.cpp @@ -51,7 +51,7 @@ Cast_Op::Cast_Op(const Cast_Op& op) void Aidge::Cast_Op::setDataType(const DataType& dataType) const { if (targetType() != dataType) { - Log::warn("Cannot force output dataType for Cast operator!"); + Log::warn("Cast::setDataType(): Cannot setDataType for cast operator."); } } -- GitLab