Skip to content

Commit

Permalink
Merge branch 'master' into images_only
Browse files Browse the repository at this point in the history
  • Loading branch information
robquill committed Aug 22, 2024
2 parents 98c27bd + fdf4098 commit 1bfc6d5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/Manager.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-License-Identifier: Apache-2.0

#include "kompute/Manager.hpp"
#include "fmt/format.h"
#include "kompute/logger/Logger.hpp"
#include <fmt/core.h>
#include <fmt/ranges.h>
#include <iterator>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>

namespace kp {

Expand Down
3 changes: 0 additions & 3 deletions src/include/kompute/Manager.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include <set>
#include <unordered_map>

#include "kompute/Core.hpp"

#include "kompute/Image.hpp"
Expand Down
2 changes: 1 addition & 1 deletion test/TestImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TEST(TestImage, ConstructorData)
EXPECT_EQ(image->vector(), vec);
}

TEST(TestImage, ConstructorNoData)
TEST(TestImage, ReserveData)
{
kp::Manager mgr;

Expand Down
38 changes: 27 additions & 11 deletions test/TestTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
#include "kompute/Kompute.hpp"
#include "kompute/logger/Logger.hpp"

// Introducing custom struct that can be used for tensors
struct TensorTestStruct
{
float x;
uint32_t y;
int32_t z;

// Creating an == operator overload for the comparison below
bool operator==(const TensorTestStruct rhs) const
{
return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z;
}
};
// Custom struct needs to be mapped the eCustom datatype
template<>
kp::Memory::DataTypes
kp::TensorT<TensorTestStruct>::dataType()
{
return kp::Memory::DataTypes::eCustom;
}

TEST(TestTensor, ConstructorData)
{
kp::Manager mgr;
Expand All @@ -15,11 +36,11 @@ TEST(TestTensor, ConstructorData)
EXPECT_EQ(tensor->vector(), vec);
}

TEST(TestTensor, ConstructorNoData)
TEST(TestTensor, ReserveData)
{
kp::Manager mgr;
std::shared_ptr<kp::Tensor> tensor =
mgr.tensor(nullptr, 3, sizeof(float), kp::Memory::DataTypes::eFloat);
std::shared_ptr<kp::Tensor> tensor = mgr.tensor(
nullptr, 3, sizeof(float), kp::Memory::DataTypes::eFloat);
EXPECT_EQ(tensor->size(), 3);
EXPECT_EQ(tensor->dataTypeMemorySize(), sizeof(float));

Expand All @@ -31,15 +52,10 @@ TEST(TestTensor, ConstructorNoData)
std::shared_ptr<kp::TensorT<float>> tensor3 = mgr.tensorT<float>(3);
EXPECT_EQ(tensor3->size(), 3);
EXPECT_EQ(tensor3->dataTypeMemorySize(), sizeof(float));
}

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

TEST(TestTensor, DataTypes)
Expand Down

0 comments on commit 1bfc6d5

Please sign in to comment.