Removed print statement in tests
This commit is contained in:
parent
07bfbe3504
commit
0410ae0db6
7 changed files with 73 additions and 99 deletions
|
|
@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
|
|||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "{CMAKE_CXX_FLAGS_RELEASE} -DRELEASE=1")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE=1")
|
||||
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
|
|
|||
16
Makefile
16
Makefile
|
|
@ -40,10 +40,12 @@ clean_cmake:
|
|||
|
||||
####### Visual studio build shortcut commands #######
|
||||
|
||||
MK_BUILD_TYPE ?= "Release"
|
||||
|
||||
mk_cmake:
|
||||
cmake \
|
||||
-Bbuild \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_BUILD_TYPE=$(MK_BUILD_TYPE) \
|
||||
-DKOMPUTE_OPT_BUILD_DOCS=0 \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$(VCPKG_UNIX_PATH) \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
|
||||
|
|
@ -70,6 +72,8 @@ mk_run_tests: mk_build_tests
|
|||
|
||||
####### Visual studio build shortcut commands #######
|
||||
|
||||
VS_BUILD_TYPE ?= "Debug"
|
||||
|
||||
vs_cmake:
|
||||
$(CMAKE_BIN) \
|
||||
-Bbuild \
|
||||
|
|
@ -79,22 +83,22 @@ vs_cmake:
|
|||
-G "Visual Studio 16 2019"
|
||||
|
||||
vs_build_all:
|
||||
$(MSBUILD_BIN) build/kompute.sln
|
||||
$(MSBUILD_BIN) build/kompute.sln -p:Configuration$(VS_BUILD_TYPE)
|
||||
|
||||
vs_build_docs:
|
||||
$(MSBUILD_BIN) build/docs/gendocsall.vcxproj
|
||||
$(MSBUILD_BIN) build/docs/gendocsall.vcxproj -p:Configuration=$(VS_BUILD_TYPE)
|
||||
|
||||
vs_build_kompute:
|
||||
$(MSBUILD_BIN) build/src/kompute.vcxproj
|
||||
$(MSBUILD_BIN) build/src/kompute.vcxproj -p:Configuration=$(VS_BUILD_TYPE)
|
||||
|
||||
vs_build_tests:
|
||||
$(MSBUILD_BIN) build/test/test_kompute.vcxproj
|
||||
$(MSBUILD_BIN) build/test/test_kompute.vcxproj -p:Configuration=$(VS_BUILD_TYPE)
|
||||
|
||||
vs_run_docs: vs_build_docs
|
||||
(cd build/docs/sphinx && python2.7 -m SimpleHTTPServer)
|
||||
|
||||
vs_run_tests: vs_build_tests
|
||||
./build/test/Debug/test_kompute.exe $(FILTER_TESTS)
|
||||
./build/test/$(VS_BUILD_TYPE)/test_kompute.exe $(FILTER_TESTS)
|
||||
|
||||
####### Create release ######
|
||||
|
||||
|
|
|
|||
18
README.md
18
README.md
|
|
@ -257,6 +257,24 @@ To update the documentation will need to:
|
|||
* Run the gensphynx target in the buildsystem
|
||||
* Push to github pages with `make push_docs_to_ghpages`
|
||||
|
||||
##### Running tests
|
||||
|
||||
To run tests you can use the helper top level Makefile
|
||||
|
||||
For visual studio you can run
|
||||
|
||||
```
|
||||
make vs_cmake
|
||||
make vs_run_tests VS_BUILD_TYPE="Release"
|
||||
```
|
||||
|
||||
For unix you can run
|
||||
|
||||
```
|
||||
make mk_cmake MK_BUILD_TYPE="Release"
|
||||
make mk_run_tests
|
||||
```
|
||||
|
||||
|
||||
# The Komputer is waiting for instructions...
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ layout (constant_id = 0) const uint LEN_LHS = 0;
|
|||
layout (constant_id = 1) const uint LEN_RHS = 0;
|
||||
layout (constant_id = 2) const uint LEN_OUT = 0;
|
||||
|
||||
// TODO: Explore how to make layout inside shader dynamic
|
||||
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
void main()
|
||||
|
|
|
|||
|
|
@ -231,9 +231,18 @@ class Tensor
|
|||
* important to ensure that there is no out-of-sync data with the GPU
|
||||
* memory.
|
||||
*
|
||||
* @return Vector of elements representing the data in the tensor.
|
||||
* @return Reference to vector of elements representing the data in the tensor.
|
||||
*/
|
||||
std::vector<float> data();
|
||||
std::vector<float>& data();
|
||||
/**
|
||||
* Overrides the subscript operator to expose the underlying data's
|
||||
* subscript operator which in this case would be its underlying
|
||||
* vector's.
|
||||
*
|
||||
* @param i The index where the element will be returned from.
|
||||
* @return Returns the element in the position requested.
|
||||
*/
|
||||
float& operator[] (int index);
|
||||
/**
|
||||
* Returns the size/magnitude of the Tensor, which will be the total number
|
||||
* of elements across all dimensions
|
||||
|
|
@ -794,7 +803,6 @@ class Algorithm
|
|||
bool mFreeDescriptorSetLayout = false;
|
||||
std::shared_ptr<vk::DescriptorPool> mDescriptorPool;
|
||||
bool mFreeDescriptorPool = false;
|
||||
// TODO: Explore design for multiple descriptor sets
|
||||
std::shared_ptr<vk::DescriptorSet> mDescriptorSet;
|
||||
bool mFreeDescriptorSet = false;
|
||||
std::shared_ptr<vk::ShaderModule> mShaderModule;
|
||||
|
|
@ -987,8 +995,6 @@ OpAlgoBase<tX, tY, tZ>::OpAlgoBase(std::shared_ptr<vk::PhysicalDevice> physicalD
|
|||
this->mY = tY > 0 ? tY : 1;
|
||||
this->mZ = tZ > 0 ? tZ : 1;
|
||||
} else {
|
||||
// TODO: If tensor empty vector exception would be thrown
|
||||
// TODO: Fully support the full size dispatch using size for the shape
|
||||
this->mX = tensors[0]->size();
|
||||
this->mY = 1;
|
||||
this->mZ = 1;
|
||||
|
|
@ -1298,7 +1304,6 @@ OpAlgoLhsRhsOut<tX, tY, tZ>::init()
|
|||
this->mTensorRHS = this->mTensors[1];
|
||||
this->mTensorOutput = this->mTensors[2];
|
||||
|
||||
// TODO: Explore adding a validate function
|
||||
if (!(this->mTensorLHS->isInit() && this->mTensorRHS->isInit() &&
|
||||
this->mTensorOutput->isInit())) {
|
||||
throw std::runtime_error(
|
||||
|
|
@ -1308,8 +1313,6 @@ OpAlgoLhsRhsOut<tX, tY, tZ>::init()
|
|||
" Output: " + std::to_string(this->mTensorOutput->isInit()));
|
||||
}
|
||||
|
||||
// TODO: Explore use-cases where tensors shouldn't be the same size, and how
|
||||
// to deal with those situations
|
||||
if (!(this->mTensorLHS->size() == this->mTensorRHS->size() &&
|
||||
this->mTensorRHS->size() == this->mTensorOutput->size())) {
|
||||
throw std::runtime_error(
|
||||
|
|
|
|||
|
|
@ -42,35 +42,30 @@ TEST_CASE("test_logistic_regression") {
|
|||
sq->end();
|
||||
sq->eval();
|
||||
|
||||
// Record op algo base
|
||||
sq->begin();
|
||||
|
||||
sq->record<kp::OpAlgoBase<>>(
|
||||
params,
|
||||
true, // Whether to copy output from device
|
||||
"test/shaders/glsl/test_logistic_regression.comp");
|
||||
|
||||
sq->end();
|
||||
|
||||
// Iterate across all expected iterations
|
||||
for (size_t i = 0; i < ITERATIONS; i++) {
|
||||
sq->begin();
|
||||
|
||||
sq->record<kp::OpAlgoBase<>>(
|
||||
params,
|
||||
true, // Whether to copy output from device
|
||||
"test/shaders/glsl/test_logistic_regression.comp");
|
||||
|
||||
sq->end();
|
||||
|
||||
sq->eval();
|
||||
|
||||
// TODO: Reference of data instead of full value copy every time
|
||||
for(size_t j = 0; j < bOut->size(); j++) {
|
||||
wInVec[0] -= wOutI->data()[j];
|
||||
wInVec[1] -= wOutJ->data()[j];
|
||||
bInVec[0] -= bOut->data()[j];
|
||||
wIn->data()[0] -= wOutI->data()[j];
|
||||
wIn->data()[1] -= wOutJ->data()[j];
|
||||
bIn->data()[0] -= bOut->data()[j];
|
||||
}
|
||||
wIn->setData(wInVec);
|
||||
bIn->setData(bInVec);
|
||||
|
||||
wIn->mapDataIntoHostMemory();
|
||||
bIn->mapDataIntoHostMemory();
|
||||
}
|
||||
}
|
||||
|
||||
wIn->mapDataFromHostMemory();
|
||||
bIn->mapDataFromHostMemory();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,60 +5,43 @@
|
|||
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
TEST_CASE("End to end OpMult Flow should execute correctly from manager") {
|
||||
spdlog::info("TEST CASE STARTING");
|
||||
TEST_CASE("End to end OpMult Flow should execute correctly from manager")
|
||||
{
|
||||
kp::Manager mgr;
|
||||
|
||||
spdlog::info("Creating manager");
|
||||
{
|
||||
kp::Manager mgr;
|
||||
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor({ 0, 1, 2 }) };
|
||||
mgr.evalOp<kp::OpCreateTensor>({ tensorLHS });
|
||||
|
||||
spdlog::info("Creating first tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor({ 0, 1, 2 }) };
|
||||
mgr.evalOp<kp::OpCreateTensor>({ tensorLHS });
|
||||
std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor(
|
||||
{ 2, 4, 6 }) };
|
||||
mgr.evalOp<kp::OpCreateTensor>({ tensorRHS });
|
||||
|
||||
spdlog::info("Creating second tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor(
|
||||
{ 2, 4, 6 }) };
|
||||
mgr.evalOp<kp::OpCreateTensor>({ tensorRHS });
|
||||
std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor(
|
||||
{ 0, 0, 0 }) };
|
||||
mgr.evalOp<kp::OpCreateTensor>({ tensorOutput });
|
||||
|
||||
// TODO: Add capabilities for just output tensor types
|
||||
spdlog::info("Creating output tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor(
|
||||
{ 0, 0, 0 }) };
|
||||
mgr.evalOp<kp::OpCreateTensor>({ tensorOutput });
|
||||
spdlog::info("OpCreateTensor success for tensors");
|
||||
spdlog::info("Tensor one: {}", tensorLHS->data());
|
||||
spdlog::info("Tensor two: {}", tensorRHS->data());
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
|
||||
spdlog::info("OpCreateTensor success for tensors");
|
||||
spdlog::info("Tensor one: {}", tensorLHS->data());
|
||||
spdlog::info("Tensor two: {}", tensorRHS->data());
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
spdlog::info("Calling op mult");
|
||||
mgr.evalOp<kp::OpMult<>>({ tensorLHS, tensorRHS, tensorOutput });
|
||||
|
||||
spdlog::info("Calling op mult");
|
||||
mgr.evalOp<kp::OpMult<>>({ tensorLHS, tensorRHS, tensorOutput });
|
||||
spdlog::info("OpMult call success");
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
|
||||
spdlog::info("OpMult call success");
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
|
||||
REQUIRE(tensorOutput->data() == std::vector<float>{0, 4, 12});
|
||||
}
|
||||
|
||||
spdlog::info("Called manager eval success END PROGRAM");
|
||||
REQUIRE(tensorOutput->data() == std::vector<float>{0, 4, 12});
|
||||
}
|
||||
|
||||
TEST_CASE("End to end OpMult Flow should execute correctly from sequence") {
|
||||
spdlog::info("TEST CASE STARTING");
|
||||
|
||||
spdlog::info("Creating manager");
|
||||
|
||||
spdlog::info("Creating first tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor(
|
||||
{ 0, 1, 2 }) };
|
||||
|
||||
spdlog::info("Creating second tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor(
|
||||
{ 2, 4, 6 }) };
|
||||
|
||||
// TODO: Add capabilities for just output tensor types
|
||||
spdlog::info("Creating output tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor(
|
||||
{ 0, 0, 0 }) };
|
||||
|
||||
|
|
@ -72,12 +55,6 @@ TEST_CASE("End to end OpMult Flow should execute correctly from sequence") {
|
|||
sq->record<kp::OpCreateTensor>({ tensorRHS });
|
||||
sq->record<kp::OpCreateTensor>({ tensorOutput });
|
||||
|
||||
spdlog::info("OpCreateTensor success for tensors");
|
||||
spdlog::info("Tensor one: {}", tensorLHS->data());
|
||||
spdlog::info("Tensor two: {}", tensorRHS->data());
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
|
||||
spdlog::info("Calling op mult");
|
||||
sq->record<kp::OpMult<>>({ tensorLHS, tensorRHS, tensorOutput });
|
||||
|
||||
sq->end();
|
||||
|
|
@ -85,12 +62,7 @@ TEST_CASE("End to end OpMult Flow should execute correctly from sequence") {
|
|||
}
|
||||
sqWeakPtr.reset();
|
||||
|
||||
spdlog::info("OpMult call success");
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
|
||||
REQUIRE(tensorOutput->data() == std::vector<float>{0, 4, 12});
|
||||
|
||||
spdlog::info("Called manager eval success END PROGRAM");
|
||||
}
|
||||
|
||||
TEST_CASE("Test manager get create functionality for sequences") {
|
||||
|
|
@ -115,20 +87,13 @@ TEST_CASE("Test manager get create functionality for sequences") {
|
|||
}
|
||||
|
||||
TEST_CASE("End to end OpMult Flow with OpCreateTensor called with multiple tensors") {
|
||||
spdlog::info("TEST CASE STARTING");
|
||||
|
||||
spdlog::info("Creating manager");
|
||||
|
||||
spdlog::info("Creating first tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorLHS{ new kp::Tensor(
|
||||
{ 0, 1, 2 }) };
|
||||
|
||||
spdlog::info("Creating second tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorRHS{ new kp::Tensor(
|
||||
{ 2, 4, 6 }) };
|
||||
|
||||
// TODO: Add capabilities for just output tensor types
|
||||
spdlog::info("Creating output tensor");
|
||||
std::shared_ptr<kp::Tensor> tensorOutput{ new kp::Tensor(
|
||||
{ 0, 0, 0 }) };
|
||||
|
||||
|
|
@ -140,15 +105,10 @@ TEST_CASE("End to end OpMult Flow with OpCreateTensor called with multiple tenso
|
|||
|
||||
sq->record<kp::OpCreateTensor>({ tensorLHS, tensorRHS, tensorOutput });
|
||||
|
||||
spdlog::info("OpCreateTensor success for tensors");
|
||||
spdlog::info("Tensor one: {}", tensorLHS->data());
|
||||
spdlog::info("Tensor two: {}", tensorRHS->data());
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
REQUIRE(tensorLHS->isInit());
|
||||
REQUIRE(tensorRHS->isInit());
|
||||
REQUIRE(tensorOutput->isInit());
|
||||
|
||||
spdlog::info("Calling op mult");
|
||||
sq->record<kp::OpMult<>>({ tensorLHS, tensorRHS, tensorOutput });
|
||||
|
||||
sq->end();
|
||||
|
|
@ -156,10 +116,5 @@ TEST_CASE("End to end OpMult Flow with OpCreateTensor called with multiple tenso
|
|||
}
|
||||
sqWeakPtr.reset();
|
||||
|
||||
spdlog::info("OpMult call success");
|
||||
spdlog::info("Tensor output: {}", tensorOutput->data());
|
||||
|
||||
REQUIRE(tensorOutput->data() == std::vector<float>{0, 4, 12});
|
||||
|
||||
spdlog::info("Called manager eval success END PROGRAM");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue