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

[Target] Framework for device querying for all targets. #8602

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

Lunderberg
Copy link
Contributor

This has been a useful feature on the vulkan side, to determine device parameters based on the device present. This PR doesn't implement device querying on other targets, but moves the framework from vulkan-specific code to code that can be used by any runtime.

  • Move "from_device" argument definition from "vulkan" target to all targets.

  • Add device querying to TargetInternal::FromConfig, using "from_device" argument. If present, these have lower priority than explicitly-specified attributes, but higher priority than the default attribute values.

  • Add default no-op DeviceAPI::GetTargetProperty.

@Lunderberg
Copy link
Contributor Author

@zxybazh , as this impacts the Target class.

@tkonolige This was partly a follow-up from our conversation a few weeks ago, in which you mentioned that it would be nice to have device parameters query-able for cuda as well as vulkan.

- Move "from_device" argument definition from "vulkan" target to all
  targets.

- Add device querying to TargetInternal::FromConfig, using
  "from_device" argument.  If present, these have lower priority than
  explicitly-specified attributes, but higher priority than the
  default attribute values.

- Add default no-op DeviceAPI::GetTargetProperty.
@@ -106,7 +106,7 @@ class VulkanDeviceAPI final : public DeviceAPI {
* Returns the results of feature/property queries done during the
* device initialization.
*/
void GetTargetProperty(Device dev, const std::string& property, TVMRetValue* rv);
void GetTargetProperty(Device dev, const std::string& property, TVMRetValue* rv) final;
Copy link
Member

Choose a reason for hiding this comment

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

A bit curious about why adding final here?

Copy link
Contributor Author

@Lunderberg Lunderberg Jul 30, 2021

Choose a reason for hiding this comment

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

It isn't strictly necessary, but I try to be in the habit of including it for virtual functions that aren't intended to be subclassed further. It's always safe to remove final later, but until then it serves as a warning to my future self that I should be look into the class's implementation in detail before making any subclass of it.

I can go either way on having it or not, since final could be interpreted either as "not intended to be subclassed, so take a careful look first" or as "intended not to be subclassed, please don't change it". I tend to take the first interpretation, but the second is completely valid.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks!

@zxybazh
Copy link
Member

zxybazh commented Jul 30, 2021

On target related class side, the code looks good to me.

@vinx13 vinx13 merged commit 96d10f8 into apache:main Aug 3, 2021
@Lunderberg Lunderberg deleted the device_target_query branch August 3, 2021 19:46
ylc pushed a commit to ylc/tvm that referenced this pull request Sep 29, 2021
- Move "from_device" argument definition from "vulkan" target to all
  targets.

- Add device querying to TargetInternal::FromConfig, using
  "from_device" argument.  If present, these have lower priority than
  explicitly-specified attributes, but higher priority than the
  default attribute values.

- Add default no-op DeviceAPI::GetTargetProperty.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
- Move "from_device" argument definition from "vulkan" target to all
  targets.

- Add device querying to TargetInternal::FromConfig, using
  "from_device" argument.  If present, these have lower priority than
  explicitly-specified attributes, but higher priority than the
  default attribute values.

- Add default no-op DeviceAPI::GetTargetProperty.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants