Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
composable_kernel
Commits
6fc49f91
Commit
6fc49f91
authored
May 30, 2020
by
Chao Liu
Browse files
remove deprecated tensor descriptor
parent
506a823a
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
612 deletions
+33
-612
driver/include/host_tensor_generator.hpp
driver/include/host_tensor_generator.hpp
+2
-2
driver/src/conv_bwd_data_driver.cpp
driver/src/conv_bwd_data_driver.cpp
+8
-8
driver/src/conv_bwd_data_driver.cu
driver/src/conv_bwd_data_driver.cu
+1
-290
driver/src/conv_bwd_data_driver.cu
driver/src/conv_bwd_data_driver.cu
+1
-290
driver/src/conv_driver.cpp
driver/src/conv_driver.cpp
+12
-13
driver/src/host_tensor.cpp
driver/src/host_tensor.cpp
+9
-9
No files found.
driver/include/tensor_generator.hpp
→
driver/include/
host_
tensor_generator.hpp
View file @
6fc49f91
#ifndef TENSOR_GENERATOR_HPP
#ifndef
HOST_
TENSOR_GENERATOR_HPP
#define TENSOR_GENERATOR_HPP
#define
HOST_
TENSOR_GENERATOR_HPP
#include "config.hpp"
#include "config.hpp"
...
...
driver/src/conv_bwd_data_driver.cpp
View file @
6fc49f91
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include "print_array.hpp"
#include "print_array.hpp"
#include "print_sequence.hpp"
#include "print_sequence.hpp"
#include "device.hpp"
#include "device.hpp"
#include "tensor_generator.hpp"
#include "
host_
tensor_generator.hpp"
#include "device_tensor.hpp"
#include "device_tensor.hpp"
#include "conv_common.hpp"
#include "conv_common.hpp"
#include "host_conv_bwd_data.hpp"
#include "host_conv_bwd_data.hpp"
...
@@ -209,19 +209,19 @@ int main(int argc, char* argv[])
...
@@ -209,19 +209,19 @@ int main(int argc, char* argv[])
constexpr
auto
out_nkhw_desc
=
get_convolution_output_default_4d_tensor_descriptor
(
constexpr
auto
out_nkhw_desc
=
get_convolution_output_default_4d_tensor_descriptor
(
in_nchw_desc
,
wei_kcyx_desc
,
ConvStrides
{},
ConvDilations
{},
LeftPads
{},
RightPads
{});
in_nchw_desc
,
wei_kcyx_desc
,
ConvStrides
{},
ConvDilations
{},
LeftPads
{},
RightPads
{});
ostream_
ConstantT
ensor
D
escriptor
(
in_nchw_desc
,
std
::
cout
<<
"in_nchw_desc: "
);
ostream_
t
ensor
_d
escriptor
(
in_nchw_desc
,
std
::
cout
<<
"in_nchw_desc: "
);
ostream_
ConstantT
ensor
D
escriptor
(
wei_kcyx_desc
,
std
::
cout
<<
"wei_kcyx_desc: "
);
ostream_
t
ensor
_d
escriptor
(
wei_kcyx_desc
,
std
::
cout
<<
"wei_kcyx_desc: "
);
ostream_
ConstantT
ensor
D
escriptor
(
out_nkhw_desc
,
std
::
cout
<<
"out_nkhw_desc: "
);
ostream_
t
ensor
_d
escriptor
(
out_nkhw_desc
,
std
::
cout
<<
"out_nkhw_desc: "
);
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"RightPads"
,
RightPads
{});
print_sequence
(
"RightPads"
,
RightPads
{});
print_sequence
(
"ConvStrides"
,
ConvStrides
{});
print_sequence
(
"ConvStrides"
,
ConvStrides
{});
print_sequence
(
"ConvDilations"
,
ConvDilations
{});
print_sequence
(
"ConvDilations"
,
ConvDilations
{});
Tensor
<
float
>
in_nchw_device
(
make_TensorDescriptor
(
in_nchw_desc
));
Tensor
<
float
>
in_nchw_device
(
make_
Host
TensorDescriptor
(
in_nchw_desc
));
Tensor
<
float
>
in_nchw_host
(
make_TensorDescriptor
(
in_nchw_desc
));
Tensor
<
float
>
in_nchw_host
(
make_
Host
TensorDescriptor
(
in_nchw_desc
));
Tensor
<
float
>
wei_kcyx
(
make_TensorDescriptor
(
wei_kcyx_desc
));
Tensor
<
float
>
wei_kcyx
(
make_
Host
TensorDescriptor
(
wei_kcyx_desc
));
Tensor
<
float
>
out_nkhw
(
make_TensorDescriptor
(
out_nkhw_desc
));
Tensor
<
float
>
out_nkhw
(
make_
Host
TensorDescriptor
(
out_nkhw_desc
));
std
::
size_t
num_thread
=
std
::
thread
::
hardware_concurrency
();
std
::
size_t
num_thread
=
std
::
thread
::
hardware_concurrency
();
...
...
driver/src/conv_bwd_data_driver.cu
deleted
100644 → 0
View file @
506a823a
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include <stdlib.h>
#include "config.hpp"
#include "tensor_descriptor.hpp"
#include "tensor_descriptor_helper.hpp"
#include "print_array.hpp"
#include "print_sequence.hpp"
#include "device.hpp"
#include "tensor_generator.hpp"
#include "device_tensor.hpp"
#include "conv_common.hpp"
#include "host_conv_bwd_data.hpp"
#include "device_convolution_backward_data_implicit_gemm_v1r1_nchw_kcyx_nkhw.hpp"
#include "device_convolution_backward_data_implicit_gemm_v1r2_nchw_kcyx_nkhw.hpp"
#include "device_convolution_backward_data_implicit_gemm_v2r1_nchw_kcyx_nkhw.hpp"
#include "device_convolution_backward_data_implicit_gemm_v3r1_nchw_kcyx_nkhw.hpp"
#include "device_convolution_backward_data_implicit_gemm_v4r1_nchw_kcyx_nkhw.hpp"
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
launcher
;
#if 0
constexpr index_t N = 64;
constexpr index_t C = 256;
constexpr index_t HI = 56;
constexpr index_t WI = 56;
constexpr index_t K = 256;
constexpr index_t Y = 1;
constexpr index_t X = 1;
using ConvStrides = Sequence<1, 1>;
using ConvDilations = Sequence<1, 1>;
using LeftPads = Sequence<0, 0>;
using RightPads = Sequence<0, 0>;
#elif
0
// 3x3, 34x34
constexpr
index_t
N
=
64
;
constexpr
index_t
C
=
256
;
constexpr
index_t
HI
=
34
;
constexpr
index_t
WI
=
34
;
constexpr
index_t
K
=
256
;
constexpr
index_t
Y
=
3
;
constexpr
index_t
X
=
3
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
0
>
;
using
RightPads
=
Sequence
<
0
,
0
>
;
#elif 0
// 3x3, 28x28
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
1024
;
constexpr
index_t
HI
=
28
;
constexpr
index_t
WI
=
28
;
constexpr
index_t
K
=
1024
;
constexpr
index_t
Y
=
3
;
constexpr
index_t
X
=
3
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
1
,
1
>
;
using
RightPads
=
Sequence
<
1
,
1
>
;
#elif 0
// 1x1 filter, 8x8 image
constexpr
index_t
N
=
256
;
constexpr
index_t
C
=
1024
;
constexpr
index_t
HI
=
8
;
constexpr
index_t
WI
=
8
;
constexpr
index_t
K
=
1024
;
constexpr
index_t
Y
=
1
;
constexpr
index_t
X
=
1
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
0
>
;
using
RightPads
=
Sequence
<
0
,
0
>
;
#elif 0
// 1x1 filter, 7x7 image
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
1024
;
constexpr
index_t
HI
=
7
;
constexpr
index_t
WI
=
7
;
constexpr
index_t
K
=
1024
;
constexpr
index_t
Y
=
1
;
constexpr
index_t
X
=
1
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
0
>
;
using
RightPads
=
Sequence
<
0
,
0
>
;
#elif 0
// 1x1 filter, 14x14 image
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
512
;
constexpr
index_t
HI
=
14
;
constexpr
index_t
WI
=
14
;
constexpr
index_t
K
=
128
;
constexpr
index_t
Y
=
1
;
constexpr
index_t
X
=
1
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
0
>
;
using
RightPads
=
Sequence
<
0
,
0
>
;
#elif 0
// 1x1 filter, 28x28 image
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
128
;
constexpr
index_t
HI
=
28
;
constexpr
index_t
WI
=
28
;
constexpr
index_t
K
=
128
;
constexpr
index_t
Y
=
1
;
constexpr
index_t
X
=
1
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
0
>
;
using
RightPads
=
Sequence
<
0
,
0
>
;
#elif 0
// 1x1 filter, 17x17 input
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
1024
;
constexpr
index_t
HI
=
17
;
constexpr
index_t
WI
=
17
;
constexpr
index_t
K
=
1024
;
constexpr
index_t
Y
=
1
;
constexpr
index_t
X
=
1
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
0
>
;
using
RightPads
=
Sequence
<
0
,
0
>
;
#elif 0
// 5x5 filter, 2x2 pad, 7x7 input
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
1024
;
constexpr
index_t
HI
=
7
;
constexpr
index_t
WI
=
7
;
constexpr
index_t
K
=
1024
;
constexpr
index_t
Y
=
5
;
constexpr
index_t
X
=
5
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
2
,
2
>
;
using
RightPads
=
Sequence
<
2
,
2
>
;
#elif 0
// 1x7 filter, 0x3 pad, 17x17 input
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
128
;
constexpr
index_t
HI
=
17
;
constexpr
index_t
WI
=
17
;
constexpr
index_t
K
=
128
;
constexpr
index_t
Y
=
1
;
constexpr
index_t
X
=
7
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
3
>
;
using
RightPads
=
Sequence
<
0
,
3
>
;
#elif 0
// 7x1 filter, 3x0 pad, 17x17 input
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
1024
;
constexpr
index_t
HI
=
17
;
constexpr
index_t
WI
=
17
;
constexpr
index_t
K
=
1024
;
constexpr
index_t
Y
=
7
;
constexpr
index_t
X
=
1
;
using
ConvStrides
=
Sequence
<
1
,
1
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
3
,
0
>
;
using
RightPads
=
Sequence
<
3
,
0
>
;
#elif 1
// 3x3 filter, 2x2 stride, 35x35 input, 17x17 output
constexpr
index_t
N
=
128
;
constexpr
index_t
C
=
128
;
constexpr
index_t
HI
=
35
;
constexpr
index_t
WI
=
35
;
constexpr
index_t
K
=
1024
;
constexpr
index_t
Y
=
3
;
constexpr
index_t
X
=
3
;
using
ConvStrides
=
Sequence
<
2
,
2
>
;
using
ConvDilations
=
Sequence
<
1
,
1
>
;
using
LeftPads
=
Sequence
<
0
,
0
>
;
using
RightPads
=
Sequence
<
0
,
0
>
;
#endif
constexpr
auto
in_nchw_desc
=
make_native_tensor_descriptor_packed
(
Sequence
<
N
,
C
,
HI
,
WI
>
{});
constexpr
auto
wei_kcyx_desc
=
make_native_tensor_descriptor_packed
(
Sequence
<
K
,
C
,
Y
,
X
>
{});
constexpr
auto
out_nkhw_desc
=
get_convolution_output_default_4d_tensor_descriptor
(
in_nchw_desc
,
wei_kcyx_desc
,
ConvStrides
{},
ConvDilations
{},
LeftPads
{},
RightPads
{});
ostream_ConstantTensorDescriptor
(
in_nchw_desc
,
std
::
cout
<<
"in_nchw_desc: "
);
ostream_ConstantTensorDescriptor
(
wei_kcyx_desc
,
std
::
cout
<<
"wei_kcyx_desc: "
);
ostream_ConstantTensorDescriptor
(
out_nkhw_desc
,
std
::
cout
<<
"out_nkhw_desc: "
);
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"RightPads"
,
RightPads
{});
print_sequence
(
"ConvStrides"
,
ConvStrides
{});
print_sequence
(
"ConvDilations"
,
ConvDilations
{});
Tensor
<
float
>
in_nchw_device
(
make_TensorDescriptor
(
in_nchw_desc
));
Tensor
<
float
>
in_nchw_host
(
make_TensorDescriptor
(
in_nchw_desc
));
Tensor
<
float
>
wei_kcyx
(
make_TensorDescriptor
(
wei_kcyx_desc
));
Tensor
<
float
>
out_nkhw
(
make_TensorDescriptor
(
out_nkhw_desc
));
std
::
size_t
num_thread
=
std
::
thread
::
hardware_concurrency
();
if
(
argc
!=
3
)
{
printf
(
"arg1: do_verification, arg2: nrepeat
\n
"
);
exit
(
1
);
}
bool
do_verification
=
atoi
(
argv
[
1
]);
std
::
size_t
nrepeat
=
atoi
(
argv
[
2
]);
if
(
do_verification
)
{
#if 0
wei_kcyx.GenerateTensorValue(GeneratorTensor_1{1}, num_thread);
out_nkhw.GenerateTensorValue(GeneratorTensor_1{1}, num_thread);
#else
wei_kcyx
.
GenerateTensorValue
(
GeneratorTensor_2
{
-
5
,
5
},
num_thread
);
out_nkhw
.
GenerateTensorValue
(
GeneratorTensor_2
{
-
5
,
5
},
num_thread
);
#endif
}
#if 0
device_convolution_backward_data_implicit_gemm_v1r1_nchw_kcyx_nkhw
#elif
0
device_convolution_backward_data_implicit_gemm_v1r2_nchw_kcyx_nkhw
#elif 0
device_convolution_backward_data_implicit_gemm_v2r1_nchw_kcyx_nkhw
#elif 0
device_convolution_backward_data_implicit_gemm_v3r1_nchw_kcyx_nkhw
#elif 1
device_convolution_backward_data_implicit_gemm_v4r1_nchw_kcyx_nkhw
#endif
(
in_nchw_desc
,
in_nchw_device
,
wei_kcyx_desc
,
wei_kcyx
,
out_nkhw_desc
,
out_nkhw
,
ConvStrides
{},
ConvDilations
{},
LeftPads
{},
RightPads
{},
nrepeat
);
if
(
do_verification
)
{
host_direct_convolution_backward_data
(
in_nchw_host
,
wei_kcyx
,
out_nkhw
,
ConvStrides
{},
ConvDilations
{},
LeftPads
{},
RightPads
{});
check_error
(
in_nchw_host
,
in_nchw_device
);
#if 0
LogRange(std::cout << "out_nkhw : ", out_nkhw.mData, ",") << std::endl;
LogRange(std::cout << "wei_kcyx : ", wei_kcyx.mData, ",") << std::endl;
LogRange(std::cout << "in_nchw_host : ", in_nchw_host.mData, ",") << std::endl;
LogRange(std::cout << "in_nchw_device : ", in_nchw_device.mData, ",") << std::endl;
#endif
}
}
driver/src/conv_bwd_data_driver.cu
0 → 120000
View file @
6fc49f91
conv_bwd_data_driver
.
cpp
\ No newline at end of file
driver/src/conv_driver.cpp
View file @
6fc49f91
#include <iostream>
#include <numeric>
#include <numeric>
#include <initializer_list>
#include <initializer_list>
#include <cstdlib>
#include <cstdlib>
#include <stdlib.h>
#include <stdlib.h>
#include <half.hpp>
#include <half.hpp>
#include "config.hpp"
#include "config.hpp"
#include "ConstantTensorDescriptor_deprecated.hpp"
#include "print_array.hpp"
#include "print_array.hpp"
#include "print_sequence.hpp"
#include "print_sequence.hpp"
#include "device.hpp"
#include "device.hpp"
#include "tensor_generator.hpp"
#include "
host_
tensor_generator.hpp"
#include "conv_common.hpp"
#include "conv_common.hpp"
#include "host_conv.hpp"
#include "host_conv.hpp"
#include "device_tensor.hpp"
#include "device_tensor.hpp"
...
@@ -505,14 +504,14 @@ int main(int argc, char* argv[])
...
@@ -505,14 +504,14 @@ int main(int argc, char* argv[])
using
RightPads
=
Sequence
<
1
,
1
>
;
using
RightPads
=
Sequence
<
1
,
1
>
;
#endif
#endif
auto
in_nchw_desc
=
make_
ConstantT
ensor
D
escriptor_packed
(
Sequence
<
N
,
C
,
HI
,
WI
>
{});
auto
in_nchw_desc
=
make_
native_t
ensor
_d
escriptor_packed
(
Sequence
<
N
,
C
,
HI
,
WI
>
{});
auto
wei_kcyx_desc
=
make_
ConstantT
ensor
D
escriptor_packed
(
Sequence
<
K
,
C
,
Y
,
X
>
{});
auto
wei_kcyx_desc
=
make_
native_t
ensor
_d
escriptor_packed
(
Sequence
<
K
,
C
,
Y
,
X
>
{});
auto
out_nkhw_desc
=
get_convolution_output_default_4d_tensor_descriptor
_deprecated
(
auto
out_nkhw_desc
=
get_convolution_output_default_4d_tensor_descriptor
(
in_nchw_desc
,
wei_kcyx_desc
,
ConvStrides
{},
ConvDilations
{},
LeftPads
{},
RightPads
{});
in_nchw_desc
,
wei_kcyx_desc
,
ConvStrides
{},
ConvDilations
{},
LeftPads
{},
RightPads
{});
ostream_
ConstantT
ensor
D
escriptor
(
in_nchw_desc
,
std
::
cout
<<
"in_nchw_desc: "
);
ostream_
t
ensor
_d
escriptor
(
in_nchw_desc
,
std
::
cout
<<
"in_nchw_desc: "
);
ostream_
ConstantT
ensor
D
escriptor
(
wei_kcyx_desc
,
std
::
cout
<<
"wei_kcyx_desc: "
);
ostream_
t
ensor
_d
escriptor
(
wei_kcyx_desc
,
std
::
cout
<<
"wei_kcyx_desc: "
);
ostream_
ConstantT
ensor
D
escriptor
(
out_nkhw_desc
,
std
::
cout
<<
"out_nkhw_desc: "
);
ostream_
t
ensor
_d
escriptor
(
out_nkhw_desc
,
std
::
cout
<<
"out_nkhw_desc: "
);
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"LeftPads"
,
LeftPads
{});
print_sequence
(
"RightPads"
,
RightPads
{});
print_sequence
(
"RightPads"
,
RightPads
{});
print_sequence
(
"ConvStrides"
,
ConvStrides
{});
print_sequence
(
"ConvStrides"
,
ConvStrides
{});
...
@@ -526,10 +525,10 @@ int main(int argc, char* argv[])
...
@@ -526,10 +525,10 @@ int main(int argc, char* argv[])
using
out_data_t
=
half_float
::
half
;
using
out_data_t
=
half_float
::
half
;
#endif
#endif
Tensor
<
in_data_t
>
in_nchw
(
make_TensorDescriptor
(
in_nchw_desc
));
Tensor
<
in_data_t
>
in_nchw
(
make_
Host
TensorDescriptor
(
in_nchw_desc
));
Tensor
<
in_data_t
>
wei_kcyx
(
make_TensorDescriptor
(
wei_kcyx_desc
));
Tensor
<
in_data_t
>
wei_kcyx
(
make_
Host
TensorDescriptor
(
wei_kcyx_desc
));
Tensor
<
out_data_t
>
out_nkhw_host
(
make_TensorDescriptor
(
out_nkhw_desc
));
Tensor
<
out_data_t
>
out_nkhw_host
(
make_
Host
TensorDescriptor
(
out_nkhw_desc
));
Tensor
<
out_data_t
>
out_nkhw_device
(
make_TensorDescriptor
(
out_nkhw_desc
));
Tensor
<
out_data_t
>
out_nkhw_device
(
make_
Host
TensorDescriptor
(
out_nkhw_desc
));
std
::
size_t
num_thread
=
std
::
thread
::
hardware_concurrency
();
std
::
size_t
num_thread
=
std
::
thread
::
hardware_concurrency
();
...
...
driver/src/tensor.cpp
→
driver/src/
host_
tensor.cpp
View file @
6fc49f91
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <cassert>
#include <cassert>
#include "tensor.hpp"
#include "
host_
tensor.hpp"
template
<
typename
X
>
template
<
typename
X
>
TensorDescriptor
::
TensorDescriptor
(
std
::
vector
<
X
>
lens
)
:
mLens
(
lens
)
Host
TensorDescriptor
::
Host
TensorDescriptor
(
std
::
vector
<
X
>
lens
)
:
mLens
(
lens
)
{
{
this
->
CalculateStrides
();
this
->
CalculateStrides
();
}
}
template
<
typename
X
,
typename
Y
>
template
<
typename
X
,
typename
Y
>
TensorDescriptor
::
TensorDescriptor
(
std
::
vector
<
X
>
lens
,
std
::
vector
<
Y
>
strides
)
Host
TensorDescriptor
::
Host
TensorDescriptor
(
std
::
vector
<
X
>
lens
,
std
::
vector
<
Y
>
strides
)
:
mLens
(
lens
),
mStrides
(
strides
)
:
mLens
(
lens
),
mStrides
(
strides
)
{
{
}
}
void
TensorDescriptor
::
CalculateStrides
()
void
Host
TensorDescriptor
::
CalculateStrides
()
{
{
mStrides
.
clear
();
mStrides
.
clear
();
mStrides
.
resize
(
mLens
.
size
(),
0
);
mStrides
.
resize
(
mLens
.
size
(),
0
);
...
@@ -27,21 +27,21 @@ void TensorDescriptor::CalculateStrides()
...
@@ -27,21 +27,21 @@ void TensorDescriptor::CalculateStrides()
mLens
.
rbegin
(),
mLens
.
rend
()
-
1
,
mStrides
.
rbegin
()
+
1
,
std
::
multiplies
<
std
::
size_t
>
());
mLens
.
rbegin
(),
mLens
.
rend
()
-
1
,
mStrides
.
rbegin
()
+
1
,
std
::
multiplies
<
std
::
size_t
>
());
}
}
std
::
size_t
TensorDescriptor
::
GetNumOfDimension
()
const
{
return
mLens
.
size
();
}
std
::
size_t
Host
TensorDescriptor
::
GetNumOfDimension
()
const
{
return
mLens
.
size
();
}
std
::
size_t
TensorDescriptor
::
GetElementSize
()
const
std
::
size_t
Host
TensorDescriptor
::
GetElementSize
()
const
{
{
assert
(
mLens
.
size
()
==
mStrides
.
size
());
assert
(
mLens
.
size
()
==
mStrides
.
size
());
return
std
::
accumulate
(
return
std
::
accumulate
(
mLens
.
begin
(),
mLens
.
end
(),
std
::
size_t
{
1
},
std
::
multiplies
<
std
::
size_t
>
());
mLens
.
begin
(),
mLens
.
end
(),
std
::
size_t
{
1
},
std
::
multiplies
<
std
::
size_t
>
());
}
}
std
::
size_t
TensorDescriptor
::
GetElementSpace
()
const
std
::
size_t
Host
TensorDescriptor
::
GetElementSpace
()
const
{
{
auto
ls
=
mLens
|
boost
::
adaptors
::
transformed
([](
std
::
size_t
v
)
{
return
v
-
1
;
});
auto
ls
=
mLens
|
boost
::
adaptors
::
transformed
([](
std
::
size_t
v
)
{
return
v
-
1
;
});
return
std
::
inner_product
(
ls
.
begin
(),
ls
.
end
(),
mStrides
.
begin
(),
std
::
size_t
{
0
})
+
1
;
return
std
::
inner_product
(
ls
.
begin
(),
ls
.
end
(),
mStrides
.
begin
(),
std
::
size_t
{
0
})
+
1
;
}
}
const
std
::
vector
<
std
::
size_t
>&
TensorDescriptor
::
GetLengths
()
const
{
return
mLens
;
}
const
std
::
vector
<
std
::
size_t
>&
Host
TensorDescriptor
::
GetLengths
()
const
{
return
mLens
;
}
const
std
::
vector
<
std
::
size_t
>&
TensorDescriptor
::
GetStrides
()
const
{
return
mStrides
;
}
const
std
::
vector
<
std
::
size_t
>&
Host
TensorDescriptor
::
GetStrides
()
const
{
return
mStrides
;
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment