-
Notifications
You must be signed in to change notification settings - Fork 159
#16353: skip no volume tensors #16619
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,17 @@ concept DeviceOperationWithCustomProgramCacheConcept = | |
{ device_operation_t::compute_program_hash(operation_attributes, tensor_args)} -> std::convertible_to<tt::stl::hash::hash_t>; | ||
}; | ||
|
||
template <typename device_operation_t> | ||
concept HasSkipLaunch = requires( | ||
device_operation_t op, | ||
const typename device_operation_t::operation_attributes_t& operation_attributes, | ||
const typename device_operation_t::tensor_args_t& tensor_args, | ||
const typename device_operation_t::tensor_return_value_t& tensor_return_value) { | ||
{ | ||
device_operation_t::skip_launch(operation_attributes, tensor_args, tensor_return_value) | ||
} -> std::convertible_to<bool>; | ||
}; | ||
|
||
namespace detail { | ||
template <typename... Ts> | ||
[[nodiscard]] std::variant<Ts...> map_index_to_variant(std::size_t i, std::variant<Ts...>) { | ||
|
@@ -238,6 +249,12 @@ template <DeviceOperationConcept device_operation_t> | |
void launch_on_worker_thread(auto cq_id, auto device_operation_id, const auto& operation_attributes, const auto& tensor_args, auto &tensor_return_value, auto& device) { | ||
ZoneScopedN("TT_DNN_DEVICE_OP"); | ||
|
||
if constexpr (HasSkipLaunch<device_operation_t>) { | ||
if (device_operation_t::skip_launch(operation_attributes, tensor_args, tensor_return_value)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this is a universal rule that can be applied to all operations. Not pushing it in this PR. Just curios what everyone think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to make that assumption, in case the op decided that it should initialize padding values or other weird edge-cases. Last I checked, the decision on how to handle padding in tiled layouts has still not been resolved, so I thought ops should explicitly opt into this skipping behavior at least for now. |
||
return; | ||
} | ||
} | ||
|
||
auto& program_cache = device->get_program_cache(); | ||
|
||
auto program_hash = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,6 +201,13 @@ tt::stl::hash::hash_t UnaryDeviceOperation::compute_program_hash( | |
return hash; | ||
} | ||
|
||
bool UnaryDeviceOperation::skip_launch( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also I wonder if instead we should return some noop from select_program_factory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I'm misunderstanding what you mean by this, I think that would be a much more invasive change to make. |
||
const operation_attributes_t& attributes, | ||
const tensor_args_t& tensor_args, | ||
const tensor_return_value_t& tensor_return_value) { | ||
return tensor_return_value.logical_shape().volume() == 0; | ||
} | ||
|
||
std::tuple<UnaryDeviceOperation::operation_attributes_t, UnaryDeviceOperation::tensor_args_t> | ||
UnaryDeviceOperation::invoke( | ||
const Tensor& input, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a similar test for binary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we have a
test_01_volume_tensors
test intest_binary_bcast.py
.