docstr: Tests dense layer compilation in auto-jit mode.
  
  Dense layer should be compiled into a single XlaCompile/XlaRun op pair in
  auto-jit mode.
docstr_tok: ["Tests","dense","layer","compilation","in","auto-jit","mode",".","Dense","layer","should","be","compiled","into","a","single","XlaCompile\/XlaRun","op","pair","in","auto-jit","mode","."]
code: def testDenseLayerAutoJit(self):
      """Tests dense layer compilation in auto-jit mode.
  
      Dense layer should be compiled into a single XlaCompile/XlaRun op pair in
      auto-jit mode.
      """
  
      os.environ[
          "TF_XLA_FLAGS"
      ] = "--tf_xla_cpu_global_jit " + os.environ.get(
          "TF_XLA_FLAGS", ""
      )
      config = config_pb2.ConfigProto()
      config.graph_options.optimizer_options.global_jit_level = (
          config_pb2.OptimizerOptions.ON_1
      )
  
      with self.session(config=config) as sess:
          x = array_ops.placeholder(
              shape=[None, None, 3], dtype=np.float32
          )
          y = layers.dense(x, 3)
  
          self.evaluate(variables.global_variables_initializer())
          run_metadata = config_pb2.RunMetadata()
          test_utils.RunWithWarmup(
              sess,
              y,
              {
                  x: np.array(
                      [[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]]
                  )
              },
              run_metadata=run_metadata,
              options=config_pb2.RunOptions(
                  trace_level=config_pb2.RunOptions.FULL_TRACE
              ),
          )
  
      labels = GetRunMetadataLabels(run_metadata)
      self.assertEqual(1, self.countXlaOps(labels))
      self.assertFalse(InLabels(labels, "MatMult"))
  
file_path: tensorflow/tensorflow/compiler/tests/dense_layer_test.py
imports: import os
  import numpy
  from tensorflow.compiler.tests import test_utils
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.compiler.xla import jit
  from tensorflow.python.framework import ops
  from tensorflow.python.layers import layers
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling the DenseLayerTest obj's underlying member method code with example usage: obj.testDenseLayerAutoJit() without return types