Skip to content

Make the C++ interface easier to use - #185

Draft
VivekPanyam wants to merge 1 commit into
mainfrom
tensor_accessor
Draft

Make the C++ interface easier to use#185
VivekPanyam wants to merge 1 commit into
mainfrom
tensor_accessor

Conversation

@VivekPanyam

Copy link
Copy Markdown
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