Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Computations with 8-Bit Data. #374

Open
ballaib opened this issue May 25, 2024 · 1 comment
Open

Add Support for Computations with 8-Bit Data. #374

ballaib opened this issue May 25, 2024 · 1 comment

Comments

@ballaib
Copy link

ballaib commented May 25, 2024

I wanted to use Kompute to do processing on 8-bit images. However, this does not appear to be possible without converting the image to another format beforehand. This made Kompute infeasible for my use case. It would be really helpful if Kompute supported computations with 8-bit data.

@axsaucedo
Copy link
Member

You can add uint_8 data type quite easily by following

// Introducing custom struct that can be used for tensors
struct TestStruct {
float x;
uint32_t y;
int32_t z;
// Creating an == operator overload for the comparison below
bool operator==(const TestStruct rhs) const {
return this->x == rhs.x && this->y == rhs.y && this->z == rhs.z;
}
};
// Custom struct needs to be mapped the eCustom datatype
template<>
kp::Tensor::TensorDataTypes
kp::TensorT<TestStruct>::dataType()
{
return Tensor::TensorDataTypes::eCustom;
}
TEST(TestShader, ShaderRawDataFromConstructorCustomDataType)
{
std::string shader(R"(
#version 450
layout (local_size_x = 1) in;
layout(std140, binding = 0) buffer a {
float ax;
uint ay;
int az;
};
layout(std140, binding = 1) buffer b {
float bx;
uint by;
int bz;
};
void main() {
bx = ax;
by = ay;
bz = az;
}
)");
kp::Manager mgr;
std::shared_ptr<kp::TensorT<TestStruct>> tensorA = mgr.tensorT<TestStruct>({ { 0.1, 2, 3} });
std::shared_ptr<kp::TensorT<TestStruct>> tensorB = mgr.tensorT<TestStruct>({ { 0.0, 0, 0} });

We are looking to add this by default however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants