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
115 lines
3.9 KiB
C++
115 lines
3.9 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include <cstdlib>
|
|
#include <numeric>
|
|
#include <iterator>
|
|
#include <vector>
|
|
|
|
#include "ck/ck.hpp"
|
|
|
|
#include "ck/library/utility/numeric.hpp"
|
|
|
|
namespace ck {
|
|
namespace utils {
|
|
namespace conv {
|
|
|
|
struct ConvParam
|
|
{
|
|
ConvParam();
|
|
ConvParam(ck::index_t n_dim,
|
|
ck::index_t group_count,
|
|
ck::index_t n_batch,
|
|
ck::index_t n_out_channels,
|
|
ck::index_t n_in_channels,
|
|
const std::vector<ck::index_t>& filters_len,
|
|
const std::vector<ck::index_t>& input_len,
|
|
const std::vector<ck::index_t>& strides,
|
|
const std::vector<ck::index_t>& dilations,
|
|
const std::vector<ck::index_t>& left_pads,
|
|
const std::vector<ck::index_t>& right_pads);
|
|
|
|
ConvParam(ck::long_index_t n_dim,
|
|
ck::long_index_t group_count,
|
|
ck::long_index_t n_batch,
|
|
ck::long_index_t n_out_channels,
|
|
ck::long_index_t n_in_channels,
|
|
const std::vector<ck::long_index_t>& filters_len,
|
|
const std::vector<ck::long_index_t>& input_len,
|
|
const std::vector<ck::long_index_t>& strides,
|
|
const std::vector<ck::long_index_t>& dilations,
|
|
const std::vector<ck::long_index_t>& left_pads,
|
|
const std::vector<ck::long_index_t>& right_pads);
|
|
|
|
ck::long_index_t num_dim_spatial_;
|
|
ck::long_index_t G_;
|
|
ck::long_index_t N_;
|
|
ck::long_index_t K_;
|
|
ck::long_index_t C_;
|
|
|
|
std::vector<ck::long_index_t> filter_spatial_lengths_;
|
|
std::vector<ck::long_index_t> input_spatial_lengths_;
|
|
std::vector<ck::long_index_t> output_spatial_lengths_;
|
|
|
|
std::vector<ck::long_index_t> conv_filter_strides_;
|
|
std::vector<ck::long_index_t> conv_filter_dilations_;
|
|
|
|
std::vector<ck::long_index_t> input_left_pads_;
|
|
std::vector<ck::long_index_t> input_right_pads_;
|
|
|
|
std::vector<ck::long_index_t> GetOutputSpatialLengths() const;
|
|
|
|
std::size_t GetFlops() const;
|
|
|
|
template <typename InDataType>
|
|
std::size_t GetInputByte() const
|
|
{
|
|
// sizeof(InDataType) * (G * N * C * <input spatial lengths product>) +
|
|
return sizeof(InDataType) *
|
|
(G_ * N_ * C_ *
|
|
ck::accumulate_n<std::size_t>(
|
|
std::begin(input_spatial_lengths_), num_dim_spatial_, 1, std::multiplies<>()));
|
|
}
|
|
|
|
template <typename WeiDataType>
|
|
std::size_t GetWeightByte() const
|
|
{
|
|
// sizeof(WeiDataType) * (G * K * C * <filter spatial lengths product>) +
|
|
return sizeof(WeiDataType) *
|
|
(G_ * K_ * C_ *
|
|
ck::accumulate_n<std::size_t>(
|
|
std::begin(filter_spatial_lengths_), num_dim_spatial_, 1, std::multiplies<>()));
|
|
}
|
|
|
|
template <typename OutDataType>
|
|
std::size_t GetOutputByte() const
|
|
{
|
|
// sizeof(OutDataType) * (G * N * K * <output spatial lengths product>);
|
|
return sizeof(OutDataType) * (G_ * N_ * K_ *
|
|
std::accumulate(std::begin(output_spatial_lengths_),
|
|
std::end(output_spatial_lengths_),
|
|
static_cast<std::size_t>(1),
|
|
std::multiplies<std::size_t>()));
|
|
}
|
|
|
|
template <typename InDataType, typename WeiDataType, typename OutDataType>
|
|
std::size_t GetByte() const
|
|
{
|
|
return GetInputByte<InDataType>() + GetWeightByte<WeiDataType>() +
|
|
GetOutputByte<OutDataType>();
|
|
}
|
|
};
|
|
|
|
std::string get_conv_param_parser_helper_msg();
|
|
|
|
ConvParam parse_conv_param(int num_dim_spatial, int arg_idx, char* const argv[]);
|
|
|
|
} // namespace conv
|
|
} // namespace utils
|
|
} // namespace ck
|
|
|
|
std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os,
|
|
const ck::utils::conv::ConvParam& p);
|