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

Extend (some) "prepare" functions to take a bit-depth parameter #126

Open
astewart-xmos opened this issue Dec 1, 2022 · 0 comments
Open
Labels
size:S type:enhancement New feature or request version: minor incr Minor version number increment required. (Change adds new features)

Comments

@astewart-xmos
Copy link
Contributor

I've encountered several places where I'd like to use a function, for example vect_s32_dot(), where an int64_t is returned, but where I'd really like to have an int32_t. vect_s32_dot_prepare() determines the necessary shifts and output exponent assuming a 64-bit output (really ~40 bits because of the VPU accumulators), and so it isn't safe to simply dump the output into an int32_t.

However, vect_s32_dot_prepare() could take a bit-depth parameter that tells it what the maximum scale for the output is. And then, even though it still returns int64_t, you could immediately dump that into an int32_t and not worry about overflows.

This mostly applies to the vector functions which return a scalar, like dot product, energy calculation, sums, etc.

I'm not sure there's a good way to allow the BFP API to take advantage of this unless e.g. bfp_s32_dot() also takes a bit-depth parameter.

I could backwards compatibility issues (and thus avoid a major version bump) creating a new prepare function and use a macro to map the old one with a default parameter.

@astewart-xmos astewart-xmos added type:enhancement New feature or request size:S version: minor incr Minor version number increment required. (Change adds new features) labels Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S type:enhancement New feature or request version: minor incr Minor version number increment required. (Change adds new features)
Projects
None yet
Development

No branches or pull requests

1 participant