1# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15"""Directives are special no-op functions that serve as compilation markers. 16 17They provide static information like type hints, compilation and TensorFlow 18overrides. 19 20These serve as annotations in the compiled code, allowing the user some control 21over the compilation process. They have no functional role at runtime. 22""" 23 24from __future__ import absolute_import 25from __future__ import division 26from __future__ import print_function 27 28 29UNSPECIFIED = object() 30 31 32def set_element_type(entity, dtype, shape=UNSPECIFIED): 33 """Indicates that the entity is expected hold items of specified type/shape. 34 35 The staged TensorFlow ops will reflect and assert this data type. Ignored 36 otherwise. 37 38 Args: 39 entity: The entity to annotate. 40 dtype: TensorFlow dtype value to assert for entity. 41 shape: Optional shape to assert for entity. 42 """ 43 del entity 44 del dtype 45 del shape 46 47 48def set_loop_options( 49 parallel_iterations=UNSPECIFIED, 50 back_prop=UNSPECIFIED, 51 swap_memory=UNSPECIFIED, 52 maximum_iterations=UNSPECIFIED): 53 """Specifies additional arguments to be passed to the enclosing while_loop. 54 55 The parameters apply to and only to the immediately enclosing loop. It only 56 has effect if the loop is staged as a TF while_loop; otherwise the parameters 57 have no effect. 58 59 Args: 60 parallel_iterations: See tf.while_loop. 61 back_prop: See tf.while_loop. 62 swap_memory: See tf.while_loop. 63 maximum_iterations: See tf.while_loop. 64 """ 65 del parallel_iterations 66 del back_prop 67 del swap_memory 68 del maximum_iterations 69