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

Make the C++ interface easier to use #185

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

VivekPanyam
Copy link
Owner

This PR adds a more convenient way to index into tensors from the C++ API.

Previously, a user would have to explicitly compute an offset based on the strides of a tensor and their desired index (or use an external library).

They would also have to use different methods for string tensors and numeric tensors (e.g. get_string/set_string for dealing with string tensors).

This PR provides an at method that lets users pass in an index and get an element. It also provides an accessor method that can be used when accessing several elements. These work for both string and numeric tensors.

Note: this is a breaking change for the following reasons:

  • get_string and set_string in the C++ API are now private methods
  • carton_tensor_get_string, carton_tensor_set_string, and carton_tensor_set_string_with_strlen from the C API now expect their index argument to take strides into account. This shouldn't have a practical impact as all our current ways of creating string tensors and exposing them via the C API create tensors with standard strides.

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.

1 participant