-
Notifications
You must be signed in to change notification settings - Fork 23
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
WIP: Float conv1 #109
base: main
Are you sure you want to change the base?
WIP: Float conv1 #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great progress!
lib/src/arithmetic/floating_point/floating_point_converter.dart
Outdated
Show resolved
Hide resolved
lib/src/arithmetic/floating_point/floating_point_converter.dart
Outdated
Show resolved
Hide resolved
lib/src/arithmetic/floating_point/floating_point_converter.dart
Outdated
Show resolved
Hide resolved
]), | ||
Iff(source.isSubnormal() | source.isNormal(), [ | ||
_result < | ||
mux( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use a mux here instead of two if statements?
lib/src/arithmetic/floating_point/floating_point_converter.dart
Outdated
Show resolved
Hide resolved
import 'package:rohd/rohd.dart'; | ||
|
||
void main() { | ||
const fp32ExponentWidth = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR should provide these constants for reference:
#110
although, why test these specifically instead of a handful of arbitrary sizes?
final converter = FloatingPointConverter(fp32, | ||
destExponentWidth: bf19ExponentWidth, | ||
destMantissaWidth: bf19MantissaWidth, | ||
name: 'fp32_to_bf19'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test the whole module works on some things?
|
||
adjustedMantissa <= | ||
adjustMantissaPrecision(source.mantissa, destMantissaWidth, | ||
Const(FloatingPointRoundingMode.roundNearestEven.index)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heads up that Const
default width is 1
destMantissaWidth: bf19MantissaWidth, | ||
name: 'fp32_to_bf19'); | ||
|
||
expect(converter.result.floatingPointValue.toString().contains('x'), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an isValid
on LogicValue
you can use
destMantissaWidth: fp16MantissaWidth, | ||
name: 'fp32_to_bf19'); | ||
|
||
print('Test case:'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the reason
field of expect
to give more detailed explanations, and '''
s to make multi-line strings
/// | ||
/// [destExponentWidth] and [destMantissaWidth] are the widths of the exponent | ||
/// and mantissa of the destination [FloatingPoint] respectively. | ||
static FloatingPoint handleOverflow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may want to tag these helper functions with @visibleForTesting
unless you think they are useful outside of this converter?
Description & Motivation
Software and Hardware Arbitrary Precision Float Converter