-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ef6ee6
commit cbf9348
Showing
16 changed files
with
354 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
orttraining/orttraining/test/training_ops/cuda/flatten_and_unpad_test.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "test/common/tensor_op_test_utils.h" | ||
#include "test/providers/provider_test_utils.h" | ||
|
||
namespace onnxruntime { | ||
namespace test { | ||
|
||
#if defined(USE_CUDA) || defined(USE_ROCM) | ||
|
||
TEST(FlattenAndUnpadTest, FloatType1D) { | ||
std::vector<float> input = {1.0f, 1.0f, 3.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, | ||
0.0f, 5.0f, 0.0f, 6.0f, 0.0f, 0.0f, 0.0f}; | ||
std::vector<int64_t> indices = {1, 3, 5, 7, 9, 11}; | ||
|
||
std::vector<float> output = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.f}; | ||
std::vector<int64_t> unflatten_dims = {5, 3}; | ||
|
||
OpTester test("FlattenAndUnpad", 1, onnxruntime::kMSDomain); | ||
test.AddInput<float>("input", {5, 3}, input); | ||
test.AddInput<int64_t>("indices", {6}, indices); | ||
test.AddOutput<float>("output", {6}, output); | ||
test.AddOutput<int64_t>("unflatten_dims", {2}, unflatten_dims); | ||
test.Run(); | ||
} | ||
|
||
TEST(FlattenAndUnpadTest, FloatType2D) { | ||
std::vector<float> input = {0.0f, 0.0f, 0.0f, 1.0f, 2.0f, 3.0f, 0.0f, 0.0f, 0.0f, | ||
4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f, 0.0f, 0.0f}; | ||
std::vector<int64_t> indices = {1, 3, 4}; | ||
|
||
std::vector<float> output = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.f, 7.f, 8.f, 9.f}; | ||
std::vector<int64_t> unflatten_dims = {2, 3}; | ||
|
||
OpTester test("FlattenAndUnpad", 1, onnxruntime::kMSDomain); | ||
test.AddInput<float>("input", {2, 3, 3}, input); | ||
test.AddInput<int64_t>("indices", {3}, indices); | ||
test.AddOutput<float>("output", {3, 3}, output); | ||
test.AddOutput<int64_t>("unflatten_dims", {2}, unflatten_dims); | ||
test.Run(); | ||
} | ||
|
||
TEST(FlattenAndUnpadTest, MLFloat16Type1D) { | ||
std::vector<float> input = {0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 3.0f, 0.0f, 4.0f, | ||
0.0f, 5.0f, 0.0f, 6.0f, 0.0f, 0.0f, 0.0f}; | ||
std::vector<int64_t> indices = {1, 3, 5, 7, 9, 11}; | ||
|
||
std::vector<float> output = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.f}; | ||
std::vector<int64_t> unflatten_dims = {5, 3}; | ||
|
||
OpTester test("FlattenAndUnpad", 1, onnxruntime::kMSDomain); | ||
test.AddInput<float>("input", {5, 3}, input); | ||
test.AddInput<int64_t>("indices", {6}, indices); | ||
test.AddOutput<float>("output", {6}, output); | ||
test.AddOutput<int64_t>("unflatten_dims", {2}, unflatten_dims); | ||
test.Run(); | ||
} | ||
|
||
TEST(FlattenAndUnpadTest, MLFloat16Type2D) { | ||
std::vector<float> input = {0.0f, 0.0f, 0.0f, 1.0f, 2.0f, 3.0f, 0.0f, 0.0f, 0.0f, | ||
4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 0.0f, 0.0f, 0.0f}; | ||
std::vector<int64_t> indices = {1, 3, 4}; | ||
|
||
std::vector<float> output = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.f, 7.f, 8.f, 9.f}; | ||
std::vector<int64_t> unflatten_dims = {2, 3}; | ||
|
||
OpTester test("FlattenAndUnpad", 1, onnxruntime::kMSDomain); | ||
test.AddInput<float>("input", {2, 3, 3}, input); | ||
test.AddInput<int64_t>("indices", {3}, indices); | ||
test.AddOutput<float>("output", {3, 3}, output); | ||
test.AddOutput<int64_t>("unflatten_dims", {2}, unflatten_dims); | ||
test.Run(); | ||
} | ||
|
||
#endif | ||
|
||
} // namespace test | ||
} // namespace onnxruntime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.