From ef539ba723834116f8e68099b68d1a2184f74bd4 Mon Sep 17 00:00:00 2001
From: thibault allenet <thibault.allenet@cea.fr>
Date: Wed, 6 Dec 2023 10:29:18 +0000
Subject: [PATCH] Add tensor constructor from dimensions

---
 include/aidge/data/Tensor.hpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/aidge/data/Tensor.hpp b/include/aidge/data/Tensor.hpp
index 58c434bcc..dca5fe7eb 100644
--- a/include/aidge/data/Tensor.hpp
+++ b/include/aidge/data/Tensor.hpp
@@ -164,6 +164,20 @@ class Tensor : public Data,
     {
         // ctor
     }
+    
+    /**
+     * @brief Construct a new Tensor object from dimensions.
+     * 
+     * @param dims dimensions of the tensor
+     * @param dataType datatype of the tensor (default = DataType::Float32)
+     */
+    Tensor(std::vector<DimSize_t> dims, DataType dataType = DataType::Float32)
+        : Data(Type),
+          mDataType(dataType),
+          mDims(dims)
+    {
+        computeSize();
+    }
 
     /**
      * @brief Construct a new Tensor object copied from another one.
-- 
GitLab