當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tf.mlir.experimental.convert_function用法及代碼示例

導入 ConcreteFunction 並將其轉換為文本 MLIR 模塊。

用法

tf.mlir.experimental.convert_function(
    concrete_function, pass_pipeline='tf-standard-pipeline',
    show_debug_info=False
)

參數

  • concrete_function ConcreteFunction 類型的對象。
  • pass_pipeline 要在模塊上運行的 MLIR Pass Pipeline 的文本說明,請參閱 MLIR 文檔文本傳遞管道語法.
  • show_debug_info 是否在發出的文本形式中包含位置。

返回

  • 對應於 ConcreteFunction 的 MLIR 模塊的文本表示。

拋出

  • InvalidArgumentError 如果 concrete_function 無效或無法轉換為 MLIR。

此 API 僅用於檢查 TensorFlow 的內部,返回的字符串目前用於調試目的。

通過提取其 ConcreteFunction(圍繞 tf.Graph 的eagerly-executing 包裝器),可以使用此 API 導入 tf.function 並將其從 TensorFlow 轉換為 TensorFlow MLIR。

例如:

@tf.function
def add(a, b):
  return a + b
concrete_function = add.get_concrete_function(
    tf.TensorSpec(None, tf.dtypes.float32),
    tf.TensorSpec(None, tf.dtypes.float32))
tf.mlir.experimental.convert_function(concrete_function)
'...module attributes {...} {...}...'

相關用法


注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.mlir.experimental.convert_function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。