Added specconst test for int
Signed-off-by: Alejandro Saucedo <axsauze@gmail.com>
This commit is contained in:
parent
2d4c2f7333
commit
1b2f42c3ac
1 changed files with 13 additions and 12 deletions
|
|
@ -59,11 +59,11 @@ TEST(TestSpecializationConstants, TestConstantsInt)
|
|||
{
|
||||
std::string shader(R"(
|
||||
#version 450
|
||||
layout (constant_id = 0) const float cOne = 1;
|
||||
layout (constant_id = 1) const float cTwo = 1;
|
||||
layout (constant_id = 0) const int cOne = 1;
|
||||
layout (constant_id = 1) const int cTwo = 1;
|
||||
layout (local_size_x = 1) in;
|
||||
layout(set = 0, binding = 0) buffer a { float pa[]; };
|
||||
layout(set = 0, binding = 1) buffer b { float pb[]; };
|
||||
layout(set = 0, binding = 0) buffer a { int pa[]; };
|
||||
layout(set = 0, binding = 1) buffer b { int pb[]; };
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
pa[index] = cOne;
|
||||
|
|
@ -77,18 +77,18 @@ TEST(TestSpecializationConstants, TestConstantsInt)
|
|||
{
|
||||
kp::Manager mgr;
|
||||
|
||||
std::shared_ptr<kp::TensorT<float>> tensorA =
|
||||
mgr.tensor({ 0, 0, 0 });
|
||||
std::shared_ptr<kp::TensorT<float>> tensorB =
|
||||
mgr.tensor({ 0, 0, 0 });
|
||||
std::shared_ptr<kp::TensorT<int32_t>> tensorA =
|
||||
mgr.tensorT<int32_t>({ 0, 0, 0 });
|
||||
std::shared_ptr<kp::TensorT<int32_t>> tensorB =
|
||||
mgr.tensorT<int32_t>({ 0, 0, 0 });
|
||||
|
||||
std::vector<std::shared_ptr<kp::Tensor>> params = { tensorA,
|
||||
tensorB };
|
||||
|
||||
kp::Constants spec = kp::Constants({ 5.0, 0.3 });
|
||||
std::vector<int32_t> spec({ -1, -2 });
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algo =
|
||||
mgr.algorithm(params, spirv, {}, spec);
|
||||
mgr.algorithm(params, spirv, {}, spec, {});
|
||||
|
||||
sq = mgr.sequence()
|
||||
->record<kp::OpTensorSyncDevice>(params)
|
||||
|
|
@ -96,8 +96,9 @@ TEST(TestSpecializationConstants, TestConstantsInt)
|
|||
->record<kp::OpTensorSyncLocal>(params)
|
||||
->eval();
|
||||
|
||||
EXPECT_EQ(tensorA->vector(), std::vector<float>({ 5, 5, 5 }));
|
||||
EXPECT_EQ(tensorB->vector(), std::vector<float>({ 0.3, 0.3, 0.3 }));
|
||||
EXPECT_EQ(tensorA->vector(), std::vector<int32_t>({ -1, -1, -1 }));
|
||||
EXPECT_EQ(tensorB->vector(), std::vector<int32_t>({ -2, -2, -2 }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue