def _swift_dispatch_body()

in Sources/TensorFlow/Bindings/generate_wrappers.py [0:0]


  def _swift_dispatch_body(self, x10_supported=False):
    names = []
    tensors = []
    backends = []
    device_source = None
    for arg in self.input_args:
      names.append(arg.swift_name)
      if arg.is_tensor_type(self.string_valued):
        tensors.append(arg)
        if arg.is_list:
          backends.append("commonBackend(" + arg.swift_name + ")")
        else:
          device_source = arg
          backends.append(arg.swift_name + ".handle.backend")
    for attr in self.attrs:
      if not attr.is_inferred_type_attr and not attr.is_inferred_number_attr:
        names.append(attr.swift_name)
    names_filtered = []
    for name in names:
      if name in _OMITTED_PARAMETER_NAMES:
        names_filtered.append(name)
      else:
        names_filtered.append(name + ": " + name)
    dispatch = self._swift_name() + "(" + (", ".join(names_filtered)) + ")"
    if len(backends) == 0 and x10_supported:
      print("x10 unsupported: " + str(self.swift_name()))
    def do_conversion(arg):
      return ("\n      let {name} = {typename}(copying: {name}, to: .defaultTFEager)"
              .format(name=arg.swift_name,
                      typename=str(arg.swift_type(self.string_valued))))
    def get_common_backend(x, y):
      return "commonBackend({}, {})".format(x, y)
    if len(backends) == 0 or (not x10_supported and (len(self.output_args) != 1
      or not self.output_args[0].is_tensor_type(self.string_valued) or not device_source)):
      return "_RawTFEager." + dispatch
    if not x10_supported:
      return """switch {backends} {{