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