parameters: (tensor)
docstring: Convert tensorflow tensor to anakin med tensor.
docstring_summary: Convert tensorflow tensor to anakin med tensor.
docstring_tokens: Convert tensorflow tensor to anakin med tensor .
function: def tf_to_anakin_tensor(tensor):
      """Convert tensorflow tensor to anakin med tensor."""
      new_type = TF_TO_ANAKIN_DTYPE[tensor.dtype]
      tdim = tensor.tensor_shape.dim
      dims = [d.size for d in tdim]
      # FIXME: something is fishy here
      if dims == [0]:
          dims = [1]
      is_raw, data = get_tf_tensor_data(tensor)
      dim_size = 1
      for i in dims:
          dim_size *= i
      # print(type(data),data,tensor.dtype,is_raw)
      if is_raw:
          if len(dims) > 0:
              anakin_tensor = np.frombuffer(data, map_tf_dtype(tensor.dtype))
              anakin_tensor = anakin_tensor.reshape(dims)
          else:
              anakin_tensor = np.zeros(0)
          return anakin_tensor
      elif dim_size > 1 and len(data) == 1:
  
          return np.array([data] * dim_size).reshape(dims)
      else:
          return data
function_tokens: def tf_to_anakin_tensor ( tensor ) : new_type = TF_TO_ANAKIN_DTYPE [ tensor . dtype ] tdim = tensor . tensor_shape . dim dims = [ d . size for d in tdim ] # FIXME: something is fishy here if dims == [ 0 ] : dims = [ 1 ] is_raw , data = get_tf_tensor_data ( tensor ) dim_size = 1 for i in dims : dim_size *= i # print(type(data),data,tensor.dtype,is_raw) if is_raw : if len ( dims ) > 0 : anakin_tensor = np . frombuffer ( data , map_tf_dtype ( tensor . dtype ) ) anakin_tensor = anakin_tensor . reshape ( dims ) else : anakin_tensor = np . zeros ( 0 ) return anakin_tensor elif dim_size > 1 and len ( data ) == 1 : return np . array ( [ data ] * dim_size ) . reshape ( dims ) else : return data