Files
TheRock/rocm-libraries/projects/hipdnn/frontend/include/hipdnn_frontend/detail/ResampleFwdUnpacker.hpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

130 lines
4.8 KiB
C++

// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
#include <hipdnn_frontend/Types.hpp>
#include <hipdnn_frontend/attributes/ResampleFwdAttributes.hpp>
#include <hipdnn_frontend/detail/DescriptorUnpackHelpers.hpp>
#include <memory>
#include <optional>
#include <unordered_map>
namespace hipdnn_frontend::detail
{
[[nodiscard]] inline Error unpackResampleFwdOperation(
hipdnnBackendDescriptor_t opDesc,
std::unordered_map<int64_t, std::shared_ptr<graph::TensorAttributes>>& tensorMap,
graph::ResampleFwdAttributes& attributes)
{
// Unpack x tensor
std::shared_ptr<graph::TensorAttributes> xTensor;
HIPDNN_CHECK_ERROR(unpackAndRegisterTensor(
opDesc, HIPDNN_ATTR_OPERATION_RESAMPLE_FWD_XDESC, tensorMap, xTensor, "resample X tensor"));
attributes.set_x(xTensor);
// Unpack y tensor
std::shared_ptr<graph::TensorAttributes> yTensor;
HIPDNN_CHECK_ERROR(unpackAndRegisterTensor(
opDesc, HIPDNN_ATTR_OPERATION_RESAMPLE_FWD_YDESC, tensorMap, yTensor, "resample Y tensor"));
attributes.set_y(yTensor);
// Unpack index tensor
std::shared_ptr<graph::TensorAttributes> indexTensor;
HIPDNN_CHECK_ERROR(unpackOptionalTensor(opDesc,
HIPDNN_ATTR_OPERATION_RESAMPLE_FWD_IDXDESC,
tensorMap,
indexTensor,
"resample INDEX tensor"));
if(indexTensor)
{
attributes.set_index(indexTensor);
}
// Unpack pre_padding
std::vector<int64_t> prePadding;
HIPDNN_CHECK_ERROR(getDescriptorAttrVec(
opDesc, HIPDNN_ATTR_RESAMPLE_PRE_PADDINGS, prePadding, "resample pre_padding"));
attributes.set_pre_padding(std::move(prePadding));
// Unpack post_padding
std::vector<int64_t> postPadding;
HIPDNN_CHECK_ERROR(getDescriptorAttrVec(
opDesc, HIPDNN_ATTR_RESAMPLE_POST_PADDINGS, postPadding, "resample post_padding"));
attributes.set_post_padding(std::move(postPadding));
// Unpack stride
std::vector<int64_t> stride;
HIPDNN_CHECK_ERROR(
getDescriptorAttrVec(opDesc, HIPDNN_ATTR_RESAMPLE_STRIDES, stride, "resample stride"));
attributes.set_stride(std::move(stride));
// Unpack window
std::vector<int64_t> window;
HIPDNN_CHECK_ERROR(
getDescriptorAttrVec(opDesc, HIPDNN_ATTR_RESAMPLE_WINDOW_DIMS, window, "resample window"));
attributes.set_window(std::move(window));
// Unpack resample_mode
hipdnnResampleMode_t resampleMode{};
HIPDNN_CHECK_ERROR(getDescriptorAttrScalar(opDesc,
HIPDNN_ATTR_RESAMPLE_MODE,
HIPDNN_TYPE_RESAMPLE_MODE,
resampleMode,
"resample resample_mode"));
auto [resampleModeResult, resampleModeErr] = fromHipdnnResampleMode(resampleMode);
if(resampleModeErr.is_bad())
{
return resampleModeErr;
}
attributes.set_resample_mode(resampleModeResult);
// Unpack padding_mode
hipdnnPaddingMode_t paddingMode{};
HIPDNN_CHECK_ERROR(getDescriptorAttrScalar(opDesc,
HIPDNN_ATTR_RESAMPLE_PADDING_MODE,
HIPDNN_TYPE_PADDING_MODE,
paddingMode,
"resample padding_mode"));
auto [paddingModeResult, paddingModeErr] = fromHipdnnPaddingMode(paddingMode);
if(paddingModeErr.is_bad())
{
return paddingModeErr;
}
attributes.set_padding_mode(paddingModeResult);
// Unpack generate_index (optional)
{
std::optional<bool> generateIndex;
HIPDNN_CHECK_ERROR(getDescriptorAttrOptionalScalar(opDesc,
HIPDNN_ATTR_RESAMPLE_GENERATE_INDEX_EXT,
HIPDNN_TYPE_BOOLEAN,
generateIndex,
"resample generate_index"));
if(generateIndex.has_value())
{
attributes.set_generate_index(*generateIndex);
}
}
// Unpack operation name
std::string opName;
HIPDNN_CHECK_ERROR(
getDescriptorAttrString(opDesc, HIPDNN_ATTR_OPERATION_NAME_EXT, opName, "operation name"));
attributes.set_name(opName);
// Unpack compute data type
auto [dt, dtErr]
= unpackGraphDataType(opDesc, HIPDNN_ATTR_RESAMPLE_COMP_TYPE, "resample compute data type");
if(dtErr.is_bad())
{
return dtErr;
}
attributes.set_compute_data_type(dt);
return {};
}
} // namespace hipdnn_frontend::detail