Skip to content

Commit

Permalink
fix the issue #138
Browse files Browse the repository at this point in the history
  • Loading branch information
masajiro committed Jul 10, 2023
1 parent b9cf56b commit 9b59603
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.14
2.0.15
11 changes: 9 additions & 2 deletions lib/NGT/NGTQ/QuantizedBlobGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,11 @@ namespace QBG {
std::vector<float> &rotatedQuery = searchContainer.objectVector;
if (objectSpace.getObjectType() == typeid(float)) {
memcpy(rotatedQuery.data(), searchContainer.object.getPointer(), rotatedQuery.size() * sizeof(float));
} else if (objectSpace.getObjectType() == typeid(uint8_t)) {
auto *ptr = static_cast<uint8_t*>(searchContainer.object.getPointer());
for (size_t i = 0; i < rotatedQuery.size(); i++) {
rotatedQuery[i] = ptr[i];
}
#ifdef NGT_HALF_FLOAT
} else if (objectSpace.getObjectType() == typeid(NGT::float16)) {
auto *ptr = static_cast<NGT::float16*>(searchContainer.object.getPointer());
Expand Down Expand Up @@ -893,10 +898,13 @@ namespace QBG {
if (objectSpace.getObjectType() == typeid(float)) {
distance = NGT::PrimitiveComparator::L2Float::compare(searchContainer.object.getPointer(),
neighborptr->second->getPointer(), dimension);
} else if (objectSpace.getObjectType() == typeid(uint8_t)) {
distance = NGT::PrimitiveComparator::L2Uint8::compare(searchContainer.object.getPointer(),
neighborptr->second->getPointer(), dimension);
#ifdef NGT_HALF_FLOAT
} else if (objectSpace.getObjectType() == typeid(NGT::float16)) {
distance = NGT::PrimitiveComparator::L2Float16::compare(searchContainer.object.getPointer(),
neighborptr->second->getPointer(), dimension);
neighborptr->second->getPointer(), dimension);
#endif
} else {
assert(false);
Expand Down Expand Up @@ -1158,7 +1166,6 @@ namespace QBG {
}

const string com = "rm -rf " + indexPath + "/" + getWorkspaceName();
std::cerr << "pass com=" << com << std::endl;
if (system(com.c_str()) == -1) {
std::cerr << "Warning. cannot remove the workspace directory. " << std::endl;
}
Expand Down
16 changes: 14 additions & 2 deletions lib/NGT/NGTQ/Quantizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,13 +658,15 @@ class SerializableObject : public NGT::Object {
dataSize = sizeof(float) * dimension;
#endif
break;
#ifdef NGT_HALF_FLOAT
case DataTypeFloat16:
#ifdef NGTQ_QBG
dataSize = sizeof(float) * genuineDimension;
dataSize = sizeof(NGT::float16) * genuineDimension;
#else
dataSize = sizeof(float) * dimension;
dataSize = sizeof(NGT::float16) * dimension;
#endif
break;
#endif
default:
NGTThrowException("Quantizer constructor: Inner error. Invalid data type.");
break;
Expand Down Expand Up @@ -2590,11 +2592,21 @@ class QuantizerInstance : public Quantizer {
quantizedObjectDistance = new QuantizedObjectDistanceUint8<uint32_t>;
} else if (property.localIDByteSize == 2) {
quantizedObjectDistance = new QuantizedObjectDistanceUint8<uint16_t>;
#ifdef NGTQ_QBG
} else if (property.localIDByteSize == 1) {
quantizedObjectDistance = new QuantizedObjectDistanceFloat<uint8_t>;
#endif
} else {
std::cerr << "Inconsistent localIDByteSize and ObjectType. " << property.localIDByteSize << ":" << globalProperty.objectType << std::endl;
abort();
}
#ifdef NGTQ_VECTOR_OBJECT
generateResidualObject = new GenerateResidualObjectFloat;
sizeoftype = sizeof(float);
#else
generateResidualObject = new GenerateResidualObjectUint8;
sizeoftype = sizeof(uint8_t);
#endif
} else {
cerr << "NGTQ::open: Fatal Inner Error: invalid object type. " << globalProperty.objectType << endl;
cerr << " check NGT version consistency between the caller and the library." << endl;
Expand Down

0 comments on commit 9b59603

Please sign in to comment.