-
Notifications
You must be signed in to change notification settings - Fork 60
RSDK-4197: Add support for Flat Tensors in Python SDK #425
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
Conversation
… np conversion bidirectionally (first draft); changed client and service to use new updated params and new utils
src/viam/utils.py
Outdated
|
||
ndarrays: Dict[str, NDArray] = dict() | ||
for name, flat_tensor in flat_tensors.tensors.items(): | ||
property_name = flat_tensor.WhichOneof("tensor") or flat_tensor.WhichOneof(b"tensor") # sus... |
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 seems fine to me? Agreed it's awkward but that's what the method calls for :/
Probably good to remove the comment here before we merge, also.
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.
Do you have more info than I on why the method accepts a bytes and non-bytes str literal of the same str?
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.
I do not! but it is what it is 🤷
…sor_data_class dict to outside of double nested helper to optimize instantiation; fixed timeout typo
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.
lgtm
data = ndarray.flatten() | ||
if tensor_data_class == FlatTensorDataInt8 or tensor_data_class == FlatTensorDataUInt8: | ||
data = data.tobytes() # as per the proto, int8 and uint8 are stored as bytes | ||
elif tensor_data_class == FlatTensorDataInt16 or tensor_data_class == FlatTensorDataUInt16: |
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.
Use numpy arrays as the backing data struct instead of dicts for mlmodel
Test plan notes:
EDGE FlatTensors without any tensors
FlatTensors with one tensor (say.. double type)
google.protobuf.internal.containers.RepeatedScalarFieldContainer
FlatTensors with two tensors (double type, float type)
google.protobuf.internal.containers.RepeatedScalarFieldContainer
Check all flat tensor data types in bundles of appropriate types