Added testseqquence tests
Signed-off-by: Alejandro Saucedo <axsauze@gmail.com>
This commit is contained in:
parent
3133e52d4b
commit
c5880d074f
1 changed files with 52 additions and 0 deletions
|
|
@ -133,3 +133,55 @@ TEST(TestSequence, SequenceTimestamps)
|
|||
EXPECT_EQ(timestamps.size(),
|
||||
6); // 1 timestamp at start + 1 after each operation
|
||||
}
|
||||
|
||||
TEST(TestSequence, UtilsClearRecordingRunning)
|
||||
{
|
||||
kp::Manager mgr;
|
||||
|
||||
std::shared_ptr<kp::Sequence> sq = mgr.sequence();
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> tensorA = mgr.tensor({ 1, 2, 3 });
|
||||
std::shared_ptr<kp::TensorT<float>> tensorB = mgr.tensor({ 2, 2, 2 });
|
||||
std::shared_ptr<kp::TensorT<float>> tensorOut = mgr.tensor({ 0, 0, 0 });
|
||||
|
||||
sq->eval<kp::OpTensorSyncDevice>({ tensorA, tensorB, tensorOut });
|
||||
|
||||
std::vector<uint32_t> spirv = compileSource(R"(
|
||||
#version 450
|
||||
|
||||
layout (local_size_x = 1) in;
|
||||
|
||||
// The input tensors bind index is relative to index in parameter passed
|
||||
layout(set = 0, binding = 0) buffer bina { float tina[]; };
|
||||
layout(set = 0, binding = 1) buffer binb { float tinb[]; };
|
||||
layout(set = 0, binding = 2) buffer bout { float tout[]; };
|
||||
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
tout[index] = tina[index] * tinb[index];
|
||||
}
|
||||
)");
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algo =
|
||||
mgr.algorithm({ tensorA, tensorB, tensorOut }, spirv);
|
||||
|
||||
sq->record<kp::OpAlgoDispatch>(algo)->record<kp::OpTensorSyncLocal>(
|
||||
{ tensorA, tensorB, tensorOut });
|
||||
|
||||
EXPECT_TRUE(sq->isRecording());
|
||||
|
||||
// Running clear to confirm it clears
|
||||
sq->clear();
|
||||
|
||||
EXPECT_FALSE(sq->isRecording());
|
||||
|
||||
sq->evalAsync();
|
||||
|
||||
EXPECT_TRUE(sq->isRunning());
|
||||
|
||||
sq->evalAwait();
|
||||
|
||||
EXPECT_FALSE(sq->isRunning());
|
||||
|
||||
EXPECT_EQ(tensorOut->vector(), std::vector<float>({ 2, 4, 6 }));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue