Skip to content

Conversation

@magnesium2400
Copy link

if half-precision: read as 16bit uint and typecast back to half type

Copy link

@kalvdans kalvdans left a comment

Choose a reason for hiding this comment

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

Looks solid to me, half.typecast does not change the underlying bit pattern.


% read the data
data = fread(fid, prod(shape), [dataType '=>' dataType]);
if ishalf; data = half.typecast(data); end

Choose a reason for hiding this comment

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

Nit: move this code outside of the try-catch body.

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