Skip to content

Commit

Permalink
Add test for reserved tensor
Browse files Browse the repository at this point in the history
Reserved tensor now has a proper test, allocating 3 uint32_t.

Signed-off-by: Andrea Calabrese <[email protected]>
  • Loading branch information
ThePseudo committed Aug 7, 2024
1 parent 41a21fa commit 8112ed1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/include/kompute/Tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class Tensor
uint32_t elementMemorySize);

/**
* @brief Reserve memory on the tensor
* Function to reserve memory on the tensor. This does not copy any data, it
* just reserves memory, similarly to std::vector reserve() method.
*
* @param newSize the new size for reservation
*/
Expand Down Expand Up @@ -336,8 +337,7 @@ class TensorT : public Tensor
this->dataType(),
tensorType)
{
KP_LOG_DEBUG("Kompute TensorT constructor with data size {}",
data.size());
KP_LOG_DEBUG("Kompute TensorT constructor with data size {}", size);
}

TensorT(std::shared_ptr<vk::PhysicalDevice> physicalDevice,
Expand Down
8 changes: 8 additions & 0 deletions test/TestTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ TEST(TestTensor, ConstructorData)
EXPECT_EQ(tensor->vector(), vec);
}

TEST(TestTensor, ReserveData)
{
kp::Manager mgr;
std::shared_ptr<kp::TensorT<float>> tensor = mgr.tensor(3, sizeof(uint32_t), Tensor::TensorDataType::eUnsignedInt);
EXPECT_EQ(tensor->size(), 0);
EXPECT_EQ(tensor->dataTypeMemorySize(), sizeof(uint32_t));
}

TEST(TestTensor, DataTypes)
{
kp::Manager mgr;
Expand Down

0 comments on commit 8112ed1

Please sign in to comment.