Updated python to build
Signed-off-by: Alejandro Saucedo <axsauze@gmail.com>
This commit is contained in:
parent
5193975e5c
commit
6113d286a9
2 changed files with 48 additions and 1 deletions
|
|
@ -61,7 +61,6 @@ PYBIND11_MODULE(kp, m) {
|
|||
py::class_<kp::Algorithm, std::shared_ptr<kp::Algorithm>>(m, "Algorithm", DOC(kp, Algorithm, Algorithm))
|
||||
.def("get_tensors", &kp::Algorithm::getTensors, DOC(kp, Algorithm, getTensors))
|
||||
.def("destroy", &kp::Algorithm::destroy, DOC(kp, Algorithm, destroy))
|
||||
.def("get_spec_consts", &kp::Algorithm::getSpecializationConstants, DOC(kp, Algorithm, getSpecializationConstants))
|
||||
.def("is_init", &kp::Algorithm::isInit, DOC(kp, Algorithm, isInit));
|
||||
|
||||
py::class_<kp::Tensor, std::shared_ptr<kp::Tensor>>(m, "Tensor", DOC(kp, Tensor))
|
||||
|
|
|
|||
|
|
@ -53,3 +53,51 @@ TEST(TestSpecializationConstants, TestTwoConstants)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (local_size_x = 1) in;
|
||||
layout(set = 0, binding = 0) buffer a { float pa[]; };
|
||||
layout(set = 0, binding = 1) buffer b { float pb[]; };
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
pa[index] = cOne;
|
||||
pb[index] = cTwo;
|
||||
})");
|
||||
|
||||
std::vector<uint32_t> spirv = compileSource(shader);
|
||||
|
||||
std::shared_ptr<kp::Sequence> sq = nullptr;
|
||||
|
||||
{
|
||||
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::vector<std::shared_ptr<kp::Tensor>> params = { tensorA,
|
||||
tensorB };
|
||||
|
||||
kp::Constants spec = kp::Constants({ 5.0, 0.3 });
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algo =
|
||||
mgr.algorithm(params, spirv, {}, spec);
|
||||
|
||||
sq = mgr.sequence()
|
||||
->record<kp::OpTensorSyncDevice>(params)
|
||||
->record<kp::OpAlgoDispatch>(algo)
|
||||
->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 }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue