Added logistic regression implementation in tests

This commit is contained in:
Alejandro Saucedo 2020-08-31 19:01:41 +01:00
parent a379feb77a
commit a325486d01
6 changed files with 616 additions and 2 deletions

View file

@ -165,3 +165,48 @@ TEST_CASE("test_multiple_algo_exec_multiple_sequence") {
REQUIRE(tensorA->data() == std::vector<float>{3, 3, 3});
}
TEST_CASE("test_multiple_algo_exec_single_sequence_single_record") {
kp::Manager mgr;
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor({ 0, 0, 0 })};
std::string shader(
"#version 450\n"
"layout (local_size_x = 1) in;\n"
"layout(set = 0, binding = 0) buffer a { float pa[]; };\n"
"void main() {\n"
" uint index = gl_GlobalInvocationID.x;\n"
" pa[index] = pa[index] + 1;\n"
"}\n"
);
std::weak_ptr<kp::Sequence> sqWeakPtr = mgr.getOrCreateManagedSequence("newSequence");
if (std::shared_ptr<kp::Sequence> sq = sqWeakPtr.lock()) {
sq->begin();
sq->record<kp::OpCreateTensor>({ tensorA });
sq->end();
sq->eval();
}
std::weak_ptr<kp::Sequence> sqWeakPtr2 = mgr.getOrCreateManagedSequence("newSequence2");
if (std::shared_ptr<kp::Sequence> sq = sqWeakPtr.lock()) {
sq->begin();
sq->record<kp::OpAlgoBase<3, 1, 1>>(
{ tensorA },
true, // Whether to copy output from device
std::vector<char>(shader.begin(), shader.end()));
sq->end();
sq->eval();
sq->eval();
sq->eval();
}
REQUIRE(tensorA->data() == std::vector<float>{3, 3, 3});
}