tensorflow/core/kernels/immutable_constant_op_test.cc
// Creates a test graph with two immutable_const tensors and a simple math
// operation, one of nodes has wrong size, check that error properly reported.
Creates a test graph with two immutable_const tensors and a simple math
operation, one of nodes has wrong size, check that error properly reported.
Creates a test graph with two immutable_const tensors and a simple math operation one of nodes has wrong size check that error properly reported .
TEST(ImmutableConstantOpTest, ExecutionError) {
  const TensorShape kBadTensorShape({40, 100});
  const TensorShape kTestTensorShapeT({1, 4});
  auto root = Scope::DisabledShapeInferenceScope().ExitOnError();
  auto node1 =
      ops::ImmutableConst(root, DT_FLOAT, kBadTensorShape, "test:///2");
  auto node2 =
      ops::ImmutableConst(root, DT_FLOAT, kTestTensorShapeT, "test:///3");
  auto result = ops::MatMul(root, node1, node2);
  GraphDef graph_def;
  TF_ASSERT_OK(root.ToGraphDef(&graph_def));
  SessionOptions session_options;
  session_options.env = Env::Default();
  std::unique_ptr<Session> session(NewSession(session_options));
  ASSERT_TRUE(session != nullptr) << "Failed to create session";
  TF_ASSERT_OK(session->Create(graph_def)) << "Can't create test graph";
  std::vector<Tensor> outputs;
  EXPECT_EQ(
      session->Run({}, {result.node()->name() + ":0"}, {}, &outputs).code(),
      error::INTERNAL);
}
TEST ( ImmutableConstantOpTest , ExecutionError ) { const TensorShape kBadTensorShape ( { 40 , 100 } ) ; const TensorShape kTestTensorShapeT ( { 1 , 4 } ) ; auto root = Scope :: DisabledShapeInferenceScope ( ) . ExitOnError ( ) ; auto node1 = ops :: ImmutableConst ( root , DT_FLOAT , kBadTensorShape , " " ) ; auto node2 = ops :: ImmutableConst ( root , DT_FLOAT , kTestTensorShapeT , " " ) ; auto result = ops :: MatMul ( root , node1 , node2 ) ; GraphDef graph_def ; TF_ASSERT_OK ( root . ToGraphDef ( & graph_def ) ) ; SessionOptions session_options ; session_options . env = Env :: Default ( ) ; std :: unique_ptr < Session > session ( NewSession ( session_options ) ) ; ASSERT_TRUE ( session != nullptr ) << " " ; TF_ASSERT_OK ( session -> Create ( graph_def ) ) << " " ; std :: vector < Tensor > outputs ; EXPECT_EQ ( session -> Run ( { } , { result . node ( ) -> name ( ) + " " } , { } , & outputs ) . code ( ) , error :: INTERNAL ) ; }
Creates a test graph with two immutable_const tensors and a simple math
operation, one of nodes has wrong size, check that error properly reported.
Creates a test graph with two immutable_const tensors and a simple math operation one of nodes has wrong size check that error properly reported .
// Check that the run returned error.