aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/hlo_parser_test.cc
diff options
context:
space:
mode:
authorGravatar Chris Leary <leary@google.com>2018-08-21 17:41:59 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-21 17:45:23 -0700
commit274bebe3a69ff0af96c721cb9b7cfbc9cd87679d (patch)
tree72d9ce1bc954ae8dc7cf55c22beeac1e730eaeec /tensorflow/compiler/xla/service/hlo_parser_test.cc
parent9ed82b760567d8b4543045603546299e0dd2ae8a (diff)
[XLA] Parse a single HLO instruction's text into a module.
Converts "free variable" operands into parameters. PiperOrigin-RevId: 209691261
Diffstat (limited to 'tensorflow/compiler/xla/service/hlo_parser_test.cc')
-rw-r--r--tensorflow/compiler/xla/service/hlo_parser_test.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/hlo_parser_test.cc b/tensorflow/compiler/xla/service/hlo_parser_test.cc
index 0d7919346b..5a1993a3bb 100644
--- a/tensorflow/compiler/xla/service/hlo_parser_test.cc
+++ b/tensorflow/compiler/xla/service/hlo_parser_test.cc
@@ -16,12 +16,15 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_parser.h"
#include <string>
+#include "tensorflow/compiler/xla/service/hlo_matchers.h"
#include "tensorflow/compiler/xla/window_util.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/test.h"
+namespace op = ::xla::testing::opcode_matchers;
+
namespace xla {
namespace {
@@ -1722,5 +1725,26 @@ ENTRY nontuple_infeed {
"infeed must have a non-empty tuple shape");
}
+TEST(HloParserSingleOpTest, SingleOp) {
+ const string text =
+ "%multiply = f32[2,4]{1,0} multiply(f32[2,4]{1,0} %broadcast, "
+ "f32[2,4]{1,0} %x)";
+ TF_ASSERT_OK_AND_ASSIGN(auto module, ParseHloOpToModule(text));
+ const HloComputation* computation = module->entry_computation();
+ ASSERT_NE(computation, nullptr);
+ EXPECT_THAT(computation->root_instruction(),
+ op::Multiply(op::Parameter(0), op::Parameter(1)));
+}
+
+TEST(HloParserSingleOpTest, SingleOpNoShapesProducesError) {
+ const string text = "%multiply = f32[2,4]{1,0} multiply(%broadcast, %x)";
+ StatusOr<std::unique_ptr<HloModule>> module = ParseHloOpToModule(text);
+ ASSERT_TRUE(!module.status().ok());
+ LOG(INFO) << "Status: " << module.status();
+ EXPECT_THAT(
+ module.status().ToString(),
+ ::testing::HasSubstr("Operand broadcast had no shape in HLO text"));
+}
+
} // namespace
} // namespace xla