Updated to enable for opmult to work
This commit is contained in:
parent
fb617d1722
commit
3304767f2c
11 changed files with 49 additions and 39 deletions
|
|
@ -15,7 +15,14 @@ Algorithm::Algorithm(
|
|||
KP_LOG_DEBUG("Kompute Algorithm Constructor with device");
|
||||
|
||||
this->mDevice = device;
|
||||
this->rebuild(tensors, spirv, workgroup, specializationConstants, pushConstants);
|
||||
|
||||
if (tensors.size() && spirv.size()) {
|
||||
KP_LOG_INFO("Kompute Algorithm initialising with tensor size: {} and spirv size: {}", tensors.size(), spirv.size());
|
||||
this->rebuild(tensors, spirv, workgroup, specializationConstants, pushConstants);
|
||||
}
|
||||
else {
|
||||
KP_LOG_INFO("Kompute Algorithm constructor with empty tensors and or spirv so not rebuilding vulkan components");
|
||||
}
|
||||
}
|
||||
|
||||
Algorithm::~Algorithm()
|
||||
|
|
@ -39,10 +46,10 @@ Algorithm::rebuild(
|
|||
this->mSpirv = spirv;
|
||||
this->mSpecializationConstants = specializationConstants;
|
||||
this->mPushConstants = pushConstants;
|
||||
this->setWorkgroup(workgroup);
|
||||
this->setWorkgroup(workgroup, this->mTensors.size() ? this->mTensors[0]->size() : 1);
|
||||
|
||||
// Descriptor pool is created first so if available then destroy all before rebuild
|
||||
if (this->mFreeDescriptorPool) {
|
||||
if (this->isInit()) {
|
||||
this->destroy();
|
||||
}
|
||||
|
||||
|
|
@ -340,20 +347,6 @@ Algorithm::recordDispatch(std::shared_ptr<vk::CommandBuffer> commandBuffer)
|
|||
{
|
||||
KP_LOG_DEBUG("Kompute Algorithm calling record dispatch");
|
||||
|
||||
if(this->mPipelineCache) {
|
||||
KP_LOG_WARN("Value valid");
|
||||
}
|
||||
else {
|
||||
KP_LOG_WARN("NOT Value valid");
|
||||
}
|
||||
|
||||
if(this->mPipeline) {
|
||||
KP_LOG_WARN("Value valid");
|
||||
}
|
||||
else {
|
||||
KP_LOG_WARN("NOT Value valid");
|
||||
}
|
||||
|
||||
commandBuffer->bindPipeline(vk::PipelineBindPoint::eCompute,
|
||||
*this->mPipeline);
|
||||
|
||||
|
|
@ -376,10 +369,7 @@ Algorithm::recordDispatch(std::shared_ptr<vk::CommandBuffer> commandBuffer)
|
|||
void
|
||||
Algorithm::setWorkgroup(const Workgroup& workgroup, uint32_t minSize) {
|
||||
|
||||
KP_LOG_INFO("Kompute OpAlgoCreate setting dispatch size X: {}, Y: {}, Z: {}",
|
||||
this->mWorkgroup[0],
|
||||
this->mWorkgroup[1],
|
||||
this->mWorkgroup[2]);
|
||||
KP_LOG_INFO("Kompute OpAlgoCreate setting dispatch size");
|
||||
|
||||
// The dispatch size is set up based on either explicitly provided template
|
||||
// parameters or by default it would take the shape and size of the tensors
|
||||
|
|
@ -394,6 +384,11 @@ Algorithm::setWorkgroup(const Workgroup& workgroup, uint32_t minSize) {
|
|||
} else {
|
||||
this->mWorkgroup = { minSize, 1, 1 };
|
||||
}
|
||||
|
||||
KP_LOG_INFO("Kompute OpAlgoCreate set dispatch size X: {}, Y: {}, Z: {}",
|
||||
this->mWorkgroup[0],
|
||||
this->mWorkgroup[1],
|
||||
this->mWorkgroup[2]);
|
||||
}
|
||||
|
||||
const Workgroup&
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Manager::Manager()
|
|||
Manager::Manager(uint32_t physicalDeviceIndex,
|
||||
const std::vector<uint32_t>& familyQueueIndices)
|
||||
{
|
||||
this->mManageResources = false;
|
||||
this->mManageResources = true;
|
||||
|
||||
this->createInstance();
|
||||
this->createDevice(familyQueueIndices, physicalDeviceIndex);
|
||||
|
|
@ -43,7 +43,7 @@ Manager::Manager(std::shared_ptr<vk::Instance> instance,
|
|||
std::shared_ptr<vk::PhysicalDevice> physicalDevice,
|
||||
std::shared_ptr<vk::Device> device)
|
||||
{
|
||||
this->mManageResources = true;
|
||||
this->mManageResources = false;
|
||||
|
||||
this->mInstance = instance;
|
||||
this->mPhysicalDevice = physicalDevice;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@
|
|||
|
||||
namespace kp {
|
||||
|
||||
OpAlgoDispatch::OpAlgoDispatch(const std::shared_ptr<kp::Algorithm>& algorithm)
|
||||
OpAlgoDispatch::OpAlgoDispatch(const std::shared_ptr<kp::Algorithm>& algorithm, bool skipAlgoCheck)
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute OpAlgoDispatch constructor");
|
||||
|
||||
if (!skipAlgoCheck && !algorithm->isInit()) {
|
||||
throw std::runtime_error("Kompute OpAlgoDispatch constructor with non initialised algorithm");
|
||||
}
|
||||
|
||||
this->mAlgorithm = algorithm;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ OpTensorSyncDevice::OpTensorSyncDevice(
|
|||
OpTensorSyncDevice::~OpTensorSyncDevice()
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute OpTensorSyncDevice destructor started");
|
||||
|
||||
this->mTensors.clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ Sequence::eval()
|
|||
std::shared_ptr<Sequence>
|
||||
Sequence::eval(std::shared_ptr<OpBase> op) {
|
||||
this->clear();
|
||||
this->record(op);
|
||||
this->eval();
|
||||
return this->record(op)->eval();
|
||||
}
|
||||
|
||||
std::shared_ptr<Sequence>
|
||||
|
|
@ -88,6 +87,7 @@ Sequence::evalAsync()
|
|||
if (this->isRecording()) {
|
||||
this->end();
|
||||
}
|
||||
|
||||
if (this->mIsRunning) {
|
||||
throw std::runtime_error("Kompute Sequence evalAsync called when an eval async was "
|
||||
"called without successful wait");
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class OpAlgoDispatch : public OpBase
|
|||
{
|
||||
public:
|
||||
|
||||
OpAlgoDispatch(const std::shared_ptr<kp::Algorithm>& algorithm);
|
||||
OpAlgoDispatch(const std::shared_ptr<kp::Algorithm>& algorithm, bool skipAlgoInit = false);
|
||||
|
||||
/**
|
||||
* Default destructor, which is in charge of destroying the algorithm
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class OpMult : public OpAlgoDispatch
|
|||
* @param komputeWorkgroup Optional parameter to specify the layout for processing
|
||||
*/
|
||||
OpMult(std::vector<std::shared_ptr<Tensor>> tensors, std::shared_ptr<Algorithm> algorithm)
|
||||
: OpAlgoDispatch(algorithm)
|
||||
: OpAlgoDispatch(algorithm, true)
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute OpMult constructor with params");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue