diff --git a/include/aidge/data/Tensor.hpp b/include/aidge/data/Tensor.hpp index 7422a52eb171ee6dae0e14ad67c0562295fe5d8c..58c434bccc7c8dd39a93c46ecf74c38d7d834d1a 100644 --- a/include/aidge/data/Tensor.hpp +++ b/include/aidge/data/Tensor.hpp @@ -477,13 +477,14 @@ class Tensor : public Data, if (dims().empty()) { return "{}"; } std::string res; std::size_t dim = 0; - std::size_t *dimVals = new std::size_t[nbDims()]; - for (std::size_t i = 0; i < nbDims(); ++i) { - dimVals[i] = 0; - } std::size_t counter = 0; - res += "{\n"; - if (nbDims()>=2){ + if (nbDims()>=2) { + std::size_t *dimVals = new std::size_t[nbDims()]; + for (std::size_t i = 0; i < nbDims(); ++i) { + dimVals[i] = 0; + } + // std::vector<std::size_t> dimVals = std::vector<std::size_t>(nbDims(), 0); + res += "{\n"; while (counter < mSize) { std::string spaceString = std::string((dim+1)<<1,' '); if (dim < nbDims()-2) { @@ -532,31 +533,35 @@ class Tensor : public Data, } res += "\n"; } + if (dim == 0) { + break; + } dimVals[dim--] = 0; dimVals[dim]++; } } - for(int i = static_cast<int>(dim); i>=0; --i) { + delete[] dimVals; + + for(int i = static_cast<int>(dim); i > 0; --i) { res += std::string((dim+1)<<1,' ') + "}\n"; } - }else{ + } else { + res += "{"; for (DimSize_t j = 0; j < dims()[0]; ++j) { switch (mDataType) { case DataType::Int32: - res += " " + std::to_string(static_cast<int *>(mImpl->rawPtr())[j]) + ((j < dims()[0]-1) ? "," : "\n"); + res += " " + std::to_string(static_cast<int *>(mImpl->rawPtr())[j]) + ((j < dims()[0]-1) ? "," : ""); break; case DataType::Float64: - res += " " + std::to_string(static_cast<double *>(mImpl->rawPtr())[j]) + ((j < dims()[0]-1) ? "," : "\n"); + res += " " + std::to_string(static_cast<double *>(mImpl->rawPtr())[j]) + ((j < dims()[0]-1) ? "," : ""); break; default: - res += " " + std::to_string(static_cast<float *>(mImpl->rawPtr())[j]) + ((j < dims()[0]-1) ? "," : "\n"); + res += " " + std::to_string(static_cast<float *>(mImpl->rawPtr())[j]) + ((j < dims()[0]-1) ? "," : ""); break; } } } - - res += "}"; return res; } diff --git a/include/aidge/operator/Producer.hpp b/include/aidge/operator/Producer.hpp index c263ae139f11503fbc8a7682e53ccf536cbe5e98..d747b340618cc7e321f2cfc2ed9169798e5d77e9 100644 --- a/include/aidge/operator/Producer.hpp +++ b/include/aidge/operator/Producer.hpp @@ -133,7 +133,7 @@ public: inline IOIndex_t nbDataInputs() const noexcept override final { return 0; }; inline IOIndex_t nbOutputs() const noexcept override final { return 1; }; static const std::vector<std::string> getInputsName(){ - return {""}; + return {}; } static const std::vector<std::string> getOutputsName(){ return {"data_output"};