Commit 93ce856f authored by Bartlomiej Kocot's avatar Bartlomiej Kocot
Browse files

Build and style fixes

parent 0245330a
......@@ -16,7 +16,6 @@
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/numeric.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_contraction.hpp"
template <ck::index_t... Is>
......
......@@ -16,7 +16,6 @@
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/numeric.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_contraction.hpp"
template <ck::index_t... Is>
......
......@@ -16,7 +16,6 @@
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/numeric.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_contraction.hpp"
template <ck::index_t... Is>
......
......@@ -16,7 +16,6 @@
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/numeric.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_contraction.hpp"
template <ck::index_t... Is>
......
......@@ -11,9 +11,7 @@
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
using Bilinear = ck::tensor_operation::element_wise::Bilinear;
using Scale = ck::tensor_operation::element_wise::Scale;
using PassThrough = ck::tensor_operation::element_wise::PassThrough;
using Bilinear = ck::tensor_operation::element_wise::Bilinear;
namespace ck {
namespace tensor_operation {
......@@ -87,14 +85,14 @@ struct ReferenceContraction_M2_N2_K2 : public ck::tensor_operation::device::Base
float Run(const Argument& arg)
{
auto f_ms_ns = [&](auto m0, auto m1, auto n0, auto n1) {
const int K0 = arg.a_ms_ks_.mDesc.GetLengths()[2];
const int K1 = arg.a_ms_ks_.mDesc.GetLengths()[3];
const ck::index_t K0 = arg.a_ms_ks_.mDesc.GetLengths()[2];
const ck::index_t K1 = arg.a_ms_ks_.mDesc.GetLengths()[3];
AccDataType v_acc = 0;
for(int k0 = 0; k0 < K0; ++k0)
for(ck::index_t k0 = 0; k0 < K0; ++k0)
{
for(int k1 = 0; k1 < K1; ++k1)
for(ck::index_t k1 = 0; k1 < K1; ++k1)
{
AccDataType v_a;
AccDataType v_b;
......
......@@ -16,27 +16,29 @@
#include "ck/library/tensor_operation_instance/gpu/contraction_bilinear.hpp"
#include "ck/library/tensor_operation_instance/gpu/contraction_scale.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_contraction.hpp"
#include "ck/host_utility/io.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_contraction.hpp"
namespace ck {
namespace profiler {
using Bilinear = ck::tensor_operation::element_wise::Bilinear;
using Scale = ck::tensor_operation::element_wise::Scale;
template <typename ALayout,
typename BLayout,
typename CDLayout,
typename DataType,
typename DTupleDataType,
typename CDElementOp>
int profile_contraction_impl(int do_verification,
int init_method,
int profile_contraction_impl(ck::index_t do_verification,
ck::index_t init_method,
bool do_log,
bool time_kernel,
CDElementOp cd_element_op,
......@@ -53,8 +55,6 @@ int profile_contraction_impl(int do_verification,
auto f_host_tensor_descriptor = [](const std::vector<ck::index_t>& dims01,
const std::vector<ck::index_t>& dims23,
const std::vector<ck::index_t>& strides) {
using namespace ck::literals;
std::vector<std::size_t> dims_szt(dims01.begin(), dims01.end());
dims_szt.insert(dims_szt.end(), dims23.begin(), dims23.end());
std::vector<std::size_t> strides_szt(strides.begin(), strides.end());
......@@ -97,6 +97,7 @@ int profile_contraction_impl(int do_verification,
a_device_buf.ToDevice(a_m_k.mData.data());
b_device_buf.ToDevice(b_k_n.mData.data());
c_device_buf.SetZero();
d_device_buf.ToDevice(d_m_n.mData.data());
const std::vector<index_t> a_ms_ks_lengths = {M[0], M[1], K[0], K[1]};
......@@ -107,8 +108,8 @@ int profile_contraction_impl(int do_verification,
const auto a_element_op = AElementOp{};
const auto b_element_op = BElementOp{};
constexpr int NumDim = 2;
using DeviceOp = ck::tensor_operation::device::DeviceContractionMultipleD<NumDim,
constexpr ck::index_t NumDim = 2;
using DeviceOp = ck::tensor_operation::device::DeviceContractionMultipleD<NumDim,
NumDim,
NumDim,
DataType,
......
......@@ -59,10 +59,10 @@ static void print_helper_msg()
void collect_index_params(char* argv[],
std::vector<ck::index_t>& params,
const int from,
const int num)
const ck::index_t from,
const ck::index_t num)
{
for(int p = from; p < from + num; p++)
for(ck::index_t p = from; p < from + num; p++)
params.push_back(std::stoi(argv[p]));
}
......@@ -94,19 +94,19 @@ int profile_contraction(int argc, char* argv[])
exit(1);
}
const auto data_type = static_cast<ContractionDataType>(std::stoi(argv[2]));
const auto layout = static_cast<ContractionMatrixLayout>(std::stoi(argv[3]));
const bool do_verification = std::stoi(argv[4]);
const int init_method = std::stoi(argv[5]);
const bool do_log = std::stoi(argv[6]);
const bool time_kernel = std::stoi(argv[7]);
const float alpha = std::stof(argv[8]);
const float beta = with_bilinear ? std::stof(argv[9]) : 0;
const auto data_type = static_cast<ContractionDataType>(std::stoi(argv[2]));
const auto layout = static_cast<ContractionMatrixLayout>(std::stoi(argv[3]));
const bool do_verification = std::stoi(argv[4]);
const ck::index_t init_method = std::stoi(argv[5]);
const bool do_log = std::stoi(argv[6]);
const bool time_kernel = std::stoi(argv[7]);
const float alpha = std::stof(argv[8]);
const float beta = with_bilinear ? std::stof(argv[9]) : 0;
std::vector<ck::index_t> M;
std::vector<ck::index_t> N;
std::vector<ck::index_t> K;
const int dims_arg_num = with_bilinear ? 10 : 9;
const ck::index_t dims_arg_num = with_bilinear ? 10 : 9;
collect_index_params(argv, M, dims_arg_num, 2);
collect_index_params(argv, N, dims_arg_num + 2, 2);
collect_index_params(argv, K, dims_arg_num + 4, 2);
......
......@@ -57,13 +57,13 @@ class TestContraction : public ::testing::Test
{16384, 1024, 32, 1},
{16384, 1024, 32, 1}}};
std::vector<int> init_methods = {0, 1, 2};
std::unique_ptr<CDElementOp> cd_element_op_ptr;
std::vector<ck::index_t> init_methods = {0, 1, 2};
std::unique_ptr<CDElementOp> p_cd_element_op;
void Run()
{
for(auto& memory_params : list_of_memory_params)
{
for(const int init_method : init_methods)
for(const ck::index_t init_method : init_methods)
{
bool pass =
ck::profiler::profile_contraction_impl<ALayout,
......@@ -75,7 +75,7 @@ class TestContraction : public ::testing::Test
init_method,
false /*do_logs*/,
false /*time_kernel*/,
*cd_element_op_ptr,
*p_cd_element_op,
memory_params.M,
memory_params.N,
memory_params.K,
......@@ -104,35 +104,35 @@ using BilinearKernelTypes =
std::tuple<Row, Col, Row, F32, ck::Tuple<F32>, Bilinear>,
std::tuple<Col, Row, Row, F32, ck::Tuple<F32>, Bilinear>,
std::tuple<Col, Col, Row, F32, ck::Tuple<F32>, Bilinear>,
std::tuple<Row, Row, Row, F64, Bilinear>,
std::tuple<Row, Col, Row, F64, Bilinear>,
std::tuple<Col, Row, Row, F64, Bilinear>,
std::tuple<Col, Col, Row, F64, Bilinear>>;
std::tuple<Row, Row, Row, F64, ck::Tuple<F32>, Bilinear>,
std::tuple<Row, Col, Row, F64, ck::Tuple<F32>, Bilinear>,
std::tuple<Col, Row, Row, F64, ck::Tuple<F32>, Bilinear>,
std::tuple<Col, Col, Row, F64, ck::Tuple<F32>, Bilinear>>;
using ScaleKernelTypes = ::testing::Types<std::tuple<Row, Row, Row, F32, ck::Tuple<>, Scale>,
std::tuple<Row, Col, Row, F32, ck::Tuple<>, Scale>,
std::tuple<Col, Row, Row, F32, ck::Tuple<>, Scale>,
std::tuple<Col, Col, Row, F32, ck::Tuple<>, Scale>,
std::tuple<Row, Row, Row, F64, Scale>,
std::tuple<Row, Col, Row, F64, Scale>,
std::tuple<Col, Row, Row, F64, Scale>,
std::tuple<Col, Col, Row, F64, Scale>>;
std::tuple<Row, Row, Row, F64, ck::Tuple<>, Scale>,
std::tuple<Row, Col, Row, F64, ck::Tuple<>, Scale>,
std::tuple<Col, Row, Row, F64, ck::Tuple<>, Scale>,
std::tuple<Col, Col, Row, F64, ck::Tuple<>, Scale>>;
TYPED_TEST_SUITE(TestContractionBilinear, BilinearKernelTypes);
TYPED_TEST_SUITE(TestContractionScale, ScaleKernelTypes);
TYPED_TEST(TestContractionBilinear, bilinear)
{
this->cd_element_op_ptr = std::make_unique<Bilinear>(1.f, 1.f);
this->p_cd_element_op = std::make_unique<Bilinear>(1.f, 1.f);
this->Run();
this->cd_element_op_ptr = std::make_unique<Bilinear>(0.5f, 0.5f);
this->p_cd_element_op = std::make_unique<Bilinear>(0.5f, 0.5f);
this->Run();
}
TYPED_TEST(TestContractionScale, scale)
{
this->cd_element_op_ptr = std::make_unique<Scale>(1.f);
this->p_cd_element_op = std::make_unique<Scale>(1.f);
this->Run();
this->cd_element_op_ptr = std::make_unique<Scale>(0.5f);
this->p_cd_element_op = std::make_unique<Scale>(0.5f);
this->Run();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment