Skip to content

Eliminate use of getType from DLConvertor#11080

Closed
ezyang wants to merge 4 commits intoexport-D9578399from
export-D9578734
Closed

Eliminate use of getType from DLConvertor#11080
ezyang wants to merge 4 commits intoexport-D9578399from
export-D9578734

Conversation

@ezyang
Copy link
Contributor

@ezyang ezyang commented Aug 30, 2018

Eliminate use of getType from DLConvertor

  • Add a new TensorOptions(Device, ScalarType) constructor,
    which serves roughly the same role as getType used to.
    We shouldn't get too wild with these constructors, but
    since this particular one was widely used by getType,
    it seems worth adding.
  • Change DLPack DeviceType conversion to at::DeviceType,
    rather than at::Backend. While I'm at, add a few more
    conversions that at::DeviceType understands.
  • Add a new overload of from_blob which understands strides.

Differential Revision: D9578734

Stacked on #11078

Differential Revision: D9578734
Differential Version: 56519039
ezyang added 2 commits August 30, 2018 07:46
Differential Revision: D9578734
Differential Version: 56520207
Differential Revision: D9578734
Differential Version: 56526151
Differential Revision: D9578734
Differential Version: 56530959
throw std::logic_error("Unsupported device_type: " + std::to_string(ctx.device_type));
}
return backend;
return DeviceType::CPU; // impossible

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

return options.type().tensorFromBlob(data, sizes, deleter);
}

inline Tensor from_blob(

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@cpuhrsch cpuhrsch left a comment

Choose a reason for hiding this comment

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

Ok with comments.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Aug 31, 2018
Summary:
Pull Request resolved: pytorch/pytorch#11080

- Add a new TensorOptions(Device, ScalarType) constructor,
  which serves roughly the same role as getType used to.
  We shouldn't get too wild with these constructors, but
  since this particular one was widely used by getType,
  it seems worth adding.
- Change DLPack DeviceType conversion to at::DeviceType,
  rather than at::Backend.  While I'm at, add a few more
  conversions that at::DeviceType understands.
- Add a new overload of from_blob which understands strides.

Reviewed By: gchanan, cpuhrsch

Differential Revision: D9578734

fbshipit-source-id: 28288ec053aae8765e23925ab91023398d632d6b
PenghuiCheng pushed a commit to PenghuiCheng/pytorch that referenced this pull request Sep 11, 2018
Summary:
Pull Request resolved: pytorch#11080

- Add a new TensorOptions(Device, ScalarType) constructor,
  which serves roughly the same role as getType used to.
  We shouldn't get too wild with these constructors, but
  since this particular one was widely used by getType,
  it seems worth adding.
- Change DLPack DeviceType conversion to at::DeviceType,
  rather than at::Backend.  While I'm at, add a few more
  conversions that at::DeviceType understands.
- Add a new overload of from_blob which understands strides.

Reviewed By: gchanan, cpuhrsch

Differential Revision: D9578734

fbshipit-source-id: 28288ec053aae8765e23925ab91023398d632d6b
@soumith soumith deleted the export-D9578734 branch February 21, 2019 23:25
@ezyang ezyang added the merged label Jun 26, 2019
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.

3 participants