#include "tensorflow/compiler/xla/service/hlo_execution_profile.h"
#include "tensorflow/compiler/xla/service/hlo_cost_analysis.h"
#include "tensorflow/compiler/xla/tests/hlo_test_base.h"
+#include "tensorflow/compiler/xla/tools/parser/hlo_parser.h"
#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
class HloExecutionProfileTest : public HloTestBase {};
TEST_F(HloExecutionProfileTest, Basic) {
- std::unique_ptr<HloModule> hlo_module = CreateNewModule();
-
- HloComputation::Builder builder(TestName());
+ auto hlo_module = tools::Parse(R"(
+ HloModule test_module
+ ENTRY entry_computation {
+ lhs = f32[30,30]{1,0} parameter(0)
+ rhs = f32[30,30]{1,0} parameter(1)
+ add = f32[30,30]{1,0} add(lhs, rhs)
+ ROOT dot = f32[30,30]{1,0} dot(lhs, add), lhs_contracting_dims={1}, rhs_contracting_dims={0}
+ })")
+ .ValueOrDie();
+ const HloInstruction* dot_instruction =
+ hlo_module->entry_computation()->root_instruction();
+ const HloInstruction* add_instruction = dot_instruction->operand(1);
Shape shape = ShapeUtil::MakeShape(F32, {30, 30});
- HloInstruction* param_lhs =
- builder.AddInstruction(HloInstruction::CreateParameter(0, shape, "lhs"));
- HloInstruction* param_rhs =
- builder.AddInstruction(HloInstruction::CreateParameter(1, shape, "rhs"));
- HloInstruction* add_instruction =
- builder.AddInstruction(HloInstruction::CreateBinary(
- shape, HloOpcode::kAdd, param_lhs, param_rhs));
- HloInstruction* dot_instruction =
- builder.AddInstruction(HloInstruction::CreateBinary(
- shape, HloOpcode::kDot, param_lhs, add_instruction));
-
- hlo_module->AddEntryComputation(builder.Build());
auto shape_size_function = [&](const Shape& shape) {
const int64 pointer_size = 8;