Skip to content

Commit

Permalink
Simplify more
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlizarraga committed Oct 12, 2023
1 parent 1567536 commit 9874186
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,12 @@ static Status GetInitializerInputData(const NodeUnitIODef& input, const QnnModel

switch (data_type) {
case ONNX_NAMESPACE::TensorProto_DataType_INT64: {
gsl::span<const int64_t> elements = qnn::utils::ReinterpretBytesAsSpan<int64_t>(initializer_bytes.data(),
initializer_bytes.size());
gsl::span<const int64_t> elements = qnn::utils::ReinterpretBytesAsSpan<int64_t>(initializer_bytes);
output.insert(output.end(), elements.begin(), elements.end());
break;
}
case ONNX_NAMESPACE::TensorProto_DataType_INT32: {
gsl::span<const int32_t> elements = qnn::utils::ReinterpretBytesAsSpan<int32_t>(initializer_bytes.data(),
initializer_bytes.size());
gsl::span<const int32_t> elements = qnn::utils::ReinterpretBytesAsSpan<int32_t>(initializer_bytes);
output.insert(output.end(), elements.begin(), elements.end());
break;
}
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/core/providers/qnn/builder/qnn_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class QnnOpConfigWrapper;

namespace utils {

// Reinterprets an array of contiguous bytes in the target's endianness to a span of elements.
// Reinterprets an array of contiguous, aligned bytes in the target's endianness to a span of elements.
template <typename T>
inline gsl::span<const T> ReinterpretBytesAsSpan(const uint8_t* data, size_t num_bytes) {
return gsl::span<const T>(reinterpret_cast<const T*>(data), num_bytes / sizeof(T));
inline gsl::span<const T> ReinterpretBytesAsSpan(gsl::span<const uint8_t> bytes_span) {
return gsl::span<const T>(reinterpret_cast<const T*>(bytes_span.data()), bytes_span.size() / sizeof(T));
}

size_t GetElementSizeByType(const Qnn_DataType_t& data_type);
Expand Down

0 comments on commit 9874186

Please sign in to comment.