Fixed some issues with documentation
This commit is contained in:
parent
92e13d43e4
commit
ebfd7284c9
|
@ -29,12 +29,12 @@ extern "C" {
|
|||
// contain data, based on whether or not the embedder was configured to perform
|
||||
// scalar quantization.
|
||||
struct Embedding {
|
||||
// Floating-point embedding. Empty/nullptr if the embedder was configured to perform
|
||||
// scalar-quantization.
|
||||
// Floating-point embedding. Empty/nullptr if the embedder was configured to
|
||||
// perform scalar-quantization.
|
||||
float* float_embedding;
|
||||
|
||||
// Scalar-quantized embedding. Empty/nullptr if the embedder was not configured to
|
||||
// perform scalar quantization.
|
||||
// Scalar-quantized embedding. Empty/nullptr if the embedder was not
|
||||
// configured to perform scalar quantization.
|
||||
char* quantized_embedding;
|
||||
|
||||
// Keep the count of embedding values.
|
||||
|
|
|
@ -36,25 +36,29 @@ void CppConvertToEmbeddingResult(
|
|||
for (uint32_t i = 0; i < out->embeddings_count; ++i) {
|
||||
auto embedding_in = in.embeddings[i];
|
||||
auto& embedding_out = out->embeddings[i];
|
||||
|
||||
// Handling float embeddings
|
||||
if (!embedding_in.float_embedding.empty()) {
|
||||
embedding_out.values_count = embedding_in.float_embedding.size();
|
||||
embedding_out.float_embedding =
|
||||
embedding_out.values_count ? new float[embedding_out.values_count]
|
||||
: nullptr;
|
||||
embedding_out.float_embedding = new float[embedding_out.values_count];
|
||||
|
||||
std::copy(embedding_in.float_embedding.begin(),
|
||||
embedding_in.float_embedding.end(),
|
||||
embedding_out.float_embedding);
|
||||
|
||||
embedding_out.quantized_embedding = nullptr;
|
||||
} else if (!embedding_in.quantized_embedding.empty()) {
|
||||
|
||||
}
|
||||
// Handling quantized embeddings
|
||||
else if (!embedding_in.quantized_embedding.empty()) {
|
||||
embedding_out.values_count = embedding_in.quantized_embedding.size();
|
||||
embedding_out.quantized_embedding =
|
||||
embedding_out.values_count ? new char[embedding_out.values_count]
|
||||
: nullptr;
|
||||
embedding_out.quantized_embedding = new char[embedding_out.values_count];
|
||||
|
||||
std::copy(embedding_in.quantized_embedding.begin(),
|
||||
embedding_in.quantized_embedding.end(),
|
||||
embedding_out.quantized_embedding);
|
||||
|
||||
embedding_out.float_embedding = nullptr;
|
||||
|
||||
}
|
||||
|
||||
embedding_out.head_index = embedding_in.head_index;
|
||||
|
@ -76,7 +80,7 @@ void CppCloseEmbeddingResult(EmbeddingResult* in) {
|
|||
free(embedding_in.head_name);
|
||||
}
|
||||
delete[] in->embeddings;
|
||||
in.head_name = nullptr;
|
||||
in->embeddings = nullptr;
|
||||
}
|
||||
|
||||
} // namespace mediapipe::tasks::c::components::containers
|
||||
|
|
Loading…
Reference in New Issue
Block a user