Skip to content
Snippets Groups Projects
Commit d8d7ca5c authored by Maxence Naud's avatar Maxence Naud
Browse files

[Fix] small fixes

- remove warning on void pointer arithmetic in TensorImpl
- remove unused variable warning in AddImpl
- update cpu Tensor test
parent cd6e9a15
No related branches found
No related tags found
Loading
Pipeline #32235 failed
......@@ -48,7 +48,7 @@ class TensorImpl_cpu : public TensorImpl {
};
void* getRaw(std::size_t idx){
return rawPtr() + (idx * sizeof(T));
return static_cast<void*>(static_cast<T *>(rawPtr()) + idx);
};
virtual ~TensorImpl_cpu() = default;
......
......@@ -99,6 +99,7 @@ Aidge::NbElts_t Aidge::AddImpl_cpu<2>::getNbRequiredProtected(const Aidge::IOInd
Aidge::NbElts_t Aidge::AddImpl_cpu<2>::getRequiredMemory(const Aidge::IOIndex_t outputIdx, const std::vector<Aidge::DimSize_t>& /*inputsSize*/) const {
// Requires the whole tensors, regardless of available data on inputs
assert(outputIdx == 0 && "operator has only one output");
(void) outputIdx; // avoid unused warning
const auto& outputDims = std::static_pointer_cast<Tensor>(mOp.getOutput(0))->dims();
return std::accumulate(outputDims.begin(), outputDims.end(),
......@@ -167,6 +168,7 @@ Aidge::NbElts_t Aidge::AddImpl_cpu<3>::getNbRequiredProtected(const Aidge::IOInd
Aidge::NbElts_t Aidge::AddImpl_cpu<3>::getRequiredMemory(const Aidge::IOIndex_t outputIdx, const std::vector<Aidge::DimSize_t>& /*inputsSize*/) const {
// Requires the whole tensors, regardless of available data on inputs
assert(outputIdx == 0 && "operator has only one output");
(void) outputIdx; // avoid unused warning
const auto& outputDims = std::static_pointer_cast<Tensor>(mOp.getOutput(0))->dims();
return std::accumulate(outputDims.begin(), outputDims.end(),
......
......@@ -41,12 +41,12 @@ TEST_CASE("Tensor creation") {
}
SECTION("get function") {
REQUIRE(x.get<int>(std::array<std::size_t, 3>({0, 0, 0})) == 1);
REQUIRE(x.get<int>(std::array<std::size_t, 3>({0, 0, 1})) == 2);
REQUIRE(x.get<int>(std::array<std::size_t, 3>({0, 1, 1})) == 4);
REQUIRE(x.get<int>(std::array<std::size_t, 3>({1, 1, 0})) == 7);
x.get<int>(std::array<std::size_t, 3>({1, 1, 1})) = 36;
REQUIRE(x.get<int>(std::array<std::size_t, 3>({1, 1, 1})) == 36);
REQUIRE(x.get<int>({0, 0, 0}) == 1);
REQUIRE(x.get<int>({0, 0, 1}) == 2);
REQUIRE(x.get<int>({0, 1, 1}) == 4);
REQUIRE(x.get<int>({1, 1, 0}) == 7);
x.get<int>({1, 1, 1}) = 36;
REQUIRE(x.get<int>({1, 1, 1}) == 36);
}
SECTION("Pretty printing for debug") { REQUIRE_NOTHROW(x.print()); }
......
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