fml
0.1-0
Fused Matrix Library
xpose.hh
1
// This file is part of fml which is released under the Boost Software
2
// License, Version 1.0. See accompanying file LICENSE or copy at
3
// https://www.boost.org/LICENSE_1_0.txt
4
5
#ifndef FML_GPU_LINALG_XPOSE_H
6
#define FML_GPU_LINALG_XPOSE_H
7
#pragma once
8
9
10
#include <stdexcept>
11
12
#include "../../_internals/linalgutils.hh"
13
14
#include "../arch/arch.hh"
15
16
#include "../gpumat.hh"
17
18
#include "internals/err.hh"
19
20
21
namespace
fml
22
{
23
namespace
linalg
24
{
41
template
<
typename
REAL>
42
void
xpose
(
const
gpumat<REAL>
&x,
gpumat<REAL>
&tx)
43
{
44
err::check_card(x, tx);
45
46
const
len_t m = x.
nrows
();
47
const
len_t n = x.
ncols
();
48
49
if
(m != tx.
ncols
() || n != tx.
nrows
())
50
tx.
resize
(n, m);
51
52
auto
cbh = x.get_card()->blas_handle();
53
54
gpublas_status_t check = gpublas::geam(cbh, GPUBLAS_OP_T, GPUBLAS_OP_N, n, m, (REAL)1.0, x.
data_ptr
(), m, (REAL) 0.0, tx.
data_ptr
(), n, tx.
data_ptr
(), n);
55
gpublas::err::check_ret(check,
"geam"
);
56
}
57
58
59
61
template
<
typename
REAL>
62
gpumat<REAL>
xpose
(
const
gpumat<REAL>
&x)
63
{
64
gpumat<REAL>
tx(x.get_card(), x.
ncols
(), x.
nrows
());
65
xpose
(x, tx);
66
return
tx;
67
}
68
}
69
}
70
71
72
#endif
fml::linalg::xpose
void xpose(const cpumat< REAL > &x, cpumat< REAL > &tx)
Computes the transpose out-of-place (i.e. in a copy).
Definition:
xpose.hh:37
fml::unimat::nrows
len_t nrows() const
Number of rows.
Definition:
unimat.hh:36
fml::unimat::ncols
len_t ncols() const
Number of columns.
Definition:
unimat.hh:38
fml::unimat::data_ptr
REAL * data_ptr()
Pointer to the internal array.
Definition:
unimat.hh:40
fml
Core namespace.
Definition:
dimops.hh:10
fml::gpumat::resize
void resize(len_t nrows, len_t ncols)
Resize the internal object storage.
Definition:
gpumat.hh:256
fml::gpumat
Matrix class for data held on a single GPU.
Definition:
gpumat.hh:35
fml
src
fml
gpu
linalg
xpose.hh
Generated by
1.8.17