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
337d6703
Commit
337d6703
authored
Jan 31, 2023
by
fsx950223
Browse files
merge updates
parents
de43a6d8
27482328
Changes
23
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
180 additions
and
0 deletions
+180
-0
test/host_tensor/test_host_tensor.cpp
test/host_tensor/test_host_tensor.cpp
+106
-0
test/softmax/CMakeLists.txt
test/softmax/CMakeLists.txt
+3
-0
test/softmax/test_softmax_host_ref.cpp
test/softmax/test_softmax_host_ref.cpp
+71
-0
No files found.
test/host_tensor/test_host_tensor.cpp
0 → 100644
View file @
337d6703
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <vector>
#include <gtest/gtest.h>
#include "ck/ck.hpp"
#include "ck/library/utility/host_tensor.hpp"
using
namespace
ck
;
TEST
(
HostTensorTranspose
,
TestBadArugment
)
{
Tensor
<
float
>
tensor
({
13
,
7
});
EXPECT_THROW
(
tensor
.
Transpose
({
0
}),
std
::
runtime_error
);
EXPECT_THROW
(
tensor
.
Transpose
({
0
,
1
,
2
}),
std
::
runtime_error
);
}
TEST
(
HostTensorTranspose
,
Test2D
)
{
std
::
vector
<
size_t
>
lengths
=
{
13
,
7
};
std
::
vector
<
size_t
>
tlengths
=
{
7
,
13
};
Tensor
<
float
>
tensor
(
lengths
);
tensor
(
0
,
0
)
=
0.
f
;
tensor
(
3
,
4
)
=
34.
f
;
EXPECT_EQ
(
tensor
.
GetLengths
(),
lengths
);
EXPECT_EQ
(
tensor
(
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
(
3
,
4
),
34.
f
);
EXPECT_EQ
(
tensor
(
4
,
3
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
().
GetLengths
(),
tlengths
);
EXPECT_EQ
(
tensor
.
Transpose
()(
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
()(
4
,
3
),
34.
f
);
EXPECT_EQ
(
tensor
.
Transpose
()(
3
,
4
),
0.
f
);
}
TEST
(
HostTensorTranspose
,
Test3D
)
{
std
::
vector
<
size_t
>
lengths
=
{
13
,
7
,
5
};
std
::
vector
<
size_t
>
tlengths
=
{
5
,
7
,
13
};
Tensor
<
float
>
tensor
(
lengths
);
tensor
(
0
,
0
,
0
)
=
0.
f
;
tensor
(
3
,
4
,
2
)
=
342.
f
;
EXPECT_EQ
(
tensor
.
GetLengths
(),
lengths
);
EXPECT_EQ
(
tensor
(
0
,
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
(
3
,
4
,
2
),
342.
f
);
EXPECT_EQ
(
tensor
(
4
,
3
,
2
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
().
GetLengths
(),
tlengths
);
EXPECT_EQ
(
tensor
.
Transpose
()(
0
,
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
()(
2
,
4
,
3
),
342.
f
);
EXPECT_EQ
(
tensor
.
Transpose
()(
2
,
3
,
4
),
0.
f
);
}
TEST
(
HostTensorTranspose
,
Test3D_021
)
{
std
::
vector
<
size_t
>
lengths
=
{
13
,
7
,
5
};
std
::
vector
<
size_t
>
tlengths
=
{
13
,
5
,
7
};
Tensor
<
float
>
tensor
(
lengths
);
tensor
(
0
,
0
,
0
)
=
0.
f
;
tensor
(
3
,
4
,
2
)
=
342.
f
;
EXPECT_EQ
(
tensor
.
GetLengths
(),
lengths
);
EXPECT_EQ
(
tensor
(
0
,
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
(
3
,
4
,
2
),
342.
f
);
EXPECT_EQ
(
tensor
(
4
,
3
,
2
),
0.
f
);
// transpose last two dimensions
EXPECT_EQ
(
tensor
.
Transpose
({
0
,
2
,
1
}).
GetLengths
(),
tlengths
);
EXPECT_EQ
(
tensor
.
Transpose
({
0
,
2
,
1
})(
0
,
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
({
0
,
2
,
1
})(
2
,
4
,
3
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
({
0
,
2
,
1
})(
3
,
2
,
4
),
342.
f
);
EXPECT_EQ
(
tensor
.
Transpose
({
0
,
2
,
1
})(
2
,
3
,
4
),
0.
f
);
// transpose last two dimensions back again
EXPECT_EQ
(
tensor
.
Transpose
({
0
,
2
,
1
}).
Transpose
({
0
,
2
,
1
}).
GetLengths
(),
lengths
);
EXPECT_EQ
(
tensor
.
Transpose
({
0
,
2
,
1
}).
Transpose
({
0
,
2
,
1
})(
3
,
4
,
2
),
342.
f
);
}
TEST
(
HostTensorTranspose
,
TestNonpacked2D
)
{
std
::
vector
<
size_t
>
lengths
=
{
13
,
7
};
std
::
vector
<
size_t
>
strides
=
{
100
,
1
};
std
::
vector
<
size_t
>
tlengths
=
{
7
,
13
};
Tensor
<
float
>
tensor
(
lengths
,
strides
);
tensor
(
0
,
0
)
=
0.
f
;
tensor
(
3
,
4
)
=
34.
f
;
EXPECT_EQ
(
tensor
.
GetLengths
(),
lengths
);
EXPECT_EQ
(
tensor
(
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
(
3
,
4
),
34.
f
);
EXPECT_EQ
(
tensor
(
4
,
3
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
().
GetLengths
(),
tlengths
);
EXPECT_EQ
(
tensor
.
Transpose
()(
0
,
0
),
0.
f
);
EXPECT_EQ
(
tensor
.
Transpose
()(
4
,
3
),
34.
f
);
EXPECT_EQ
(
tensor
.
Transpose
()(
3
,
4
),
0.
f
);
}
test/softmax/CMakeLists.txt
View file @
337d6703
...
...
@@ -3,9 +3,12 @@ add_custom_target(test_softmax)
add_gtest_executable
(
test_softmax_rank3 test_softmax_rank3.cpp
)
add_gtest_executable
(
test_softmax_rank4 test_softmax_rank4.cpp
)
add_gtest_executable
(
test_softmax_interface test_softmax_interface.cpp
)
add_gtest_executable
(
test_softmax_host_ref test_softmax_host_ref.cpp
)
target_link_libraries
(
test_softmax_rank3 PRIVATE utility device_softmax_instance
)
target_link_libraries
(
test_softmax_rank4 PRIVATE utility device_softmax_instance
)
target_link_libraries
(
test_softmax_interface PRIVATE utility device_softmax_instance
)
target_link_libraries
(
test_softmax_host_ref PRIVATE utility
)
add_dependencies
(
test_softmax test_softmax_rank3
)
add_dependencies
(
test_softmax test_softmax_rank4
)
add_dependencies
(
test_softmax test_softmax_interface
)
add_dependencies
(
test_softmax test_softmax_host_ref
)
test/softmax/test_softmax_host_ref.cpp
0 → 100644
View file @
337d6703
This diff is collapsed.
Click to expand it.
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