docstr: Tests that XLA handles compile-time constants in defuns.
docstr_tok: ["Tests","that","XLA","handles","compile-time","constants","in","defuns","."]
code: def testCompileTimeConstantsInDefun(self):
      """Tests that XLA handles compile-time constants in defuns."""
      with self.session() as sess:
  
          @function.Defun(dtypes.float32, dtypes.int32, dtypes.int32)
          def Foo(a, c, d):
              # c and d must be known at compile time
              x = array_ops.slice(a, c, d)
              return x
  
          a = array_ops.placeholder(dtypes.float32)
          c = array_ops.placeholder(dtypes.int32, shape=[4])
          d = array_ops.placeholder(dtypes.int32, shape=[4])
          with self.test_scope():
              call_f = Foo(a, c, d)
          result = sess.run(
              call_f,
              feed_dict={
                  a: np.ones([1, 4, 4, 1]),
                  c: [0, 0, 0, 0],
                  d: [1, 2, 2, 1],
              },
          )
  
      self.assertAllEqual(np.ones([1, 2, 2, 1]), result)
  
file_path: tensorflow-upstream/tensorflow/compiler/tests/function_test.py
imports: import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import function
  from tensorflow.python.ops import array_ops
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 4 for calling the FunctionTest obj's underlying member method code with example usage: obj.testCompileTimeConstantsInDefun() and returns: x