Working iteration of kompute tensor with multiplee types

This commit is contained in:
Alejandro Saucedo 2021-03-06 17:44:17 +00:00
parent ad18c2e546
commit 956883e0cd
4 changed files with 30 additions and 8 deletions

View file

@ -7,6 +7,11 @@
int main()
{
#if KOMPUTE_ENABLE_SPDLOG
spdlog::set_level(
static_cast<spdlog::level::level_enum>(SPDLOG_ACTIVE_LEVEL));
#endif
kp::Manager mgr;
auto tensorInA = mgr.tensor<float>({ 2.0, 4.0, 6.0 });
@ -39,7 +44,8 @@ int main()
mgr.sequence()
->record<kp::OpTensorSyncDevice>(params)
->record<kp::OpAlgoDispatch>(algo)
->record<kp::OpTensorSyncLocal>(params);
->record<kp::OpTensorSyncLocal>(params)
->eval();
// prints "Output { 0 4 12 }"
std::cout<< "Output: { ";

View file

@ -1108,16 +1108,17 @@ class TensorView: public Tensor
const TensorTypes& tensorType = TensorTypes::eDevice)
: Tensor(physicalDevice, device, (void*)data.data(), data.size(), sizeof(T), this->dataType())
{
KP_LOG_DEBUG("Kompute TensorView constructor with data size {}", data.size());
this->mData = data;
}
~TensorView() {
KP_LOG_DEBUG("Kompute TensorView destructor");
}
void rebuild(const std::vector<T>& data,
TensorTypes tensorType = TensorTypes::eDevice) {
KP_LOG_DEBUG("Kompute TensorView creating with data size {}", data.size());
this->mData = data;
Tensor::rebuild(data.data(), data.size(), sizeof(T));
}
@ -1131,6 +1132,7 @@ class TensorView: public Tensor
}
void setData(const std::vector<T>& data) {
KP_LOG_DEBUG("Kompute TensorView setting data with data size {}", data.size());
if (data.size() != this->mData.size()) {
throw std::runtime_error(
@ -1144,6 +1146,8 @@ class TensorView: public Tensor
void setRawData(void* data, uint32_t elementTotalCount, uint32_t elementMemorySize) override
{
KP_LOG_DEBUG("Kompute TensorView setRawData with data size {}", elementTotalCount);
assert(elementMemorySize == sizeof(T));
this->mData = { (T*)data, ((T*)data) + elementTotalCount };
@ -1153,10 +1157,14 @@ class TensorView: public Tensor
TensorDataTypes dataType() override;
uint32_t size() override {
KP_LOG_DEBUG("Kompute TensorView retrieving size: {}", this->mData.size());
return this->mData.size();
}
uint32_t memorySize() override {
KP_LOG_DEBUG("Kompute TensorView retrieving memory size: {}", this->mData.size() * sizeof(T));
return this->mData.size() * sizeof(T);
}
@ -1185,7 +1193,6 @@ class TensorView: public Tensor
};
} // End namespace kp
namespace kp {

View file

@ -170,6 +170,7 @@ Tensor::recordBufferMemoryBarrier(const vk::CommandBuffer& commandBuffer,
vk::DescriptorBufferInfo
Tensor::constructDescriptorBufferInfo()
{
KP_LOG_WARN("Kompute Tensor construct descriptor buffer info size {}", this->memorySize());
vk::DeviceSize bufferSize = this->memorySize();
return vk::DescriptorBufferInfo(*this->mPrimaryBuffer,
0, // offset

View file

@ -318,16 +318,17 @@ class TensorView: public Tensor
const TensorTypes& tensorType = TensorTypes::eDevice)
: Tensor(physicalDevice, device, (void*)data.data(), data.size(), sizeof(T), this->dataType())
{
KP_LOG_DEBUG("Kompute TensorView constructor with data size {}", data.size());
this->mData = data;
}
~TensorView() {
KP_LOG_DEBUG("Kompute TensorView destructor");
}
void rebuild(const std::vector<T>& data,
TensorTypes tensorType = TensorTypes::eDevice) {
KP_LOG_DEBUG("Kompute TensorView creating with data size {}", data.size());
this->mData = data;
Tensor::rebuild(data.data(), data.size(), sizeof(T));
}
@ -341,6 +342,7 @@ class TensorView: public Tensor
}
void setData(const std::vector<T>& data) {
KP_LOG_DEBUG("Kompute TensorView setting data with data size {}", data.size());
if (data.size() != this->mData.size()) {
throw std::runtime_error(
@ -354,6 +356,8 @@ class TensorView: public Tensor
void setRawData(void* data, uint32_t elementTotalCount, uint32_t elementMemorySize) override
{
KP_LOG_DEBUG("Kompute TensorView setRawData with data size {}", elementTotalCount);
assert(elementMemorySize == sizeof(T));
this->mData = { (T*)data, ((T*)data) + elementTotalCount };
@ -363,10 +367,14 @@ class TensorView: public Tensor
TensorDataTypes dataType() override;
uint32_t size() override {
KP_LOG_DEBUG("Kompute TensorView retrieving size: {}", this->mData.size());
return this->mData.size();
}
uint32_t memorySize() override {
KP_LOG_DEBUG("Kompute TensorView retrieving memory size: {}", this->mData.size() * sizeof(T));
return this->mData.size() * sizeof(T);
}