Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions include/cudnn_frontend/cudnn_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <memory>
#include <vector>
#include <unordered_map>
#include <unordered_set>

#include "../cudnn_frontend_Tensor.h"
#include "../cudnn_frontend_Operation.h"
Expand All @@ -18,30 +19,15 @@
namespace cudnn_frontend {

namespace detail {
inline void
assign_uid(graph::Tensor_attributes* const tensor,
int64_t& potential_uid,
std::unordered_set<int64_t> const& used_uids) {
// get_next_potential_uid
while (used_uids.find(potential_uid) != used_uids.end()) {
++potential_uid;
}

tensor->set_uid(potential_uid);
++potential_uid; // increment, as used its used now
}

// TODO: Always returns OK. Can the status and error message be accessed from tensor descriptor?
inline error_t
create_cudnn_tensor(
std::shared_ptr<graph::Tensor_attributes> const& props,
std::unordered_map<graph::Tensor_attributes::uid_t, std::shared_ptr<cudnn_frontend::Tensor>>& tensors,
int64_t& potential_uid,
std::unordered_set<int64_t> const& used_uids) {
// Assign tensor a uid
if (props->has_uid() == false) {
assign_uid(props.get(), potential_uid, used_uids);
}
std::unordered_map<graph::Tensor_attributes::uid_t, std::shared_ptr<cudnn_frontend::Tensor>>& tensors) {
RETURN_CUDNN_FRONTEND_ERROR_IF(
props->has_uid() == false,
error_code_t::ATTRIBUTE_NOT_SET,
"Tensor '" + props->get_name() + "' UID not assigned before creating backend tensor.");

// Check whether backend tensor already created
auto tensor_uid = props->get_uid();
Expand Down Expand Up @@ -81,7 +67,7 @@ create_cudnn_tensor(
}

if (auto ragged_offset_props = props->get_ragged_offset()) {
CHECK_CUDNN_FRONTEND_ERROR(create_cudnn_tensor(ragged_offset_props, tensors, potential_uid, used_uids));
CHECK_CUDNN_FRONTEND_ERROR(create_cudnn_tensor(ragged_offset_props, tensors));
tensor_builder.setRaggedOffset(tensors.at(ragged_offset_props->get_uid()));
}
if (props->has_ragged_offset_multiplier()) {
Expand Down
6 changes: 3 additions & 3 deletions include/cudnn_frontend/graph_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ log_dump_tensor_content(int64_t uid,
default:
data_str = to_hex(host_buf.data(), num_elements, elem_size);
}
CUDNN_FE_LOG_LABEL_ENDL("Tensor Dump Uid: " << uid << " Name: " << name << " Data: " << data_str);
CUDNN_FE_LOG_LABEL_ENDL("Tensor Dump uid: " << uid << " Name: " << name << " Data: " << data_str);
return {error_code_t::OK, ""};
}

Expand Down Expand Up @@ -562,7 +562,7 @@ log_variant_pack_memory_type(int64_t uid, void* ptr) {
};

// clang-format off
CUDNN_FE_LOG_LABEL_ENDL("Variant Pack" << std::setw(0) << " Uid: " << std::setw(20) << uid
CUDNN_FE_LOG_LABEL_ENDL("Variant Pack" << std::setw(0) << " uid: " << std::setw(20) << uid
<< std::setw(0) << " MemoryType: " << std::setw(12) << memory_type_to_string(attributes.type)
<< std::setw(0) << " Device: " << std::setw(4) << attributes.device
<< std::setw(0) << " UnifiedPtr: " << std::setw(20) << ptr_to_string(ptr)
Expand All @@ -584,4 +584,4 @@ class cudnnGraphNotSupportedException : public std::runtime_error {
}
};

} // namespace cudnn_frontend
} // namespace cudnn_frontend
Loading