This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add op C++ benchmark test framework(matmul, elementwise_add op benchm…
…ark test)
- Loading branch information
1 parent
f05f22b
commit d14ffd6
Showing
29 changed files
with
659 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/common/type.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace cinn::common { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/ir/intrinsic_ops.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace cinn::ir { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/ir/ir_verify.h" | ||
|
||
#include "cinn/ir/ir_mutator.h" | ||
#include "cinn/ir/ir_printer.h" | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#include "cinn/ir/ir_verify.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "cinn/ir/ir_operators.h" | ||
|
||
namespace cinn::ir { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#pragma once | ||
#include <llvm/ADT/ArrayRef.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include_directories(${CMAKE_SOURCE_DIR}/cinn/runtime) | ||
set(srcs test_utils.cc test_matmul.cc test_elementwise.cc) | ||
|
||
cc_test(test_matmul SRCS test_matmul.cc test_utils.cc DEPS core ARGS ${global_test_args}) | ||
target_compile_options(test_matmul PRIVATE "-O3") | ||
|
||
cc_test(test_elementwise SRCS test_elementwise.cc test_utils.cc DEPS core ARGS ${global_test_args}) | ||
target_compile_options(test_elementwise PRIVATE "-O3") |
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,32 @@ | ||
#include "tests/benchmark/test_elementwise.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "cinn/cinn.h" | ||
#include "cinn/hlir/framework/node.h" | ||
|
||
namespace cinn { | ||
namespace tests { | ||
|
||
void ElementwiseAddTester::Compare() { | ||
std::vector<float *> all_datas = GetAllDatas(); | ||
int out_dims = GetOutDims(); | ||
CHECK_EQ(all_datas.size(), 3U) << "elementwise_add should have 3 args.\n"; | ||
for (int i = 0; i < out_dims; ++i) { | ||
EXPECT_EQ((all_datas[0][i] + all_datas[1][i]), all_datas[2][i]); | ||
} | ||
} | ||
|
||
TEST(test_elementwise_add, default) { | ||
int M = 100; | ||
int N = 32; | ||
std::vector<std::vector<int>> input_shapes{{M, N}, {M, N}}; | ||
std::string op_name = "elementwise_add"; | ||
hlir::framework::NodeAttr attrs; | ||
ElementwiseAddTester add_tester(op_name, input_shapes); | ||
std::vector<Type> type{Float(32)}; | ||
add_tester.TestOp("elementwise_add_default", attrs, type); | ||
} | ||
|
||
} // namespace tests | ||
} // namespace cinn |
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,24 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "tests/benchmark/test_utils.h" | ||
|
||
namespace cinn { | ||
namespace tests { | ||
|
||
class ElementwiseAddTester : public OpBenchmarkTester { | ||
public: | ||
ElementwiseAddTester(const std::string &op_name, | ||
const std::vector<std::vector<int>> &input_shapes, | ||
const common::Target &target = common::DefaultHostTarget(), | ||
int repeat = 10, | ||
float diff = 1e-5) | ||
: OpBenchmarkTester(op_name, input_shapes, target, repeat, diff) {} | ||
|
||
void Compare() override; | ||
}; | ||
|
||
} // namespace tests | ||
} // namespace cinn |
Oops, something went wrong.