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

Use log probs for paraformer #120

Merged
merged 2 commits into from
Apr 9, 2023
Merged

Use log probs for paraformer #120

merged 2 commits into from
Apr 9, 2023

Conversation

pengzhendong
Copy link
Contributor

No description provided.

@@ -103,5 +103,18 @@ std::vector<int32_t> TopkIndex(const T *vec, int32_t size, int32_t topk) {
return index;
}

template <class T>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow

auto y = static_cast<int64_t>(std::distance(
static_cast<const float *>(p_log_probs),
std::max_element(
static_cast<const float *>(p_log_probs),
static_cast<const float *>(p_log_probs) + vocab_size)));

to use std::max_element to replace ArgMax().

You don't need to reimplement the wheel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p_log_probs is const float *, why do we use static_cast again?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p_log_probs is const float *, why do we use static_cast again?

yes, you are right. please remove the cast.

Comment on lines 23 to 24
const float *p = log_probs.GetTensorData<float>();
for (int32_t i = 0; i != batch_size; ++i) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const float *p = log_probs.GetTensorData<float>();
for (int32_t i = 0; i != batch_size; ++i) {
for (int32_t i = 0; i != batch_size; ++i) {
const float *p = log_probs.GetTensorData<float>() + i * num_tokens * vocab_size;

@csukuangfj
Copy link
Collaborator

Thanks!

@csukuangfj csukuangfj merged commit d781fcd into k2-fsa:master Apr 9, 2023
XiaYucca pushed a commit to XiaYucca/sherpa-onnx that referenced this pull request Jan 9, 2025
* Use log probs for paraformer

* Fix
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

Successfully merging this pull request may close these issues.

2 participants