Skip to content

Commit a536e23

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix numel() downcast in executorch/backends/vulkan/test/utils/test_utils.cpp +2
Summary: `numel()` has type `int64_t`. The implicit downcasts fix in this change artificially truncate data ranges which can lead to hard-to-debug errors and SEVs. Using `auto` ensures that the correct data type is used. Reviewed By: dtolnay Differential Revision: D73534006
1 parent 954f2cb commit a536e23

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

backends/vulkan/test/utils/test_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void record_bitw8_image_to_nchw_nobitw8buffer_op(
114114
api::vTensor& v_src,
115115
api::StagingBuffer& dst_buffer) {
116116
vkapi::PipelineBarrier pipeline_barrier{};
117-
uint32_t buffer_len = utils::safe_downcast<uint32_t>(dst_buffer.numel() / 4);
117+
auto buffer_len = utils::safe_downcast<uint32_t>(dst_buffer.numel() / 4);
118118
utils::uvec3 global_wg_size = {buffer_len, 1, 1};
119119

120120
std::string kernel_name = "bitw8_image_to_nchw_nobitw8buffer";

backends/xnnpack/runtime/utils/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ executorch::runtime::Error QuantizePerTensor(
132132
double scale,
133133
int zero_point) {
134134
const float* rdata = rtensor.const_data_ptr<float>();
135-
int numel = rtensor.numel();
135+
auto numel = rtensor.numel();
136136
ET_CHECK_OR_RETURN_ERROR(
137137
(std::is_same<T, uint8_t>::value || std::is_same<T, int8_t>::value),
138138
Internal,

0 commit comments

Comments
 (0)