global Variable for sizing #34
-
|
Hi I'm new to Fxpmath, I was digging around in the code and I noticed that the default sizing is optimal, I was wondering if there was an easy way to easily set all variables to output to 'same' sizing instead? I have too many variables to manually do that for everyone so I was hoping that you guys have a global variable that will let me set that as the default instead. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
|
here is an example piece of code as to why I am asking this question:
showing the info shows that the word bits are 73 and I understand that you can't have more than 64 bits because of NumPy but I was hoping there was a way to keep it below 64, preferably keeping it to 32 but I just want a result that isn't all 0s. |
Beta Was this translation helpful? Give feedback.
-
|
Hello @Hamuel101, from fxpmath import Fxp
Fxp.template = Fxp(None, True, 32, 10, op_sizing='same') # enable template
x = Fxp(np.random.random((1,400)))
y = Fxp(np.random.random((400,128)))
Fxp.template = None # disable templateBut checking with your example, I found that There is another concern is about your example. The function z = x.dot(y) # op_sizing of x is usedor import fxpmath as fxp
z = fxp.dot(x, y, sizing='same')Any suggestion is very welcome! |
Beta Was this translation helpful? Give feedback.
-
|
Apologies for another question. I was wondering if there is a way to have optimal sizing but up to a bit cap, so for example it can have a max n_word of 32 but have any amount of n_bits? |
Beta Was this translation helpful? Give feedback.
-
|
all of your suggestions have been very helpful and I am now running into an issue with division. I have been doing as you suggested with fxp.dot and other functions like that. I am coming across a problem where I can't find a fxp.div or fxp.divide or anything like that. So I tried doing
it prints: 0.62786865234375 I can only give it 8 bits for other reasons so can not give integer bits for this purpose. Any suggestions? On a side note can I specify rounding in the template like, this doesn't seem to work either: Fxp.template = Fxp(None, True,8 ,7, op_sizing='same',rounding = 'around') |
Beta Was this translation helpful? Give feedback.
-
|
I have another question. again apologies for your time.
Error: TypeError: Is there a reason you guys raise an error instead of just turning the output into an Fxp object? I feel like you guys could just say
or else is there a way to transpose and Fxp object? |
Beta Was this translation helpful? Give feedback.
Hello @Hamuel101,
You're right about that default sizing is
optimal, and there is a way to define a template for newFxpobjects:But checking with your example, I found that
configparameters are set with default values, soop_sizingis set with 'optimal' again (I'm going to open an issue with this).There is another concern is about your example. The function
np.dotdoesn't know how to resolve sizing fromop_sizingproperty ofxory(it could be another issue), you can use so…