Skip to content

Conversation

@gchanan
Copy link
Contributor

@gchanan gchanan commented Aug 3, 2018

This changes setStorage (called by set_), newView (view), and newWithStorage (tensor) as per the title.

This also allows us to share size inference code between TH and ATen, so I killed e.g. newInferSize in TH; we just use at::infer_size inside of TH now.
Finally, I reorganized the TH/THC tensor/storage code to more closely match up; e.g. if THC has a non-generic version of a function, TH will as well.

NOTE: I didn't completely kill THSize, THStride yet because I haven't moved all the functions over yet. This has the unfortunate effect that we now have both IntList and Storage versions of the same concepts, e.g. there are IntListSize and IntListStride in Declarations.cwrap that pull out the LongStorage-ness, but not the 0-dim-to-1-dim or 0-dim-to-null functionality of THLongStorageView. Both of these limitations will be addressed in further PRs.

@gchanan
Copy link
Contributor Author

gchanan commented Aug 3, 2018


// Infers the size of a dim with size -1, if it exists. Also checks that new
// shape is compatible with the number of elements.
static std::vector<int64_t> infer_size(IntList shape, int64_t numel) {

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice

namespace at {

static inline std::vector<int64_t> get_intlist_size_th(IntList sizes) {
if (sizes.size() == 0) {

This comment was marked as off-topic.

This comment was marked as off-topic.

gchanan added 2 commits August 3, 2018 11:40
… of functions in TH.

This changes setStorage (called by set_), newView (view), and newWithStorage (tensor) as per the title.
This also allows us to share size inference code between TH and ATen, so I killed e.g. newInferSize in TH; we just use at::infer_size inside of TH now.
Finally, I reorganized the TH/THC tensor/storage code to more closely match up; e.g. if THC has a non-generic version of a function, TH will as well.

NOTE: I didn't completely kill THSize, THStride yet because I haven't moved all the functions over yet.  This has the unfortunate effect that we now have both IntList
and Storage versions of the same concepts, e.g. there are IntListSize and IntListStride in Declarations.cwrap that pull out the LongStorage-ness, but not the 0-dim-to-1-dim
or 0-dim-to-null functionality of THLongStorageView.  Both of these limitations will be addressed in further PRs.
@gchanan gchanan force-pushed the use_intlist_in_th2_storgetters branch from 0efd854 to 3de86ca Compare August 3, 2018 18:54
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@gchanan
Copy link
Contributor Author

gchanan commented Aug 6, 2018

Closing in favor of #10219.

@gchanan gchanan closed this Aug 6, 2018
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.

4 participants