This commit is contained in:
Alejandro Saucedo 2021-02-08 19:43:50 +00:00
parent f62e353f4a
commit aa75fdae47
6 changed files with 39 additions and 34 deletions

6
src/Manager.cpp Executable file → Normal file
View file

@ -62,7 +62,8 @@ Manager::~Manager()
SPDLOG_DEBUG("Kompute Manager explicitly freeing tensors");
for (const std::shared_ptr<Tensor>& tensor : this->mManagedTensors) {
if (!tensor->isInit()) {
SPDLOG_ERROR("Kompute Manager attempted to free managed tensor but not tensor is not initialised");
SPDLOG_ERROR("Kompute Manager attempted to free managed tensor "
"but not tensor is not initialised");
}
tensor->freeMemoryDestroyGPUResources();
}
@ -142,8 +143,7 @@ Manager::createManagedSequence(std::string sequenceName, uint32_t queueIndex)
if (sequenceName.empty()) {
this->mCurrentSequenceIndex++;
this->mManagedSequences.insert(
{ KP_DEFAULT_SESSION, sq });
this->mManagedSequences.insert({ KP_DEFAULT_SESSION, sq });
} else {
// TODO: Check if sequence doesn't already exist
this->mManagedSequences.insert({ sequenceName, sq });

View file

@ -232,7 +232,8 @@ Tensor::mapDataFromHostMemory()
} else if (this->mTensorType == TensorTypes::eDevice) {
hostVisibleMemory = this->mStagingMemory;
} else {
SPDLOG_WARN("Kompute Tensor mapping data not supported on storage tensor");
SPDLOG_WARN(
"Kompute Tensor mapping data not supported on storage tensor");
return;
}
@ -258,7 +259,8 @@ Tensor::mapDataIntoHostMemory()
} else if (this->mTensorType == TensorTypes::eDevice) {
hostVisibleMemory = this->mStagingMemory;
} else {
SPDLOG_WARN("Kompute Tensor mapping data not supported on storage tensor");
SPDLOG_WARN(
"Kompute Tensor mapping data not supported on storage tensor");
return;
}

View file

@ -1,7 +1,7 @@
#pragma once
#include <unordered_map>
#include <set>
#include <unordered_map>
#include "kompute/Core.hpp"
@ -125,9 +125,8 @@ class Manager
{
SPDLOG_DEBUG("Kompute Manager evalOp Default triggered");
this->mCurrentSequenceIndex++;
this->evalOp<T>(tensors,
KP_DEFAULT_SESSION,
std::forward<TArgs>(params)...);
this->evalOp<T>(
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
}
/**
@ -177,9 +176,8 @@ class Manager
{
SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered");
this->mCurrentSequenceIndex++;
this->evalOpAsync<T>(tensors,
KP_DEFAULT_SESSION,
std::forward<TArgs>(params)...);
this->evalOpAsync<T>(
tensors, KP_DEFAULT_SESSION, std::forward<TArgs>(params)...);
}
/**
@ -220,8 +218,7 @@ class Manager
void evalOpAwaitDefault(uint64_t waitFor = UINT64_MAX)
{
SPDLOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered");
this->evalOpAwait(KP_DEFAULT_SESSION,
waitFor);
this->evalOpAwait(KP_DEFAULT_SESSION, waitFor);
}
/**
@ -254,7 +251,10 @@ class Manager
}
/**
* Function that simplifies the common workflow of tensor initialisation. It will take the constructor parameters for a Tensor and will will us it to create a new Tensor. The tensor memory will then be managed and owned by the manager.
* Function that simplifies the common workflow of tensor initialisation. It
* will take the constructor parameters for a Tensor and will will us it to
* create a new Tensor. The tensor memory will then be managed and owned by
* the manager.
*
* @param data The data to initialize the tensor with
* @param tensorType The type of tensor to initialize
@ -274,7 +274,8 @@ class Manager
tensor->mapDataIntoHostMemory();
}
std::set<std::shared_ptr<Tensor>>::iterator it = this->mManagedTensors.find(tensor);
std::set<std::shared_ptr<Tensor>>::iterator it =
this->mManagedTensors.find(tensor);
if (it == this->mManagedTensors.end()) {
this->mManagedTensors.insert(tensor);
}