'tf' 方言

TensorFlow 方言。

此方言對應到 TensorFlow 運算。

不變性

  • 所有值皆為 Tensor 類型 (特別是,純量以零維張量表示);

TODO: 使不變性更結構化,以便我們可以在運算中參考它們。

運算

tf._ArrayToList (TF::_ArrayToListOp)

將張量陣列轉換為張量列表。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性
out_types::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf._EagerConst (TF::_EagerConstOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf._FusedBatchNormEx (TF::_FusedBatchNormExOp)

內部 FusedBatchNorm 運算:保留供內部使用。

請勿在 Python 中直接調用此運算子。預期融合最佳化會建立這些運算子。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
epsilon::mlir::FloatAttr32 位元浮點屬性
exponential_avg_factor::mlir::FloatAttr32 位元浮點屬性
activation_mode::mlir::StringAttr字串屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
is_training::mlir::BoolAttr布林屬性
num_side_inputs::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性
U::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
scale 32 位元浮點數值的張量
offset 32 位元浮點數值的張量
mean 32 位元浮點數值的張量
variance 32 位元浮點數值的張量
side_input bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量的可變參數

結果

結果 描述
y bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
batch_mean 32 位元浮點數值的張量
batch_variance 32 位元浮點數值的張量
reserve_space_1 32 位元浮點數值的張量
reserve_space_2 32 位元浮點數值的張量
reserve_space_3 32 位元浮點數值的張量

tf._FusedConv2D (TF::_FusedConv2DOp)

執行卷積,後接一系列指定的運算。

卷積的輸入為 inputfilter。後續的運算系列由 fused_ops 屬性指定,該屬性是以字串形式指定的 TF 運算名稱列表 (例如 "Relu")。這些運算依序執行,其中每個運算的 (第一個) 輸入是前一個運算的輸出。第一個輸入和每個 fused_op 的輸出都必須為 T 類型。

目前支援的 fused_op 組合為:[X] 和 [X,A],其中 X 是 {"BiasAdd"、"FusedBatchNorm"} 之一,A 是 {"Elu"、"Relu"、"Relu6"} 之一。

  • 運算 X 的第一個輸入是 Conv2D 結果,而 X 的額外輸入由 args 指定。
  • 如果指定了運算 A,則運算 X 的輸出是運算 A 的輸入,而運算 A 會產生 _FusedConv2D 輸出。否則,運算 X 會產生 _FusedConv2D 輸出。

Traits: AlwaysSpeculatableImplTrait, AttrSizedOperandSegments

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_args::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
strides::mlir::ArrayAttr64 位元整數陣列屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr值為 NHWC、NCHW 或 NCHW_VECT_C 的字串屬性
filter_format::mlir::StringAttr值為 HWIO、OIHW 或 OIHW_VECT_I 的字串屬性
dilations::mlir::ArrayAttr64 位元整數陣列屬性
use_cudnn_on_gpu::mlir::BoolAttr布林屬性
fused_ops::mlir::ArrayAttr字串陣列屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
leakyrelu_alpha::mlir::FloatAttr32 位元浮點屬性
num_host_args::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性
TArgs::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 8 位元整數或 8 位元量化整數值的張量
filter 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 8 位元整數或 8 位元量化整數值的張量
args tf.dtype 值的張量的可變參數
host_args 32 位元浮點數值的張量的可變參數

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 8 位元整數或 8 位元量化整數值的張量

tf._FusedMatMul (TF::_FusedMatMulOp)

執行 MatMul,後接一系列指定的運算。

MatMul 的輸入由 ab 指定。後續的運算系列由 fused_ops 屬性指定,該屬性是以字串形式指定的 TF 運算名稱列表 (例如 "Relu")。這些運算依序執行,其中每個運算的 (第一個) 輸入是前一個運算的輸出。第一個輸入和每個 fused_op 的輸出都必須為 T 類型。

目前支援的 fused_op 組合為:["BiasAdd"] 和 ["BiasAdd",A],其中 A 是 {"Elu"、"Relu"、"Relu6"} 之一。

  • BiasAdd 的第一個輸入是 MatMul 結果,而額外的 BiasAdd 輸入由 args 指定。
  • 如果指定了運算 A,則 BiasAdd 的輸出是運算 A 的輸入,而運算 A 會產生 _FusedConv2D 輸出。否則,BiasAdd 會產生 _FusedConv2D 輸出。

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
transpose_a::mlir::BoolAttr布林屬性
transpose_b::mlir::BoolAttr布林屬性
fused_ops::mlir::ArrayAttr字串陣列屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
leakyrelu_alpha::mlir::FloatAttr32 位元浮點屬性
num_args::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
b bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
args bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量的可變參數

結果

結果 描述
product bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

tf._HostRecv (TF::_HostRecvOp)

_從 recv_device 上的 send_device 接收具名張量。

_HostRecv 在主機記憶體上產生輸出,而 _Recv 在裝置記憶體上產生輸出。

Interfaces: GetResourceInstanceInterface, TF_RecvSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
send_device::mlir::StringAttr字串屬性
send_device_incarnation::mlir::IntegerAttr64 位元無號整數屬性
recv_device::mlir::StringAttr字串屬性
client_terminated::mlir::BoolAttr布林屬性
tensor_type::mlir::Attribute衍生屬性

結果

結果 描述
tensor tf.dtype 值的張量

tf._HostSend (TF::_HostSendOp)

_從 send_device 將具名張量傳送至 recv_device。

_HostSend 需要其在主機記憶體上的輸入,而 _Send 需要其在裝置記憶體上的輸入。

Interfaces: GetResourceInstanceInterface, TF_SendSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
send_device::mlir::StringAttr字串屬性
send_device_incarnation::mlir::IntegerAttr64 位元無號整數屬性
recv_device::mlir::StringAttr字串屬性
client_terminated::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量

tf._InternalTestMustExecuteTrait_ (TF::InternalTestMustExecuteTrait)

僅供測試的內部運算

Interfaces: TF_MustExecute (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

tf._InternalTestNonResourceValueSideEffects_ (TF::InternalTestNonResourceValueSideEffects)

僅供測試的內部運算

運算元

運算元 描述
key 字串值的張量

tf._ListToArray (TF::_ListToArrayOp)

將張量列表轉換為張量陣列。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tin::mlir::Attribute衍生屬性
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf._Recv (TF::_RecvOp)

_從 recv_device 上的 send_device 接收具名張量。

Interfaces: GetResourceInstanceInterface, TF_RecvSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
send_device::mlir::StringAttr字串屬性
send_device_incarnation::mlir::IntegerAttr64 位元無號整數屬性
recv_device::mlir::StringAttr字串屬性
client_terminated::mlir::BoolAttr布林屬性
tensor_type::mlir::Attribute衍生屬性

結果

結果 描述
tensor tf.dtype 值的張量

tf._Send (TF::_SendOp)

_從 send_device 將具名張量傳送至 recv_device。

Interfaces: GetResourceInstanceInterface, TF_SendSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
send_device::mlir::StringAttr字串屬性
send_device_incarnation::mlir::IntegerAttr64 位元無號整數屬性
recv_device::mlir::StringAttr字串屬性
client_terminated::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量

tf._TPUCompileMlir (TF::_TPUCompileMlirOp)

編譯運算,以在一個或多個 TPU 裝置上執行。

供分散式 TPU 編譯器的內部使用。

'mlir_module' 是序列化的 MLIR 模組,其中包含具有目標運算的 main 函式。 'dynamic_shapes' 包含引數的動態形狀,這些引數的形狀在 TPUReplication 重寫時並非靜態已知。 'metadata' 是序列化的 TPUCompileMetadataProto,描述運算輸入的形狀和類型,以及對應到 TPU pod 拓撲的映射。 'program' 輸出是一個字串金鑰,該金鑰會傳遞至 TPUExecute 運算,並用於在編譯快取中查找程式。

Interfaces: TF_MustExecute (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
mlir_module::mlir::StringAttr字串屬性
metadata::mlir::StringAttr字串屬性
NumDynamicShapes::mlir::Attribute衍生屬性
num_computations::mlir::Attribute衍生屬性

運算元

運算元 描述
dynamic_shapes 64 位元整數值的張量的可變參數

結果

結果 描述
compilation_status 字串值的張量
program 字串值的張量的可變參數

tf._TPUDeviceOrdinalPlaceholder (TF::_TPUDeviceOrdinalPlaceholderOp)

_裝置序數的預留位置,該序數取決於其 tf_device.replicate 上層項目。

此運算必須具有 tf_device.replicate 上層項目。上層項目 replica_id 和 logical_core 屬性對應到 TPU 核心。此運算將 TPU 核心映射到裝置序數,其中裝置序數是核心相對於其主機的索引。

replicate_to_island 傳遞會移除並扁平化 tf_device.replicate,因此它會將此運算轉換為核心相對於其主機的常數索引。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
logical_core::mlir::IntegerAttr64 位元無號整數屬性

結果

結果 描述
device_ordinal 64 位元整數值的張量

tf._UnaryOpsComposition (TF::_UnaryOpsCompositionOp)

注意:請勿在 Python 中直接調用此運算子。圖形重寫傳遞為

預期會建立這些運算子。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
op_names::mlir::ArrayAttr字串陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
y 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf._XlaCompile (TF::_XlaCompileOp)

XLA 編譯運算。僅供 XLA JIT 使用。

將 TensorFlow 函式編譯為 XLA LocalExecutable,並傳回 _XlaRun 可用來查找 LocalExecutable 並執行它的金鑰。

Traits: AttrSizedOperandSegments

屬性

屬性MLIR 類型描述
must_compile::mlir::BoolAttr布林屬性
function::mlir::SymbolRefAttr符號參考屬性
Nresources::mlir::Attribute衍生屬性
Targs::mlir::Attribute衍生屬性
Tconstants::mlir::Attribute衍生屬性

運算元

運算元 描述
constants tf.dtype 值的張量的可變參數
args tf.dtype 值的張量的可變參數
resources 資源值的張量的可變參數

結果

結果 描述
key 字串值的張量
compilation_successful 布林值的張量

tf._XlaCompileMlirPlaceholderProgramKey (TF::_XlaCompileMlirPlaceholderProgramKeyOp)

XLA program 的預留位置程式金鑰 (編譯快取金鑰)。

當某些重寫傳遞具體化需要程式金鑰的運算,但尚未新增 _TPUCompileMlir 或 _XlaCompile 運算時,可以使用此運算。後續的重寫傳遞必須將此運算取代為 program 輸出。

Interfaces: TF_MustExecute (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

結果

結果 描述
program 字串值的張量

tf._XlaHostComputeMlir (TF::_XlaHostComputeMlirOp)

代表 XLA 程式中主機端運算的虛擬運算。

Interfaces: TF_RecvSideEffect (MemoryEffectOpInterface), TF_SendSideEffect (MemoryEffectOpInterface), TF_XlaHostComputeSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::XlaHostCompute}

屬性

屬性MLIR 類型描述
send_key::mlir::StringAttr字串屬性
recv_key::mlir::StringAttr字串屬性
host_mlir_module::mlir::StringAttr字串屬性
manual_sharding::mlir::BoolAttr布林屬性
Tinputs::mlir::Attribute衍生屬性
Toutputs::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf._XlaRecvAtHost (TF::_XlaRecvAtHostOp)

從正在執行的 XLA 運算接收值的預留位置運算。

Interfaces: GetResourceInstanceInterface, TF_RecvSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}

屬性

屬性MLIR 類型描述
key::mlir::StringAttr字串屬性
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
device_type::mlir::StringAttr字串屬性
Toutputs::mlir::Attribute衍生屬性

運算元

運算元 描述
dynamic_key 字串值的張量

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf._XlaRecvAtHostV2 (TF::_XlaRecvAtHostV2Op)

從正在執行的 XLA 運算接收值的預留位置運算,並支援執行階段裝置序數。

Interfaces: GetResourceInstanceInterface, TF_RecvSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}

屬性

屬性MLIR 類型描述
key::mlir::StringAttr字串屬性
device_type::mlir::StringAttr字串屬性
Toutputs::mlir::Attribute衍生屬性

運算元

運算元 描述
dynamic_key 字串值的張量
device_ordinal 64 位元整數值的張量

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf._XlaRun (TF::_XlaRunOp)

XLA 執行運算。僅供 XLA JIT 使用。

執行先前由 _XlaCompile 運算編譯到 LocalExecutable 中的 TensorFlow 函式。

Interfaces: MemoryEffectOpInterface

屬性

屬性MLIR 類型描述
Targs::mlir::Attribute衍生屬性
Tresults::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數
key 字串值的張量

結果

結果 描述
results tf.dtype 值的張量的可變參數

tf._XlaSendFromHost (TF::_XlaSendFromHostOp)

將值傳送至正在執行的 XLA 運算的預留位置運算。

Interfaces: GetResourceInstanceInterface, TF_SendSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}

屬性

屬性MLIR 類型描述
key::mlir::StringAttr字串屬性
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
device_type::mlir::StringAttr字串屬性
Tinputs::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數
dynamic_key 字串值的張量

tf._XlaSendFromHostV2 (TF::_XlaSendFromHostV2Op)

從正在執行的 XLA 運算接收值的預留位置運算,並支援執行階段裝置序數。

Interfaces: GetResourceInstanceInterface, TF_SendSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}

屬性

屬性MLIR 類型描述
key::mlir::StringAttr字串屬性
device_type::mlir::StringAttr字串屬性
Tinputs::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數
dynamic_key 字串值的張量
device_ordinal 64 位元整數值的張量

tf.Abs (TF::AbsOp)

計算張量的絕對值。

給定張量 x,此運算會傳回包含 x 中每個元素絕對值的張量。例如,如果 x 是輸入元素,y 是輸出元素,則此運算會計算 \(y = |x|\)。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

結果

結果 描述
y bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

tf.Acos (TF::AcosOp)

逐元素計算 x 的 acos。

提供輸入張量,tf.math.acos 運算會傳回張量每個元素的反餘弦值。如果 y = tf.math.cos(x),則 x = tf.math.acos(y)

輸入範圍為 [-1, 1],輸出範圍為 [0, pi]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Acosh (TF::AcoshOp)

逐元素計算 x 的反雙曲餘弦值。

給定輸入張量,此函式會計算每個元素的反雙曲餘弦值。輸入範圍為 [1, inf]。如果輸入超出範圍,則傳回 nan

x = tf.constant([-2, -0.5, 1, 1.2, 200, 10000, float("inf")])
tf.math.acosh(x) ==> [nan nan 0. 0.62236255 5.9914584 9.903487 inf]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Add (TF::AddOp)

逐元素傳回 x + y。

給定兩個輸入張量,tf.add 運算會計算張量中每個元素的總和。

輸入和輸出範圍皆為 (-inf, inf)

Traits: AlwaysSpeculatableImplTrait, ResultsBroadcastableShape, TF_LayoutAgnostic, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或帶正負號的整數或複數或 8 位元無號整數或字串值的張量
y 浮點數或帶正負號的整數或複數或 8 位元無號整數或字串值的張量

結果

結果 描述
z 浮點數或帶正負號的整數或複數或 8 位元無號整數或字串值的張量

tf.AddN (TF::AddNOp)

逐元素相加所有輸入張量。

輸入的大小和形狀必須相同。

  x = [9, 7, 10]
  tf.math.add_n(x) ==> 26

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數或變體值的張量的可變參數

結果

結果 描述
sum bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數或變體值的張量

tf.AddV2 (TF::AddV2Op)

逐元素傳回 x + y。

Traits: AlwaysSpeculatableImplTrait, Commutative, ResultsBroadcastableShape, TF_CwiseBinary, TF_LayoutAgnostic, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.AdjustContrastv2 (TF::AdjustContrastv2Op)

調整一或多個影像的對比度。

images 是至少 3 維的張量。最後 3 維解譯為 [高度、寬度、通道]。其他維度僅代表影像集合,例如 [批次、高度、寬度、通道]

對於每個影像的每個通道,會獨立調整對比度。

對於每個通道,運算子首先計算通道中影像像素的平均值,然後將每個像素的每個組件調整為 (x - 平均值) * contrast_factor + 平均值

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images 16 位元浮點數或 32 位元浮點數值的張量
contrast_factor 32 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數值的張量

tf.AdjustHue (TF::AdjustHueOp)

調整一或多個影像的色相。

images 是至少 3 維的張量。最後一維解譯為通道,且必須為三。

輸入影像會以 RGB 色彩空間考量。概念上,RGB 色彩會先映射到 HSV。接著將增量套用至所有色相值,然後重新映射回 RGB 色彩空間。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images 16 位元浮點數或 32 位元浮點數值的張量
delta 32 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數值的張量

tf.AdjustSaturation (TF::AdjustSaturationOp)

調整一或多個影像的飽和度。

images 是至少 3 維的張量。最後一維解譯為通道,且必須為三。

輸入影像會以 RGB 色彩空間考量。概念上,RGB 色彩會先映射到 HSV。接著將比例套用至所有飽和度值,然後重新映射回 RGB 色彩空間。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images 16 位元浮點數或 32 位元浮點數值的張量
scale 32 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數值的張量

tf.All (TF::AllOp)

計算張量維度中元素的「邏輯 AND」。

沿著 axis 中指定的維度縮減 input。除非 keep_dims 為 true,否則張量的等級會針對 axis 中的每個項目減少 1。如果 keep_dims 為 true,則縮減的維度會保留長度 1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 布林值的張量
reduction_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 布林值的張量

tf.AllToAll (TF::AllToAllOp)

用於跨 TPU 副本交換資料的運算。

在每個副本上,輸入會沿著 split_dimension 分割成 split_count 個區塊,並傳送至指定 group_assignment 的其他副本。從其他副本接收 split_count - 1 個區塊後,我們會沿著 concat_dimension 連接區塊作為輸出。

例如,假設有 2 個 TPU 副本:副本 0 收到輸入:[[A, B]] 副本 1 收到輸入:[[C, D]]

group_assignment=[[0, 1]] concat_dimension=0 split_dimension=1 split_count=2

副本 0 的輸出:[[A], [C]] 副本 1 的輸出:[[B], [D]]

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
concat_dimension::mlir::IntegerAttr64 位元無號整數屬性
split_dimension::mlir::IntegerAttr64 位元無號整數屬性
split_count::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
group_assignment 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.Angle (TF::AngleOp)

傳回複數的引數。

給定複數的張量 input,此運算會傳回 float 類型的張量,該張量是 input 中每個元素的引數。input 中的所有元素都必須是 \(a + bj\) 形式的複數,其中 a 是實部,b 是虛部。

此運算傳回的引數為 \(atan2(b, a)\) 形式。

例如

# tensor 'input' is [-2.25 + 4.75j, 3.25 + 5.75j]
tf.math.angle(input) ==> [2.0132, 1.056]

@compatibility(numpy) 相當於 np.angle。 @end_compatibility

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.AnonymousIterator (TF::AnonymousIteratorOp)

迭代器資源的容器。

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量

tf.AnonymousIteratorV2 (TF::AnonymousIteratorV2Op)

迭代器資源的容器。

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量
deleter 變體值的張量

tf.AnonymousIteratorV3 (TF::AnonymousIteratorV3Op)

迭代器資源的容器。

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量

tf.AnonymousMemoryCache (TF::AnonymousMemoryCacheOp)

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

結果

結果 描述
handle 資源值的張量
deleter 變體值的張量

tf.AnonymousMultiDeviceIterator (TF::AnonymousMultiDeviceIteratorOp)

多裝置迭代器資源的容器。

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
devices::mlir::ArrayAttr至少有 1 個元素的字串陣列屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量
deleter 變體值的張量

tf.AnonymousMultiDeviceIteratorV3 (TF::AnonymousMultiDeviceIteratorV3Op)

多裝置迭代器資源的容器。

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
devices::mlir::ArrayAttr至少有 1 個元素的字串陣列屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量

tf.AnonymousRandomSeedGenerator (TF::AnonymousRandomSeedGeneratorOp)

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

運算元

運算元 描述
seed 64 位元整數值的張量
seed2 64 位元整數值的張量

結果

結果 描述
handle 資源值的張量
deleter 變體值的張量

tf.AnonymousSeedGenerator (TF::AnonymousSeedGeneratorOp)

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

運算元

運算元 描述
seed 64 位元整數值的張量
seed2 64 位元整數值的張量
reshuffle 布林值的張量

結果

結果 描述
handle 資源值的張量
deleter 變體值的張量

tf.Any (TF::AnyOp)

計算張量維度中元素的「邏輯 OR」。

沿著 axis 中指定的維度縮減 input。除非 keep_dims 為 true,否則張量的等級會針對 axis 中的每個項目減少 1。如果 keep_dims 為 true,則縮減的維度會保留長度 1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 布林值的張量
reduction_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 布林值的張量

tf.ApproximateEqual (TF::ApproximateEqualOp)

逐元素傳回 abs(x-y) < tolerance 的真值。

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
tolerance::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 數字值的張量
y 數字值的張量

結果

結果 描述
z 布林值的張量

tf.ApproxTopK (TF::ApproxTopKOp)

以近似方式傳回輸入運算元的最小/最大 k 值及其索引。

如需演算法詳細資訊,請參閱 https://arxiv.org/abs/2206.14286。此運算目前僅在 TPU 上最佳化。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
k::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
reduction_dimension::mlir::IntegerAttr64 位元無號整數屬性
recall_target::mlir::FloatAttr32 位元浮點屬性
is_max_k::mlir::BoolAttr布林屬性
reduction_input_size_override::mlir::IntegerAttr64 位元無號整數屬性
aggregate_to_topk::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
values bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
indices 32 位元整數值的張量

tf.ArgMax (TF::ArgMaxOp)

傳回張量維度中具有最大值的索引。

請注意,如果出現平手情況,則不保證傳回值的身分。

Usage

  import tensorflow as tf
  a = [1, 10, 26.9, 2.8, 166.32, 62.3]
  b = tf.math.argmax(input = a)
  c = tf.keras.backend.eval(b)
  # c = 4
  # here a[4] = 166.32 which is the largest element of a across axis 0

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
output_type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或布林值或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
dimension 16 位元整數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 16 位元整數或 32 位元整數或 64 位元整數或 16 位元無號整數值的張量

tf.ArgMin (TF::ArgMinOp)

傳回張量維度中具有最小值的索引。

請注意,如果出現平手情況,則不保證傳回值的身分。

Usage

  import tensorflow as tf
  a = [1, 10, 26.9, 2.8, 166.32, 62.3]
  b = tf.math.argmin(input = a)
  c = tf.keras.backend.eval(b)
  # c = 0
  # here a[0] = 1 which is the smallest element of a across axis 0

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
output_type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或布林值或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
dimension 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.Asin (TF::AsinOp)

逐元素計算 x 的三角反函數正弦值。

tf.math.asin 運算會傳回 tf.math.sin 的反函數,因此如果 y = tf.math.sin(x),則 x = tf.math.asin(y)

例如

# Note: [1.047, 0.785] ~= [(pi/3), (pi/4)]
x = tf.constant([1.047, 0.785])
y = tf.math.sin(x) # [0.8659266, 0.7068252]

tf.math.asin(y) # [1.047, 0.785] = x

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Asinh (TF::AsinhOp)

逐元素計算 x 的反雙曲正弦值。

給定一個輸入張量,此函數計算張量中每個元素的反雙曲正弦值。輸入和輸出的範圍均為 [-inf, inf]

  x = tf.constant([-float("inf"), -2, -0.5, 1, 1.2, 200, 10000, float("inf")])
  tf.math.asinh(x) ==> [-inf -1.4436355 -0.4812118 0.8813736 1.0159732 5.991471 9.903487 inf]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Assert (TF::AssertOp)

斷言給定條件為真。

如果 condition 的評估結果為 false,則印出 data 中的張量列表。summarize 決定要印出多少張量的條目。

屬性

屬性MLIR 類型描述
summarize::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
condition 布林值的張量
data tf.dtype 值的張量的可變參數

tf.Assign (TF::AssignOp)

透過將 'value' 賦值給 'ref' 來更新 'ref'。

此操作會在賦值完成後輸出 "ref"。這使得鏈接需要使用重設值的操作變得更容易。

屬性

屬性MLIR 類型描述
validate_shape::mlir::BoolAttr布林屬性
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
ref tf.dtype 值的張量
value tf.dtype 值的張量

結果

結果 描述
output_ref tf.dtype 值的張量

tf.AssignAddVariableOp (TF::AssignAddVariableOp)

將值加到變數的目前值。

任何控制依賴於此操作的 ReadVariableOp 都保證會看到遞增後的值或後續更新的值。

屬性

屬性MLIR 類型描述
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
value tf.dtype 值的張量

tf.AssignSubVariableOp (TF::AssignSubVariableOp)

從變數的目前值中減去一個值。

任何控制依賴於此操作的 ReadVariableOp 都保證會看到遞減後的值或後續更新的值。

屬性

屬性MLIR 類型描述
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
value tf.dtype 值的張量

tf.AssignVariableOp (TF::AssignVariableOp)

為變數賦予新值。

任何控制依賴於此操作的 ReadVariableOp 都保證會傳回此值或變數後續更新的值。

屬性

屬性MLIR 類型描述
validate_shape::mlir::BoolAttr布林屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
value tf.dtype 值的張量

tf.AsString (TF::AsStringOp)

將給定張量中的每個條目轉換為字串。

支援多種數值類型和布林值。

對於 Unicode,請參閱 https://tensorflow.dev.org.tw/tutorials/representation/unicode 教學課程。

範例

tf.strings.as_string([3, 2])tf.strings.as_string([3.1415926, 2.71828], precision=2).numpy() array([b'3.14', b'2.72'], dtype=object)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
precision::mlir::IntegerAttr64 位元無號整數屬性
scientific::mlir::BoolAttr布林屬性
shortest::mlir::BoolAttr布林屬性
width::mlir::IntegerAttr64 位元無號整數屬性
fill::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或字串或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數或變體值的張量

結果

結果 描述
輸出 字串值的張量

tf.Atan (TF::AtanOp)

逐元素計算 x 的三角反正切值。

tf.math.atan 運算傳回 tf.math.tan 的反函數,因此如果 y = tf.math.tan(x),則 x = tf.math.atan(y)

例如

# Note: [1.047, 0.785] ~= [(pi/3), (pi/4)]
x = tf.constant([1.047, 0.785])
y = tf.math.tan(x) # [1.731261, 0.99920404]

tf.math.atan(y) # [1.047, 0.785] = x

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Atan2 (TF::Atan2Op)

逐元素計算 y/x 的反正切值,並考量引數的符號。

這是角度 \( \theta \in [-\pi, \pi] \) 使得 \[ x = r \cos(\theta) \] 且 \[ y = r \sin(\theta) \] 其中 \(r = \sqrt{x^2 + y^2} \)。

例如

x = [1., 1.] y = [1., -1.] print((tf.math.atan2(y,x) * (180 / np.pi)).numpy()) [ 45. -45.]

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
y 浮點數值的張量
x 浮點數值的張量

結果

結果 描述
z 浮點數值的張量

tf.Atanh (TF::AtanhOp)

逐元素計算 x 的反雙曲正切值。

給定一個輸入張量,此函數計算張量中每個元素的反雙曲正切值。輸入範圍為 [-1,1],輸出範圍為 [-inf, inf]。如果輸入為 -1,輸出將為 -inf,如果輸入為 1,輸出將為 inf。範圍以外的值將輸出 nan

  x = tf.constant([-float("inf"), -1, -0.5, 1, 0, 0.5, 10, float("inf")])
  tf.math.atanh(x) ==> [nan -inf -0.54930615 inf  0. 0.54930615 nan nan]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.AvgPool (TF::AvgPoolOp)

對輸入執行平均池化。

output 中的每個條目都是 value 中對應大小 ksize 視窗的平均值。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
value 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.AvgPool3D (TF::AvgPool3DOp)

對輸入執行 3D 平均池化。

output 中的每個條目都是 value 中對應大小 ksize 視窗的平均值。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.AvgPool3DGrad (TF::AvgPool3DGradOp)

計算平均池化函數的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
T::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input_shape 32 位元整數值的張量
grad 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.AvgPoolGrad (TF::AvgPoolGradOp)

計算平均池化函數的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input_shape 32 位元整數值的張量
grad 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.BatchDatasetV2 (TF::BatchDatasetV2Op)

建立一個從 input_dataset 批次處理 batch_size 個元素的資料集。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
parallel_copy::mlir::BoolAttr布林屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
batch_size 64 位元整數值的張量
drop_remainder 布林值的張量

結果

結果 描述
handle 變體值的張量

tf.BatchFunction (TF::BatchFunctionOp)

將所有輸入張量批次處理到函數完成的計算中。

因此,例如,在以下程式碼中


  # This input will be captured.
  y = tf.placeholder_with_default(1.0, shape=[])

  @tf.Defun(tf.float32)
  def computation(a):
    return tf.matmul(a, a) + y

  b = gen_batch_ops.batch_function(
          f=computation
          in_tensors=[a],
          captured_tensors=computation.captured_inputs,
          Tout=[o.type for o in computation.definition.signature.output_arg],
          num_batch_threads=1,
          max_batch_size=10,
          batch_timeout_micros=100000,  # 100ms
          allowed_batch_sizes=[3, 10],
          batching_queue="")

如果多個 session.run 呼叫同時嘗試計算 b,則 a 的值將被收集,沿著第一個軸非決定性地串連,並且只有一個執行緒會執行計算。

假設函數的所有引數都是張量,這些張量將沿著它們的第一個維度進行批次處理。

捕獲的引數不會進行批次處理。執行串連的 session.run 呼叫將使用可用的捕獲張量的值。因此,捕獲張量的典型用途應涉及在 session.run 呼叫之間保持不變的值。推論是這方面的一個很好的例子。

不支援 SparseTensor。裝飾函數的傳回值必須是張量或張量的列表/元組。

Traits: AlwaysSpeculatableImplTrait, AttrSizedOperandSegments

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)SymbolUserOpInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
num_batch_threads::mlir::IntegerAttr64 位元無號整數屬性
max_batch_size::mlir::IntegerAttr64 位元無號整數屬性
batch_timeout_micros::mlir::IntegerAttr64 位元無號整數屬性
max_enqueued_batches::mlir::IntegerAttr64 位元無號整數屬性
allowed_batch_sizes::mlir::ArrayAttr64 位元整數陣列屬性
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
batching_queue::mlir::StringAttr字串屬性
low_priority_max_batch_size::mlir::IntegerAttr64 位元無號整數屬性
low_priority_batch_timeout_micros::mlir::IntegerAttr64 位元無號整數屬性
low_priority_allowed_batch_sizes::mlir::ArrayAttr64 位元整數陣列屬性
low_priority_max_enqueued_batches::mlir::IntegerAttr64 位元無號整數屬性
mixed_priority_policy::mlir::StringAttr字串屬性,其值為 low_priority_padding_with_max_batch_size、或 low_priority_padding_with_next_allowed_batch_size、或 priority_isolation
enable_large_batch_splitting::mlir::BoolAttr布林屬性
Tcaptured::mlir::Attribute衍生屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
in_tensors tf.dtype 值的張量的可變參數
captured_tensors tf.dtype 值的張量的可變參數

結果

結果 描述
out_tensors tf.dtype 值的張量的可變參數

tf.BatchMatMul (TF::BatchMatMulOp)

在批次中乘兩個張量的切片。

Tensor xy 的所有切片(每個切片可以視為批次的一個元素)相乘,並將個別結果排列在具有相同批次大小的單個輸出張量中。每個個別切片可以選擇性地進行伴隨運算(伴隨矩陣表示轉置並共軛),方法是將 adj_xadj_y 旗標設定為 True,預設情況下這些旗標為 False

輸入張量 xy 是 2 維或更高維的,形狀為 [..., r_x, c_x][..., r_y, c_y]

輸出張量是 2 維或更高維的,形狀為 [..., r_o, c_o],其中

r_o = c_x if adj_x else r_x
c_o = r_y if adj_y else c_y

它計算為

output[..., :, :] = matrix(x[..., :, :]) * matrix(y[..., :, :])

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
adj_x::mlir::BoolAttr布林屬性
adj_y::mlir::BoolAttr布林屬性
grad_x::mlir::BoolAttr布林屬性
grad_y::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.BatchMatMulV2 (TF::BatchMatMulV2Op)

在批次中乘兩個張量的切片。

Tensor xy 的所有切片(每個切片可以視為批次的一個元素)相乘,並將個別結果排列在具有相同批次大小的單個輸出張量中。每個個別切片可以選擇性地進行伴隨運算(伴隨矩陣表示轉置並共軛),方法是將 adj_xadj_y 旗標設定為 True,預設情況下這些旗標為 False

輸入張量 xy 是 2 維或更高維的,形狀為 [..., r_x, c_x][..., r_y, c_y]

輸出張量是 2 維或更高維的,形狀為 [..., r_o, c_o],其中

r_o = c_x if adj_x else r_x
c_o = r_y if adj_y else c_y

它計算為

output[..., :, :] = matrix(x[..., :, :]) * matrix(y[..., :, :])

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
adj_x::mlir::BoolAttr布林屬性
adj_y::mlir::BoolAttr布林屬性
grad_x::mlir::BoolAttr布林屬性
grad_y::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

結果

結果 描述
輸出 bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

tf.BatchMatMulV3 (TF::BatchMatMulV3Op)

在批次中乘兩個張量的切片。

Tensor xy 的所有切片(每個切片可以視為批次的一個元素)相乘,並將個別結果排列在具有相同批次大小的單個輸出張量中。每個個別切片可以選擇性地進行伴隨運算(伴隨矩陣表示轉置並共軛),方法是將 adj_xadj_y 旗標設定為 True,預設情況下這些旗標為 False

輸入張量 xy 是 2 維或更高維的,形狀為 [..., r_x, c_x][..., r_y, c_y]

輸出張量是 2 維或更高維的,形狀為 [..., r_o, c_o],其中

r_o = c_x if adj_x else r_x
c_o = r_y if adj_y else c_y

它計算為

output[..., :, :] = matrix(x[..., :, :]) * matrix(y[..., :, :])

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
adj_x::mlir::BoolAttr布林屬性
adj_y::mlir::BoolAttr布林屬性
grad_x::mlir::BoolAttr布林屬性
grad_y::mlir::BoolAttr布林屬性
Ta::mlir::Attribute衍生屬性
Tb::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元無符號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元無符號整數值的張量

結果

結果 描述
輸出 bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數值的張量

tf.BatchNormWithGlobalNormalization (TF::BatchNormWithGlobalNormalizationOp)

批次正規化。

此操作已棄用。建議使用 tf.nn.batch_normalization

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
variance_epsilon::mlir::FloatAttr32 位元浮點屬性
scale_after_normalization::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
m bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
v bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
beta bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
gamma bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

結果

結果 描述
result bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

tf.BatchToSpace (TF::BatchToSpaceOp)

T 類型的 4 維張量的 BatchToSpace。

這是更通用的 BatchToSpaceND 的舊版。

將資料從批次重新排列(置換)到空間資料區塊中,然後進行裁剪。這是 SpaceToBatch 的反向轉換。更具體地說,此操作輸出輸入張量的副本,其中 batch 維度中的值在空間區塊中移動到 heightwidth 維度,然後沿著 heightwidth 維度進行裁剪。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
block_size::mlir::IntegerAttr最小值為 2 的 64 位元無號整數屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
crops 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.BatchToSpaceND (TF::BatchToSpaceNDOp)

T 類型的 N 維張量的 BatchToSpace。

此操作將 "batch" 維度 0 重塑為 M + 1 維度,形狀為 block_shape + [batch],將這些區塊交錯回由空間維度 [1, ..., M] 定義的網格中,以獲得與輸入相同秩的結果。然後,根據 crops 可選地裁剪此中間結果的空間維度,以產生輸出。這是 SpaceToBatch 的反向操作。請參閱下面的精確描述。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tblock_shape::mlir::Attribute衍生屬性
Tcrops::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
block_shape 32/64 位元帶正負號的整數值的張量
crops 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.BesselI0e (TF::BesselI0eOp)

逐元素計算 x 的 Bessel i0e 函數。

指數縮放的 0 階修正貝索函數定義為 bessel_i0e(x) = exp(-abs(x)) bessel_i0(x)

此函數比 bessel_i0(x) 更快且數值上更穩定。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.BesselI1e (TF::BesselI1eOp)

逐元素計算 x 的 Bessel i1e 函數。

指數縮放的 0 階修正貝索函數定義為 bessel_i1e(x) = exp(-abs(x)) bessel_i1(x)

此函數比 bessel_i1(x) 更快且數值上更穩定。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.Betainc (TF::BetaincOp)

_計算正規化不完全貝他積分 \(I_x(a, b)\)。_

正規化不完全貝他積分定義為

\(I_x(a, b) = \frac{B(x; a, b)}{B(a, b)}\)

其中

\(B(x; a, b) = \int_0^x t^{a-1} (1 - t)^{b-1} dt\)

是不完全貝他函數,而 \(B(a, b)\) 是完全貝他函數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 32/64 位元浮點數值的張量
b 32/64 位元浮點數值的張量
x 32/64 位元浮點數值的張量

結果

結果 描述
z 32/64 位元浮點數值的張量

tf.BiasAdd (TF::BiasAddOp)

bias 加到 value

這是 tf.add 的特殊情況,其中 bias 被限制為 1 維。支援廣播,因此 value 可以有任意數量的維度。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)TF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
value 數字值的張量
bias 數字值的張量

結果

結果 描述
輸出 數字值的張量

tf.BiasAddGrad (TF::BiasAddGradOp)

"BiasAdd" 在 "bias" 張量上的反向運算。

它將 out_backprop 中的所有值累積到特徵維度中。對於 NHWC 資料格式,特徵維度是最後一個。對於 NCHW 資料格式,特徵維度是倒數第三個。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
out_backprop 數字值的張量

結果

結果 描述
輸出 數字值的張量

tf.BiasAddV1 (TF::BiasAddV1Op)

bias 加到 value

這是 BiasAdd 的已棄用版本,即將移除。

這是 tf.add 的特殊情況,其中 bias 被限制為 1 維。支援廣播,因此 value 可以有任意數量的維度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
value 數字值的張量
bias 數字值的張量

結果

結果 描述
輸出 數字值的張量

tf.Bincount (TF::BincountOp)

計算整數陣列中每個值出現的次數。

輸出一個長度為 size 且與 weights 相同 dtype 的向量。如果 weights 為空,則索引 i 儲存值 iarr 中被計數的次數。如果 weights 非空,則索引 i 儲存 weights 中每個索引處的值的總和,其中 arr 中的對應值為 i

忽略 [0, size) 範圍之外 arr 中的值。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
arr 32 位元整數值的張量
size 32 位元整數值的張量
weights 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
bins 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.Bitcast (TF::BitcastOp)

將張量從一種型別位元轉換為另一種型別,而不複製資料。

給定一個張量 input,此操作會傳回一個與 input 具有相同緩衝區資料且資料類型為 type 的張量。

如果輸入資料類型 T 大於輸出資料類型 type,則形狀會從 [...] 變更為 [..., sizeof(T)/sizeof(type)]。

如果 T 小於 type,則運算子要求最右邊的維度等於 sizeof(type)/sizeof(T)。然後形狀會從 [..., sizeof(type)/sizeof(T)] 變更為 [...]。

當將實數 dtype 轉換為複數 dtype(例如 tf.complex64 或 tf.complex128)時,tf.bitcast() 和 tf.cast() 的工作方式不同,因為 tf.cast() 會將虛部設為 0,而 tf.bitcast() 會產生模組錯誤。例如,

範例 1

a = [1., 2., 3.] equality_bitcast = tf.bitcast(a, tf.complex128) Traceback (most recent call last): ... InvalidArgumentError: Cannot bitcast from 1 to 18 [Op:Bitcast] equality_cast = tf.cast(a, tf.complex128) print(equality_cast) tf.Tensor([1.+0.j 2.+0.j 3.+0.j], shape=(3,), dtype=complex128)

範例 2

tf.bitcast(tf.constant(0xffffffff, dtype=tf.uint32), tf.uint8)

範例 3

x = [1., 2., 3.] y = [0., 2., 3.] equality= tf.equal(x,y) equality_cast = tf.cast(equality,tf.float32) equality_bitcast = tf.bitcast(equality_cast,tf.uint8) print(equality) tf.Tensor([False True True], shape=(3,), dtype=bool) print(equality_cast) tf.Tensor([0. 1. 1.], shape=(3,), dtype=float32) print(equality_bitcast) tf.Tensor( [[ 0 0 0 0] [ 0 0 128 63] [ 0 0 128 63]], shape=(3, 4), dtype=uint8)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 數字值的張量

結果

結果 描述
輸出 數字值的張量

tf.BitwiseAnd (TF::BitwiseAndOp)

逐元素計算 xy 的位元 AND。

結果將設定那些在 xy 中都設定的位元。計算是在 xy 的底層表示上執行的。

例如

import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64,
              tf.uint8, tf.uint16, tf.uint32, tf.uint64]

for dtype in dtype_list:
  lhs = tf.constant([0, 5, 3, 14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
  exp = tf.constant([0, 0, 3, 10], dtype=tf.float32)

  res = bitwise_ops.bitwise_and(lhs, rhs)
  tf.assert_equal(tf.cast(res, tf.float32), exp) # TRUE

特性:AlwaysSpeculatableImplTraitCommutativeResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數值的張量
y 整數值的張量

結果

結果 描述
z 整數值的張量

tf.BitwiseOr (TF::BitwiseOrOp)

逐元素計算 xy 的位元 OR。

結果將設定那些在 xy 或兩者中都設定的位元。計算是在 xy 的底層表示上執行的。

例如

import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64,
              tf.uint8, tf.uint16, tf.uint32, tf.uint64]

for dtype in dtype_list:
  lhs = tf.constant([0, 5, 3, 14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
  exp = tf.constant([5, 5, 7, 15], dtype=tf.float32)

  res = bitwise_ops.bitwise_or(lhs, rhs)
  tf.assert_equal(tf.cast(res,  tf.float32), exp)  # TRUE

特性:AlwaysSpeculatableImplTraitCommutativeResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數值的張量
y 整數值的張量

結果

結果 描述
z 整數值的張量

tf.BitwiseXor (TF::BitwiseXorOp)

逐元素計算 xy 的位元 XOR。

結果將設定那些在 xy 中不同的位元。計算是在 xy 的底層表示上執行的。

例如

import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64,
              tf.uint8, tf.uint16, tf.uint32, tf.uint64]

for dtype in dtype_list:
  lhs = tf.constant([0, 5, 3, 14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
  exp = tf.constant([5, 5, 4, 5],  dtype=tf.float32)

  res = bitwise_ops.bitwise_xor(lhs, rhs)
  tf.assert_equal(tf.cast(res, tf.float32), exp) # TRUE

特性:AlwaysSpeculatableImplTraitCommutativeResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數值的張量
y 整數值的張量

結果

結果 描述
z 整數值的張量

tf.BoostedTreesBucketize (TF::BoostedTreesBucketizeOp)

根據儲存桶邊界對每個特徵進行儲存桶化。

一個運算,傳回浮點張量列表,其中每個張量代表單個特徵的儲存桶化值。

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_features::mlir::Attribute衍生屬性

運算元

運算元 描述
float_values 32 位元浮點數值的張量的可變參數
bucket_boundaries 32 位元浮點數值的張量的可變參數

結果

結果 描述
buckets 32 位元整數值的張量的變數

tf.BroadcastArgs (TF::BroadcastArgsOp)

傳回具有廣播的 s0 op s1 的形狀。

給定 s0s1,表示形狀的張量,計算廣播形狀 r0s0s1r0 都是整數向量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
s0 32/64 位元帶正負號的整數值的張量
s1 32/64 位元帶正負號的整數值的張量

結果

結果 描述
r0 32/64 位元帶正負號的整數值的張量

tf.BroadcastGradientArgs (TF::BroadcastGradientArgsOp)

傳回用於計算具有廣播的 s0 op s1 的梯度的縮減索引。

這通常用於廣播運算的梯度計算。

特性:AlwaysSpeculatableImplTraitSameOperandsAndResultElementType

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
s0 32/64 位元帶正負號的整數值的張量
s1 32/64 位元帶正負號的整數值的張量

結果

結果 描述
r0 32/64 位元帶正負號的整數值的張量
r1 32/64 位元帶正負號的整數值的張量

tf.BroadcastTo (TF::BroadcastToOp)

為相容的形狀廣播陣列。

廣播是使陣列具有相容形狀以進行算術運算的過程。如果對於每個維度對,它們要麼相等,要麼其中一個為一,則兩個形狀是相容的。

例如

x = tf.constant([[1, 2, 3]]) # 形狀 (1, 3,) y = tf.broadcast_to(x, [2, 3]) print(y) tf.Tensor( [[1 2 3] [1 2 3]], shape=(2, 3), dtype=int32)

在上面的範例中,形狀為 [1, 3] 的輸入張量被廣播到形狀為 [2, 3] 的輸出張量。

廣播時,如果張量的軸少於必要的軸,則其形狀會在左側以 1 進行填充。因此,這給出了與先前範例相同的結果

x = tf.constant([1, 2, 3]) # 形狀 (3,) y = tf.broadcast_to(x, [2, 3])

當執行廣播運算(例如將張量乘以純量)時,廣播(通常)會帶來一些時間或空間上的好處,因為廣播張量永遠不會實體化。

但是,broadcast_to 並不具有任何此類好處。新建立的張量佔用廣播形狀的完整記憶體。(在圖形環境中,broadcast_to 可能會融合到後續操作,然後被最佳化掉,但是。)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Bucketize (TF::BucketizeOp)

根據 'boundaries' 將 'input' 分成儲存桶。

例如,如果輸入是 boundaries = [0, 10, 100] input = [[-5, 10000] [150, 10] [5, 100]]

則輸出將為 output = [[0, 3] [3, 2] [1, 3]]

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
boundaries::mlir::ArrayAttr32 位元浮點數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 32 位元整數值的張量

tf.CacheDatasetV2 (TF::CacheDatasetV2Op)

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
filename 字串值的張量
cache 資源值的張量

結果

結果 描述
handle 變體值的張量

tf.Case (TF::CaseOp)

一個 n 路開關陳述式,它呼叫單個分支函數。

一個 n 路開關陳述式,實作如下

```
switch (branch_index) {
  case 0:
    output = branches[0](input);
    break;
  case 1:
    output = branches[1](input);
    break;
  ...
  case [[nbranches-1]]:
  default:
    output = branches[nbranches-1](input);
    break;
}
```

介面:SymbolUserOpInterface

屬性

屬性MLIR 類型描述
branches::mlir::ArrayAttr具有至少 1 個元素的符號參考陣列屬性
is_stateless::mlir::BoolAttr布林屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性
output_shapes::mlir::Attribute衍生屬性

運算元

運算元 描述
branch_index 32 位元無號整數值的張量
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.CaseRegion (TF::CaseRegionOp)

一個 n 路開關陳述式,它呼叫單個分支函數。

一個 n 路開關陳述式,實作如下

```
switch (branch_index) {
  case 0:
    output = branches[0](input);
    break;
  case 1:
    output = branches[1](input);
    break;
  ...
  case [[nbranches-1]]:
  default:
    output = branches[nbranches-1](input);
    break;
}
```

特性:NoRegionArgumentsSingleBlockImplicitTerminator<YieldOp>SingleBlock

屬性

屬性MLIR 類型描述
is_stateless::mlir::BoolAttr布林屬性

運算元

運算元 描述
branch_index 32 位元無號整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.Cast (TF::CastOp)

將型別為 SrcT 的 x 轉換為 DstT 的 y。

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Truncate::mlir::BoolAttr布林屬性
SrcT::mlir::Attribute衍生屬性
DstT::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量

結果

結果 描述
y tf.dtype 值的張量

tf.Ceil (TF::CeilOp)

傳回逐元素不小於 x 的最小整數。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.CheckNumerics (TF::CheckNumericsOp)

檢查張量中是否有 NaN 和 Inf 值。

執行時,如果 tensor 有任何非數字 (NaN) 或無限 (Inf) 值,則報告 InvalidArgument 錯誤。否則,傳回輸入張量。

範例用法

a = tf.Variable(1.0)
tf.debugging.check_numerics(a, message='')

b = tf.Variable(np.nan)
try:
  tf.debugging.check_numerics(b, message='Checking b')
except Exception as e:
  assert "Checking b : Tensor had NaN values" in e.message

c = tf.Variable(np.inf)
try:
  tf.debugging.check_numerics(c, message='Checking c')
except Exception as e:
  assert "Checking c : Tensor had Inf values" in e.message

特性:InferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_NoConstantFold

介面:InferShapedTypeOpInterfaceInferTypeOpInterfaceTF_MustExecute (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
message::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.Cholesky (TF::CholeskyOp)

計算一個或多個方陣的 Cholesky 分解。

輸入是形狀為 [..., M, M] 的張量,其最內層的 2 個維度形成方陣。

輸入必須是對稱且正定的。此運算只會使用輸入的下三角部分。不會讀取上三角部分。

輸出是與輸入形狀相同的張量,其中包含所有輸入子矩陣 [..., :, :] 的 Cholesky 分解。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.ClipByValue (TF::ClipByValueOp)

將張量值裁剪為指定的最小值和最大值。

給定一個張量 x,此操作會傳回與 x 類型和形狀相同的張量,其值裁剪為 clip_value_minclip_value_max。任何小於 clip_value_min 的值都會設定為 clip_value_min。任何大於 clip_value_max 的值都會設定為 clip_value_max

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
clip_value_min bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
clip_value_max bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

結果

結果 描述
輸出 bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無符號整數或 8 位元量化無符號整數或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

tf.CloseSummaryWriter (TF::CloseSummaryWriterOp)

刷新並關閉摘要寫入器。

也會將其從資源管理器中移除。若要重新開啟,請使用另一個 CreateSummaryFileWriter 運算。

writer:摘要寫入器資源的控制代碼。

運算元

運算元 描述
writer 資源值的張量

tf.CollateTPUEmbeddingMemory (TF::CollateTPUEmbeddingMemoryOp)

一個運算,合併來自所有主機的字串編碼記憶體配置原型。

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性

運算元

運算元 描述
memory_configs 字串值的張量的可變參數

結果

結果 描述
merged_memory_config 字串值的張量

tf.CollectiveAllToAllV2 (TF::CollectiveAllToAllV2Op)

相互交換多個具有相同類型和形狀的張量。

is_stateless 表示每個運算不需要對其他集體運算進行控制依賴。在這種情況下,應使用在執行階段唯一的索引鍵(例如 instance_key)來區分集體群組。

介面:GetResourceInstanceInterfaceTF_CollectiveReduceOrderingEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::CollectiveReduceOrdering}

屬性

屬性MLIR 類型描述
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
is_stateless::mlir::BoolAttr布林屬性
Nordering_token::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數或 32/64 位元帶號整數值的張量
group_size 32 位元整數值的張量
group_key 32 位元整數值的張量
instance_key 32 位元整數值的張量
ordering_token 資源值的張量的可變參數

結果

結果 描述
data 浮點數或 32/64 位元帶號整數值的張量

tf.CollectiveAssignGroupV2 (TF::CollectiveAssignGroupV2Op)

根據群組分配指派群組索引鍵。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
group_assignment 32 位元整數值的張量
device_index 32 位元整數值的張量
base_key 32 位元整數值的張量

結果

結果 描述
group_size 32 位元整數值的張量
group_key 32 位元整數值的張量

tf.CollectiveBcastRecv (TF::CollectiveBcastRecvOp)

接收從另一個裝置廣播的張量值。

屬性

屬性MLIR 類型描述
group_size::mlir::IntegerAttr64 位元無號整數屬性
group_key::mlir::IntegerAttr64 位元無號整數屬性
instance_key::mlir::IntegerAttr64 位元無號整數屬性
shape::mlir::AttributeTensorFlow 形狀屬性
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

結果

結果 描述
data 布林值或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.CollectiveBcastSend (TF::CollectiveBcastSendOp)

將張量值廣播到一個或多個其他裝置。

屬性

屬性MLIR 類型描述
group_size::mlir::IntegerAttr64 位元無號整數屬性
group_key::mlir::IntegerAttr64 位元無號整數屬性
instance_key::mlir::IntegerAttr64 位元無號整數屬性
shape::mlir::AttributeTensorFlow 形狀屬性
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 布林值或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
data 布林值或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.CollectiveGather (TF::CollectiveGatherOp)

相互累積多個具有相同類型和形狀的張量。

屬性

屬性MLIR 類型描述
group_size::mlir::IntegerAttr64 位元無號整數屬性
group_key::mlir::IntegerAttr64 位元無號整數屬性
instance_key::mlir::IntegerAttr64 位元無號整數屬性
shape::mlir::AttributeTensorFlow 形狀屬性
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
data 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.CollectiveGatherV2 (TF::CollectiveGatherV2Op)

相互累積多個具有相同類型和形狀的張量。

is_stateless 表示每個運算不需要對其他集體運算進行控制依賴。在這種情況下,應使用在執行階段唯一的索引鍵(例如 instance_key)來區分集體群組。

介面:GetResourceInstanceInterfaceTF_CollectiveReduceOrderingEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::CollectiveReduceOrdering}

屬性

屬性MLIR 類型描述
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
is_stateless::mlir::BoolAttr布林屬性
Nordering_token::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量
group_size 32 位元整數值的張量
group_key 32 位元整數值的張量
instance_key 32 位元整數值的張量
ordering_token 資源值的張量的可變參數

結果

結果 描述
data 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.CollectivePermute (TF::CollectivePermuteOp)

一個在複製的 TPU 執行個體之間置換張量的運算。

每個執行個體提供自己的輸入。

例如,假設有 4 個 TPU 執行個體:[A, B, C, D]。傳遞 source_target_pairs=[[0,1],[1,2],[2,3],[3,0]] 會得到輸出:[D, A, B, C]

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 數字值的張量
source_target_pairs 32 位元整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.CollectiveReduce (TF::CollectiveReduceOp)

相互縮減多個具有相同類型和形狀的張量。

特性:InferTensorTypeTF::SameOperandsAndResultTypeResolveRef

介面:InferShapedTypeOpInterfaceInferTypeOpInterface

屬性

屬性MLIR 類型描述
group_size::mlir::IntegerAttr64 位元無號整數屬性
group_key::mlir::IntegerAttr64 位元無號整數屬性
instance_key::mlir::IntegerAttr64 位元無號整數屬性
merge_op::mlir::StringAttr字串屬性,其值為 Min、或 Max、或 Mul、或 Add
final_op::mlir::StringAttr字串屬性,其值為 Id、或 Div
subdiv_offsets::mlir::ArrayAttr64 位元整數陣列屬性
wait_for::mlir::ArrayAttr64 位元整數陣列屬性
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數或 32/64 位元帶號整數值的張量

結果

結果 描述
data 浮點數或 32/64 位元帶號整數值的張量

tf.CollectiveReduceScatterV2 (TF::CollectiveReduceScatterV2Op)

相互縮減多個具有相同類型和形狀的張量,並分散結果。

is_stateless 表示每個運算不需要對其他集體運算進行控制依賴。在這種情況下,應使用在執行階段唯一的索引鍵(例如 instance_key)來區分集體群組。

介面:GetResourceInstanceInterfaceTF_CollectiveReduceOrderingEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::CollectiveReduceOrdering}

屬性

屬性MLIR 類型描述
merge_op::mlir::StringAttr字串屬性,其值為 Min、或 Max、或 Mul、或 Add
final_op::mlir::StringAttr字串屬性,其值為 Id、或 Div
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
is_stateless::mlir::BoolAttr布林屬性
max_subdivs_per_device::mlir::IntegerAttr64 位元無號整數屬性
Nordering_token::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數或 32/64 位元帶號整數值的張量
group_size 32 位元整數值的張量
group_key 32 位元整數值的張量
instance_key 32 位元整數值的張量
ordering_token 資源值的張量的可變參數

結果

結果 描述
data 浮點數或 32/64 位元帶號整數值的張量

tf.CollectiveReduceV2 (TF::CollectiveReduceV2Op)

相互縮減多個具有相同類型和形狀的張量。

is_stateless 表示每個運算不需要對其他集體運算進行控制依賴。在這種情況下,應使用在執行階段唯一的索引鍵(例如 instance_key)來區分集體群組。

介面:GetResourceInstanceInterfaceTF_CollectiveReduceOrderingEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::CollectiveReduceOrdering}

屬性

屬性MLIR 類型描述
merge_op::mlir::StringAttr字串屬性,其值為 Min、或 Max、或 Mul、或 Add
final_op::mlir::StringAttr字串屬性,其值為 Id、或 Div
communication_hint::mlir::StringAttr字串屬性
timeout_seconds::mlir::FloatAttr32 位元浮點屬性
is_stateless::mlir::BoolAttr布林屬性
max_subdivs_per_device::mlir::IntegerAttr64 位元無號整數屬性
Nordering_token::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數或 32/64 位元帶號整數值的張量
group_size 32 位元整數值的張量
group_key 32 位元整數值的張量
instance_key 32 位元整數值的張量
ordering_token 資源值的張量的可變參數

結果

結果 描述
data 浮點數或 32/64 位元帶號整數值的張量

tf.Complex (TF::ComplexOp)

將兩個實數轉換為複數。

給定一個表示複數實部的張量 real 和一個表示複數虛部的張量 imag,此運算會逐元素傳回 \(a + bj\) 形式的複數,其中 a 表示 real 部分,b 表示 imag 部分。

輸入張量 realimag 必須具有相同的形狀。

例如

# tensor 'real' is [2.25, 3.25]
# tensor `imag` is [4.75, 5.75]
tf.complex(real, imag) ==> [[2.25 + 4.75j], [3.25 + 5.75j]]

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
real 32/64 位元浮點數值的張量
imag 32/64 位元浮點數值的張量

結果

結果 描述
out 128 位元複數或 64 位元複數值的張量

tf.ComplexAbs (TF::ComplexAbsOp)

計算張量的複數絕對值。

給定一個複數張量 x,此操作會傳回一個 floatdouble 類型的張量,其為 x 中每個元素的絕對值。x 中的所有元素都必須是 \(a + bj\) 形式的複數。絕對值的計算方式為 \( \sqrt{a^2 + b^2}\)。

例如

x = tf.complex(3.0, 4.0) print((tf.raw_ops.ComplexAbs(x=x, Tout=tf.dtypes.float32, name=None)).numpy()) 5.0

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
x 128 位元複數或 64 位元複數值的張量

結果

結果 描述
y 32/64 位元浮點數值的張量

tf.Concat (TF::ConcatOp)

沿著一個維度串連張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
concat_dim 32 位元整數值的張量
values tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量

tf.ConcatOffset (TF::ConcatOffsetOp)

計算串連輸入在其輸出中的偏移量。

例如

x = [2, 2, 7] y = [2, 3, 7] z = [2, 9, 7] offsets = concat_offset(1, [x, y, z]) [list(off.numpy()) for off in offsets] [[0, 0, 0], [0, 2, 0], [0, 5, 0]]

這通常用於串連操作的梯度計算。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
shape_type::mlir::Attribute衍生屬性

運算元

運算元 描述
concat_dim 32 位元整數值的張量
shape 32/64 位元有號整數值的張量變數

結果

結果 描述
offset 32/64 位元有號整數值的張量變數

tf.ConcatV2 (TF::ConcatV2Op)

沿著一個維度串連張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
values tf.dtype 值的張量的可變參數
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.ConfigureAndInitializeGlobalTPU (TF::ConfigureAndInitializeGlobalTPUOp)

在多用戶設定中初始化 TPU 系統的操作。

為多用戶執行初始化全域 TPU 系統。

此操作執行 ConfigureDistributedTpuOp 和 InitializeHostForDistributedTpuOp 的工作,並輸出後者的結果。

結果

結果 描述
輸出 32 位元整數值的張量

tf.ConfigureDistributedTPU (TF::ConfigureDistributedTPUOp)

為分散式 TPU 系統設定集中式結構。

屬性

屬性MLIR 類型描述
embedding_config::mlir::StringAttr字串屬性
tpu_embedding_config::mlir::StringAttr字串屬性
is_global_init::mlir::BoolAttr布林屬性
enable_whole_mesh_compilations::mlir::BoolAttr布林屬性
compilation_failure_closes_chips::mlir::BoolAttr布林屬性
tpu_cancellation_closes_chips::mlir::IntegerAttr64 位元無號整數屬性

結果

結果 描述
topology 字串值的張量

tf.ConfigureTPUEmbedding (TF::ConfigureTPUEmbeddingOp)

在分散式 TPU 系統中設定 TPUEmbedding。

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性

tf.ConfigureTPUEmbeddingHost (TF::ConfigureTPUEmbeddingHostOp)

在主機上設定 TPUEmbedding 軟體的操作。

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性

運算元

運算元 描述
common_config 字串值的張量
memory_config 字串值的張量

結果

結果 描述
network_config 字串值的張量

tf.ConfigureTPUEmbeddingMemory (TF::ConfigureTPUEmbeddingMemoryOp)

在主機上設定 TPUEmbedding 軟體的操作。

運算元

運算元 描述
common_config 字串值的張量

結果

結果 描述
memory_config 字串值的張量

tf.Conj (TF::ConjOp)

傳回複數的共軛複數。

給定一個複數張量 input,此操作會傳回一個複數張量,其為 input 中每個元素的共軛複數。input 中的複數必須為 \(a + bj\) 形式,其中 a 是實部,而 b 是虛部。

此操作傳回的共軛複數形式為 \(a - bj\)。

例如

# tensor 'input' is [-2.25 + 4.75j, 3.25 + 5.75j]
tf.conj(input) ==> [-2.25 - 4.75j, 3.25 - 5.75j]

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_Involution

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數或變體值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數或變體值的張量

tf.ConjugateTranspose (TF::ConjugateTransposeOp)

根據置換來混洗 x 的維度,並共軛結果。

輸出 yx 具有相同的秩。xy 的形狀滿足:對於 i in [0, 1, ..., rank(x) - 1]y.shape[i] == x.shape[perm[i]] y[i,j,k,...,s,t,u] == conj(x[perm[i], perm[j], perm[k],...,perm[s], perm[t], perm[u]])

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tperm::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
perm 32/64 位元帶正負號的整數值的張量

結果

結果 描述
y tf.dtype 值的張量

tf.ConnectTPUEmbeddingHosts (TF::ConnectTPUEmbeddingHostsOp)

在每個主機上呼叫 ConfigureTPUEmbeddingHost 後,設定 TPUEmbedding 主機軟體執行個體之間通訊的操作。

在每個主機上呼叫 ConfigureTPUEmbeddingHost 之後。

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性

運算元

運算元 描述
network_configs 字串值的張量的可變參數

tf.Const (TF::ConstOp)

常數張量運算

特性:AlwaysSpeculatableImplTraitConstantLike

介面:ConditionallySpeculatableInferTypeOpInterfaceNoMemoryEffect (MemoryEffectOpInterface)OpAsmOpInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
value::mlir::ElementsAttr常數向量/張量屬性
dtype::mlir::Attribute衍生屬性

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Conv (TF::ConvOp)

_計算給定 (N+1+batchdims)-D input 和 (N+2)-D filter 張量的 N 維度卷積。

用於計算 N 維度卷積的通用函數。需要 1 <= N <= 3

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr字串屬性,其值為 CHANNELS_FIRST 或 CHANNELS_LAST
dilations::mlir::ArrayAttr64 位元整數陣列屬性
batch_dims::mlir::IntegerAttr64 位元無號整數屬性
groups::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量
filter bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

tf.Conv2D (TF::Conv2DOp)

計算給定 4 維度 inputfilter 張量的 2 維度卷積。

給定形狀為 [batch, in_height, in_width, in_channels] 的輸入張量,以及形狀為 [filter_height, filter_width, in_channels, out_channels] 的篩選器/核心張量,此操作會執行以下操作

  1. 將篩選器展平為形狀為 [filter_height * filter_width * in_channels, output_channels] 的 2 維度矩陣。
  2. 從輸入張量中擷取影像塊,以形成形狀為 [batch, out_height, out_width, filter_height * filter_width * in_channels]虛擬張量。
  3. 針對每個塊,將篩選器矩陣和影像塊向量進行右乘。

詳細來說,使用預設 NHWC 格式,

output[b, i, j, k] =
    sum_{di, dj, q} input[b, strides[1] * i + di, strides[2] * j + dj, q] *
                    filter[di, dj, q, k]

必須具有 strides[0] = strides[3] = 1。對於最常見的相同水平和垂直步幅情況,strides = [1, stride, stride, 1]

特性:AlwaysSpeculatableImplTraitInferTensorType

介面:ConditionallySpeculatableInferShapedTypeOpInterfaceInferTypeOpInterfaceNoMemoryEffect (MemoryEffectOpInterface)TF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
use_cudnn_on_gpu::mlir::BoolAttr布林屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量
filter bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

tf.Conv2DBackpropFilter (TF::Conv2DBackpropFilterOp)

計算關於篩選器的卷積梯度。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)TF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
use_cudnn_on_gpu::mlir::BoolAttr布林屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
filter_sizes 32 位元整數值的張量
out_backprop 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.Conv2DBackpropFilterV2 (TF::Conv2DBackpropFilterV2Op)

計算關於篩選器的卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
use_cudnn_on_gpu::mlir::BoolAttr布林屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
filter 浮點數值的張量
out_backprop 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.Conv2DBackpropInput (TF::Conv2DBackpropInputOp)

計算關於輸入的卷積梯度。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)TF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
use_cudnn_on_gpu::mlir::BoolAttr布林屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
input_sizes 32 位元整數值的張量
filter bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量
out_backprop bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

tf.Conv2DBackpropInputV2 (TF::Conv2DBackpropInputV2Op)

計算關於輸入的卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
use_cudnn_on_gpu::mlir::BoolAttr布林屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量
filter bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量
out_backprop bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數值的張量

tf.Conv3D (TF::Conv3DOp)

計算給定 5 維度 inputfilter 張量的 3 維度卷積。

在訊號處理中,交叉相關性是用於衡量兩個波形相似度的指標,它是其中一個波形相對於另一個波形的時間延遲的函數。這也稱為滑動點積或滑動內積。

我們的 Conv3D 實作了一種形式的交叉相關性。

特性:AlwaysSpeculatableImplTraitInferTensorType

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
filter 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.Conv3DBackpropFilter (TF::Conv3DBackpropFilterOp)

計算關於篩選器的 3 維度卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
filter 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
out_backprop 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.Conv3DBackpropFilterV2 (TF::Conv3DBackpropFilterV2Op)

計算關於篩選器的 3 維度卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
filter_sizes 32 位元整數值的張量
out_backprop 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.Conv3DBackpropInput (TF::Conv3DBackpropInputOp)

計算關於輸入的 3 維度卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
filter 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
out_backprop 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.Conv3DBackpropInputV2 (TF::Conv3DBackpropInputV2Op)

計算關於輸入的 3 維度卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性
Tshape::mlir::Attribute衍生屬性

運算元

運算元 描述
input_sizes 32/64 位元帶正負號的整數值的張量
filter 浮點數值的張量
out_backprop 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.ConvertToCooTensor (TF::ConvertToCooTensorOp)

將張量轉換為 coo 格式的操作。

此操作會將密集、稀疏和參差不齊的張量轉換為標準 coo 張量格式,其中包含三個 1D 張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
combiner::mlir::StringAttr字串屬性

運算元

運算元 描述
indices_or_row_splits 32 位元整數值的張量
values 32 位元整數值的張量
weights 32 位元浮點數值的張量

結果

結果 描述
row_ids 32 位元整數值的張量
col_ids 32 位元整數值的張量
gains 32 位元浮點數值的張量

tf.ConvertToListOfSparseCoreCooTensors (TF::ConvertToListOfSparseCoreCooTensorsOp)

一個將稀疏/參差不齊/密集張量轉換為每個 SparseCore 的 COO 張量清單的操作。

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSizeSameVariadicResultSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
row_offset::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
col_offset::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
col_shift::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
num_sc_shards::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
stacked_table_sample_count::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
combiner::mlir::StringAttr字串屬性
num_sc_per_chip::mlir::Attribute衍生屬性

運算元

運算元 描述
indices_or_row_splits 32 位元整數值的張量
values 32 位元整數值的張量
weights 32 位元浮點數值的張量

結果

結果 描述
row_ids_list 32 位元整數值的張量的變數
col_ids_list 32 位元整數值的張量的變數
gains_list 32 位元浮點數值的張量的可變參數

tf.ConvertToSparseCoreCsrWrappedCooTensorOp (TF::ConvertToSparseCoreCsrWrappedCooTensorOp)

一個將排序後的 coo 張量轉換為稀疏核心 CSR 包裝的 COO 格式的操作。

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count_per_sc::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_replica::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_minibatches_per_sc::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_ids_per_chip_per_sample::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_vocab_size::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
feature_width::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性
allow_id_dropping::mlir::BoolAttr布林屬性
num_sc_per_chip::mlir::Attribute衍生屬性

運算元

運算元 描述
sorted_row_ids_list 32 位元整數值的張量的變數
sorted_col_ids_list 32 位元整數值的張量的變數
sorted_gains_list 32 位元浮點數值的張量的可變參數
id_counts_list 32 位元整數值的張量的變數
splits 64 位元整數值的張量

結果

結果 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
row_pointers_unpadded_size 32 位元整數值的張量
ids_unpadded_size 32 位元整數值的張量
num_minibatches_per_sc 32 位元整數值的張量

tf.Cos (TF::CosOp)

逐元素計算 x 的餘弦值。

給定輸入張量,此函數會計算張量中每個元素的餘弦值。輸入範圍為 (-inf, inf),輸出範圍為 [-1,1]。如果輸入超出邊界,則會傳回 nan

  x = tf.constant([-float("inf"), -9, -0.5, 1, 1.2, 200, 10000, float("inf")])
  tf.math.cos(x) ==> [nan -0.91113025 0.87758255 0.5403023 0.36235774 0.48718765 -0.95215535 nan]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Cosh (TF::CoshOp)

逐元素計算 x 的雙曲餘弦值。

給定輸入張量,此函數會計算張量中每個元素的雙曲餘弦值。輸入範圍為 [-inf, inf),輸出範圍為 [1, inf]

  x = tf.constant([-float("inf"), -9, -0.5, 1, 1.2, 2, 10, float("inf")])
  tf.math.cosh(x) ==> [inf 4.0515420e+03 1.1276259e+00 1.5430807e+00 1.8106556e+00 3.7621956e+00 1.1013233e+04 inf]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.CreateSummaryDbWriter (TF::CreateSummaryDbWriterOp)

建立可透過給定資源控制代碼存取的摘要資料庫寫入器。

這可用於將執行圖中的張量直接寫入資料庫。目前僅支援 SQLite。如果結構描述不存在,此函數將會建立結構描述。如果使用者、實驗和執行表中的項目尚不存在,則會自動建立。

writer:要覆寫的 SummaryWriter 資源的控制代碼。db_uri:例如 "file:/tmp/foo.sqlite"。experiment_name:不能包含 ASCII 控制字元或 <>。區分大小寫。如果為空,則執行將不會與任何實驗相關聯。run_name:不能包含 ASCII 控制字元或 <>。區分大小寫。如果為空,則每個標記都不會與任何執行相關聯。user_name:必須同時作為 DNS 標籤和 Linux 使用者名稱有效。如果為空,則實驗將不會與任何使用者相關聯。

運算元

運算元 描述
writer 資源值的張量
db_uri 字串值的張量
experiment_name 字串值的張量
run_name 字串值的張量
user_name 字串值的張量

tf.CreateSummaryFileWriter (TF::CreateSummaryFileWriterOp)

建立可透過給定資源控制代碼存取的摘要檔案寫入器。

writer:摘要寫入器資源的控制代碼 logdir:事件檔案將寫入的目錄。max_queue:待處理事件和摘要的佇列大小。flush_millis:以毫秒為單位,將待處理事件和摘要刷新到磁碟的頻率。filename_suffix:每個事件檔案的名稱都附加此後綴。

運算元

運算元 描述
writer 資源值的張量
logdir 字串值的張量
max_queue 32 位元整數值的張量
flush_millis 32 位元整數值的張量
filename_suffix 字串值的張量

tf.Cross (TF::CrossOp)

計算成對的叉積。

ab 必須具有相同的形狀;它們可以是簡單的 3 元素向量,或最內層維度為 3 的任何形狀。在後一種情況下,每對對應的 3 元素向量會獨立進行叉積。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 整數或浮點數值的張量
b 整數或浮點數值的張量

結果

結果 描述
product 整數或浮點數值的張量

tf.CrossReplicaSum (TF::CrossReplicaSumOp)

一個用於跨複製的 TPU 執行個體對輸入求和的運算。

每個執行個體提供自己的輸入。

例如,假設有 8 個 TPU 執行個體:[A, B, C, D, E, F, G, H]。傳遞 group_assignment=[[0,2,4,6],[1,3,5,7]] 會將 A, C, E, G 設定為群組 0,並將 B, D, F, H 設定為群組 1。因此,我們會得到輸出:[A+C+E+G, B+D+F+H, A+C+E+G, B+D+F+H, A+C+E+G, B+D+F+H, A+C+E+G, B+D+F+H]

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 32 位元無號整數值的張量
group_assignment 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 32 位元無號整數值的張量

tf.Cumprod (TF::CumprodOp)

沿著 axis 計算張量 x 的累積乘積。

依預設,此運算執行包含性累積乘積,這表示輸入的第一個元素與輸出的第一個元素相同

tf.cumprod([a, b, c])  # => [a, a * b, a * b * c]

透過將 exclusive kwarg 設定為 True,會改為執行互斥累積乘積

tf.cumprod([a, b, c], exclusive=True)  # => [1, a, a * b]

透過將 reverse kwarg 設定為 True,累積乘積會以相反方向執行

tf.cumprod([a, b, c], reverse=True)  # => [a * b * c, b * c, c]

這比使用個別的 tf.reverse 運算更有效率。

reverseexclusive kwargs 也可以組合使用

tf.cumprod([a, b, c], exclusive=True, reverse=True)  # => [b * c, c, 1]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
exclusive::mlir::BoolAttr布林屬性
reverse::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
x 數字值的張量
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
out 數字值的張量

tf.Cumsum (TF::CumsumOp)

沿著 axis 計算張量 x 的累積總和。

依預設,此運算執行包含性累積總和,這表示輸入的第一個元素與輸出的第一個元素相同

tf.cumsum([a, b, c])  # => [a, a + b, a + b + c]

透過將 exclusive kwarg 設定為 True,會改為執行互斥累積總和

tf.cumsum([a, b, c], exclusive=True)  # => [0, a, a + b]

透過將 reverse kwarg 設定為 True,累積總和會以相反方向執行

tf.cumsum([a, b, c], reverse=True)  # => [a + b + c, b + c, c]

這比使用個別的 tf.reverse 運算更有效率。

reverseexclusive kwargs 也可以組合使用

tf.cumsum([a, b, c], exclusive=True, reverse=True)  # => [b + c, c, 0]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
exclusive::mlir::BoolAttr布林屬性
reverse::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
x 數字值的張量
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
out 數字值的張量

tf.CumulativeLogsumexp (TF::CumulativeLogsumexpOp)

沿著 axis 計算張量 x 的累積乘積。

依預設,此運算執行包含性累積對數和指數,這表示輸入的第一個元素與輸出的第一個元素相同

tf.math.cumulative_logsumexp([a, b, c])  # => [a, log(exp(a) + exp(b)), log(exp(a) + exp(b) + exp(c))]

透過將 exclusive kwarg 設定為 True,會改為執行互斥累積對數和指數

tf.cumulative_logsumexp([a, b, c], exclusive=True)  # => [-inf, a, log(exp(a) * exp(b))]

請注意,對數和指數運算的 нейтральный 元素為 -inf,但是,基於效能考量,會改為使用浮點數類型可表示的最小值。

透過將 reverse kwarg 設定為 True,累積對數和指數會以相反方向執行。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
exclusive::mlir::BoolAttr布林屬性
reverse::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
out 浮點數值的張量

tf.DataFormatDimMap (TF::DataFormatDimMapOp)

傳回給定來源資料格式的目的地資料格式中的維度索引。

來源資料格式。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
src_format::mlir::StringAttr字串屬性
dst_format::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 32/64 位元帶正負號的整數值的張量

結果

結果 描述
y 32/64 位元帶正負號的整數值的張量

tf.DataFormatVecPermute (TF::DataFormatVecPermuteOp)

將輸入張量從 src_format 置換為 dst_format

給定長度為 n=4 或 5 的來源和目的地格式字串,輸入張量必須是大小為 n 或 n-2 的向量,或是形狀為 (n, 2) 或 (n-2, 2) 的 2D 張量。

如果輸入張量的第一個維度為 n-2,則假設省略了非空間維度 (即 NC)。

例如,使用 src_formatNHWCdst_formatNCHW 和輸入

[1, 2, 3, 4]

,輸出將為

[1, 4, 2, 3]

使用 src_formatNDHWCdst_formatNCDHW 和輸入

[[1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]

,輸出將為

[[1, 6], [5, 10], [2, 7], [3, 8], [4, 9]]

使用 src_formatNHWCdst_formatNCHW 和輸入

[1, 2]

,輸出將為

[1, 2]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
src_format::mlir::StringAttr字串屬性
dst_format::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 32/64 位元帶正負號的整數值的張量

結果

結果 描述
y 32/64 位元帶正負號的整數值的張量

tf.DebugIdentityV2 (TF::DebugIdentityV2Op)

Debug Identity V2 運算。

提供從輸入到輸出的身分對應,同時透過呼叫 DebugEventsWriter 寫入輸入張量的內容。

輸入張量的語意取決於 tensor_debug_mode。在一般用法中,只有在 graph_debug_mode 為 FULL_TENSOR 時,輸入張量才會直接來自使用者計算 (請參閱 protobuf/debug_event.proto 以取得 graph_debug_mode 所有可能值的清單)。對於其他偵錯模式,輸入張量應由額外的運算或子圖產生,以計算關於一個或多個張量的摘要資訊。

屬性

屬性MLIR 類型描述
tfdbg_context_id::mlir::StringAttr字串屬性
op_name::mlir::StringAttr字串屬性
output_slot::mlir::IntegerAttr64 位元無號整數屬性
tensor_debug_mode::mlir::IntegerAttr64 位元無號整數屬性
debug_urls::mlir::ArrayAttr字串陣列屬性
circular_buffer_size::mlir::IntegerAttr64 位元無號整數屬性
tfdbg_run_id::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.DecodeAndCropJpeg (TF::DecodeAndCropJpegOp)

解碼和裁剪 JPEG 編碼的影像為 uint8 張量。

屬性 channels 指出已解碼影像所需的色彩通道數。

接受的值為

  • 0:使用 JPEG 編碼影像中的通道數。
  • 1:輸出灰階影像。
  • 3:輸出 RGB 影像。

如果需要,JPEG 編碼影像會轉換為符合要求的色彩通道數。

屬性 ratio 允許在解碼期間將影像按整數因子縮小。允許的值為:1、2、4 和 8。這比稍後縮小影像快得多。

它相當於解碼和裁剪的組合,但透過僅解碼部分 jpeg 影像而快得多。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
channels::mlir::IntegerAttr64 位元無號整數屬性
ratio::mlir::IntegerAttr64 位元無號整數屬性
fancy_upscaling::mlir::BoolAttr布林屬性
try_recover_truncated::mlir::BoolAttr布林屬性
acceptable_fraction::mlir::FloatAttr32 位元浮點屬性
dct_method::mlir::StringAttr字串屬性

運算元

運算元 描述
contents 字串值的張量
crop_window 32 位元整數值的張量

結果

結果 描述
image 8 位元無號整數值的張量

tf.DecodeGif (TF::DecodeGifOp)

將 GIF 編碼影像的影格解碼為 uint8 張量。

不支援具有影格或透明度壓縮的 GIF 影像。在 Linux 和 MacOS 系統上,將動畫 GIF 從壓縮轉換為未壓縮,方法是執行

convert \\(src.gif -coalesce \\)dst.gif

此運算也支援解碼 JPEG 和 PNG,但使用 tf.io.decode_image 會更簡潔。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
contents 字串值的張量

結果

結果 描述
image 8 位元無號整數值的張量

tf.DecodeJpeg (TF::DecodeJpegOp)

將 JPEG 編碼的影像解碼為 uint8 張量。

屬性 channels 指出已解碼影像所需的色彩通道數。

接受的值為

  • 0:使用 JPEG 編碼影像中的通道數。
  • 1:輸出灰階影像。
  • 3:輸出 RGB 影像。

如果需要,JPEG 編碼影像會轉換為符合要求的色彩通道數。

屬性 ratio 允許在解碼期間將影像按整數因子縮小。允許的值為:1、2、4 和 8。這比稍後縮小影像快得多。

此運算也支援解碼 PNG 和非動畫 GIF,因為介面相同,但使用 tf.io.decode_image 會更簡潔。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
channels::mlir::IntegerAttr64 位元無號整數屬性
ratio::mlir::IntegerAttr64 位元無號整數屬性
fancy_upscaling::mlir::BoolAttr布林屬性
try_recover_truncated::mlir::BoolAttr布林屬性
acceptable_fraction::mlir::FloatAttr32 位元浮點屬性
dct_method::mlir::StringAttr字串屬性

運算元

運算元 描述
contents 字串值的張量

結果

結果 描述
image 8 位元無號整數值的張量

tf.DecodePaddedRaw (TF::DecodePaddedRawOp)

將字串的位元組重新解譯為數字向量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
little_endian::mlir::BoolAttr布林屬性
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
input_bytes 字串值的張量
fixed_length 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 8 位元無號整數值的張量

tf.DecodePng (TF::DecodePngOp)

將 PNG 編碼的影像解碼為 uint8 或 uint16 張量。

屬性 channels 指出已解碼影像所需的色彩通道數。

接受的值為

  • 0:使用 PNG 編碼影像中的通道數。
  • 1:輸出灰階影像。
  • 3:輸出 RGB 影像。
  • 4:輸出 RGBA 影像。

如果需要,PNG 編碼影像會轉換為符合要求的色彩通道數。

此運算也支援解碼 JPEG 和非動畫 GIF,因為介面相同,但使用 tf.io.decode_image 會更簡潔。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
channels::mlir::IntegerAttr64 位元無號整數屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
contents 字串值的張量

結果

結果 描述
image 16 位元無號整數或 8 位元無號整數值的張量

tf.DeleteIterator (TF::DeleteIteratorOp)

迭代器資源的容器。

運算元

運算元 描述
handle 資源值的張量
deleter 變體值的張量

tf.DeleteMemoryCache (TF::DeleteMemoryCacheOp)

運算元

運算元 描述
handle 資源值的張量
deleter 變體值的張量

tf.DeleteMultiDeviceIterator (TF::DeleteMultiDeviceIteratorOp)

迭代器資源的容器。

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性

運算元

運算元 描述
multi_device_iterator 資源值的張量
iterators 資源值的張量的可變參數
deleter 變體值的張量

tf.DeleteRandomSeedGenerator (TF::DeleteRandomSeedGeneratorOp)

運算元

運算元 描述
handle 資源值的張量
deleter 變體值的張量

tf.DeleteSeedGenerator (TF::DeleteSeedGeneratorOp)

運算元

運算元 描述
handle 資源值的張量
deleter 變體值的張量

tf.DepthToSpace (TF::DepthToSpaceOp)

T 類型張量的 DepthToSpace。

將資料從深度重新排列到空間資料區塊。這是 SpaceToDepth 的反向轉換。更具體來說,此運算會輸出輸入張量的副本,其中 depth 維度中的值會以空間區塊移動到 heightwidth 維度。屬性 block_size 指出輸入區塊大小以及資料的移動方式。

  • 大小為 block_size * block_size 的深度資料區塊會重新排列到大小為 block_size x block_size 的非重疊區塊
  • 輸出張量的寬度為 input_depth * block_size,而高度為 input_height * block_size
  • 輸出影像每個區塊中的 Y、X 座標由輸入通道索引的高階元件決定。
  • 輸入張量的深度必須可被 block_size * block_size 整除。

data_format 屬性使用以下選項指定輸入和輸出張量的版面配置:"NHWC":[ batch, height, width, channels ] "NCHW":[ batch, channels, height, width ] "NCHW_VECT_C":qint8 [ batch, channels / 4, height, width, 4 ]

將運算視為轉換 6 維度張量會很有用。例如,對於 data_format = NHWC,輸入張量中的每個元素都可以透過 6 個座標指定,依記憶體版面配置重要性降序排列為:n,iY,iX,bY,bX,oC (其中 n=批次索引,iX, iY 表示輸入影像中的 X 或 Y 座標,bX, bY 表示輸出區塊中的座標,oC 表示輸出通道)。輸出會是輸入轉置為以下版面配置:n,iY,bY,iX,bX,oC

此運算適用於調整卷積之間的啟動大小 (但保留所有資料),例如,而不是池化。它也適用於訓練純粹的卷積模型。

例如,給定形狀為 [1, 1, 1, 4]、data_format = "NHWC" 和 block_size = 2 的輸入

x = [[[[1, 2, 3, 4]]]]

此運算會輸出形狀為 [1, 2, 2, 1] 的張量

   [[[[1], [2]],
     [[3], [4]]]]

在這裡,輸入的批次大小為 1,且每個批次元素的形狀為 [1, 1, 4],對應的輸出將具有 2x2 個元素,且深度為 1 個通道 (1 = 4 / (block_size * block_size))。輸出元素形狀為 [2, 2, 1]

對於具有較大深度的輸入張量,例如形狀為 [1, 1, 1, 12]

x = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]

此運算對於區塊大小為 2,將傳回以下形狀為 [1, 2, 2, 3] 的張量

   [[[[1, 2, 3], [4, 5, 6]],
     [[7, 8, 9], [10, 11, 12]]]]

同樣地,對於以下形狀為 [1 2 2 4] 和區塊大小為 2 的輸入

x =  [[[[1, 2, 3, 4],
       [5, 6, 7, 8]],
      [[9, 10, 11, 12],
       [13, 14, 15, 16]]]]

運算子將傳回以下形狀為 [1 4 4 1] 的張量

x = [[[ [1],   [2],  [5],  [6]],
      [ [3],   [4],  [7],  [8]],
      [ [9],  [10], [13],  [14]],
      [ [11], [12], [15],  [16]]]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
block_size::mlir::IntegerAttr最小值為 2 的 64 位元無號整數屬性
data_format::mlir::StringAttr值為 NHWC、NCHW 或 NCHW_VECT_C 的字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.DepthwiseConv2dNative (TF::DepthwiseConv2dNativeOp)

計算給定 4 維度 inputfilter 張量的 2 維度深度可分離卷積。

給定形狀為 [batch, in_height, in_width, in_channels] 的輸入張量,以及形狀為 [filter_height, filter_width, in_channels, channel_multiplier] 的篩選器/核心張量,其中包含深度為 1 的 in_channels 個卷積篩選器,depthwise_conv2d 會將不同的篩選器套用至每個輸入通道 (從 1 個通道擴展到每個通道 channel_multiplier 個通道),然後將結果串連在一起。因此,輸出具有 in_channels * channel_multiplier 個通道。

for k in 0..in_channels-1
  for q in 0..channel_multiplier-1
    output[b, i, j, k * channel_multiplier + q] =
      sum_{di, dj} input[b, strides[1] * i + di, strides[2] * j + dj, k] *
                        filter[di, dj, k, q]

必須具有 strides[0] = strides[3] = 1。對於最常見的相同水平和垂直步幅情況,strides = [1, stride, stride, 1]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
filter 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.DepthwiseConv2dNativeBackpropFilter (TF::DepthwiseConv2dNativeBackpropFilterOp)

計算關於篩選器的深度可分離卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
filter_sizes 32 位元整數值的張量
out_backprop 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.DepthwiseConv2dNativeBackpropInput (TF::DepthwiseConv2dNativeBackpropInputOp)

計算關於輸入的深度可分離卷積梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strides::mlir::ArrayAttr64 位元整數陣列屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
dilations::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
input_sizes 32 位元整數值的張量
filter 浮點數值的張量
out_backprop 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.Dequantize (TF::DequantizeOp)

將 'input' 張量反量化為浮點數或 bfloat16 張量。

[min_range, max_range] 是純量浮點數,用於指定輸出的範圍。 'mode' 屬性控制用於將浮點數值轉換為其量化等效值的確切計算。

在 'MIN_COMBINED' 模式中,張量的每個值都將經歷以下過程

if T == qint8: in[i] += (range(T) + 1)/ 2.0
out[i] = min_range + (in[i]* (max_range - min_range) / range(T))

此處 range(T) = numeric_limits<T>::max() - numeric_limits<T>::min()

MIN_COMBINED 模式範例

如果輸入來自 QuantizedRelu6,則輸出類型為 quint8 (範圍為 0-255),但 QuantizedRelu6 的可能範圍為 0-6。因此,min_range 和 max_range 值分別為 0.0 和 6.0。quint8 的反量化將取每個值、轉換為浮點數,然後乘以 6 / 255。請注意,如果 quantizedtype 為 qint8,則運算會在轉換之前額外將每個值加上 128。

如果模式為 'MIN_FIRST',則會使用此方法

num_discrete_values = 1 << (# of bits in T)
range_adjust = num_discrete_values / (num_discrete_values - 1)
range = (range_max - range_min) * range_adjust
range_scale = range / num_discrete_values
const double offset_input = static_cast<double>(input) - lowest_quantized;
result = range_min + ((input - numeric_limits<T>::min()) * range_scale)

如果模式為 SCALED,則透過將每個輸入值乘以 scaling_factor 來執行反量化。(因此,輸入 0 始終會對應到 0.0)。

scaling_factor 是從 min_rangemax_rangenarrow_range 以與 QuantizeAndDequantize{V2|V3}QuantizeV2 相容的方式判斷,使用以下演算法


  const int min_expected_T = std::numeric_limits<T>::min() +
    (narrow_range ? 1 : 0);
  const int max_expected_T = std::numeric_limits<T>::max();
  const float max_expected_T = std::numeric_limits<float>::max();

  const float scale_factor =
    (std::numeric_limits<T>::min() == 0) ? (max_range / max_expected_T)
                                         : std::max(min_range / min_expected_T,
                                                    max_range / max_expected_T);

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
mode::mlir::StringAttr字串屬性,其值為 MIN_COMBINED、MIN_FIRST 或 SCALED
narrow_range::mlir::BoolAttr布林屬性
axis::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數值的張量
min_range 32 位元浮點數值的張量
max_range 32 位元浮點數值的張量

結果

結果 描述
輸出 bfloat16 或 32 位元浮點數值的張量

tf.DeserializeIterator (TF::DeserializeIteratorOp)

將給定的變體張量轉換為迭代器,並將其儲存在給定的資源中。

運算元

運算元 描述
resource_handle 資源值的張量
serialized 變體值的張量

tf.DeserializeSparse (TF::DeserializeSparseOp)

還原序列化 SparseTensor 物件。

輸入 serialized_sparse 的形狀必須為 [?, ?, ..., ?, 3],其中最後一個維度儲存序列化的 SparseTensor 物件,而其他 N 個維度 (N >= 0) 對應於批次。原始 SparseTensor 物件的秩都必須相符。建立最終的 SparseTensor 時,其秩為傳入 SparseTensor 物件的秩加上 N;稀疏張量已沿著新的維度串連,每個批次一個維度。

原始維度的輸出 SparseTensor 物件的形狀值是跨輸入 SparseTensor 物件的形狀值針對對應維度的最大值。新的維度與批次的大小相符。

輸入 SparseTensor 物件的索引假設以標準詞典順序排序。如果不是這種情況,請在此步驟之後執行 SparseReorder 以還原索引排序。

例如,如果序列化輸入是代表兩個原始 SparseTensor 物件的 [2 x 3] 矩陣

index = [ 0]
        [10]
        [20]
values = [1, 2, 3]
shape = [50]

index = [ 2]
        [10]
values = [4, 5]
shape = [30]

則最終還原序列化的 SparseTensor 將為

index = [0  0]
        [0 10]
        [0 20]
        [1  2]
        [1 10]
values = [1, 2, 3, 4, 5]
shape = [2 50]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tserialized::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
serialized_sparse 字串或變體值的張量

結果

結果 描述
sparse_indices 64 位元整數值的張量
sparse_values tf.dtype 值的張量
sparse_shape 64 位元整數值的張量

tf.DestroyResourceOp (TF::DestroyResourceOp)

刪除控制代碼指定的資源。

所有後續使用資源的運算都會導致 NotFound 錯誤狀態。

屬性

屬性MLIR 類型描述
ignore_lookup_error::mlir::BoolAttr布林屬性

運算元

運算元 描述
resource 資源值的張量

tf.DeviceIndex (TF::DeviceIndexOp)

傳回運算執行的裝置索引。

給定裝置名稱清單,此運算會傳回此運算執行的裝置索引。在兩種情況下會傳回清單的長度:(1) 裝置在給定的裝置清單中不存在。(2) 它在 XLA 編譯中。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
device_names::mlir::ArrayAttr字串陣列屬性

結果

結果 描述
index 32 位元整數值的張量

tf.Diag (TF::DiagOp)

傳回具有給定對角線值的對角線張量。

給定 diagonal,此運算會傳回具有 diagonal 的張量,以及以零填補的所有其他內容。對角線的計算方式如下

假設 diagonal 的維度為 [D1,..., Dk],則輸出是秩為 2k 的張量,維度為 [D1,..., Dk, D1,..., Dk],其中

output[i1,..., ik, i1,..., ik] = diagonal[i1, ..., ik],其他位置為 0。

例如

# 'diagonal' is [1, 2, 3, 4]
tf.diag(diagonal) ==> [[1, 0, 0, 0]
                       [0, 2, 0, 0]
                       [0, 0, 3, 0]
                       [0, 0, 0, 4]]

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
diagonal bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.DiagPart (TF::DiagPartOp)

傳回張量的對角線部分。

此運算會傳回具有 inputdiagonal 部分的張量。diagonal 部分的計算方式如下

假設 input 的維度為 [D1,..., Dk, D1,..., Dk],則輸出是秩為 k 的張量,維度為 [D1,..., Dk],其中

diagonal[i1,..., ik] = input[i1, ..., ik, i1,..., ik].

例如

# 'input' is [[1, 0, 0, 0]
              [0, 2, 0, 0]
              [0, 0, 3, 0]
              [0, 0, 0, 4]]

tf.diag_part(input) ==> [1, 2, 3, 4]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
diagonal bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.Digamma (TF::DigammaOp)

逐元素計算 Psi,即 Lgamma (的絕對值對數) 的導數

Gamma(x))。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.DisableCopyOnRead (TF::DisableCopyOnReadOp)

關閉讀取時複製模式。

關閉資源變數的讀取時複製模式。如果變數未處於讀取時複製模式,則此運算沒有任何作用。

運算元

運算元 描述
resource 資源值的張量

tf.Div (TF::DivOp)

逐元素傳回 x / y。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.DivNoNan (TF::DivNoNanOp)

如果分母為零,則傳回 0。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量
y 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.DummyMemoryCache (TF::DummyMemoryCacheOp)

結果

結果 描述
handle 資源值的張量

tf.DummySeedGenerator (TF::DummySeedGeneratorOp)

結果

結果 描述
handle 資源值的張量

tf.DynamicEnqueueTPUEmbeddingArbitraryTensorBatch (TF::DynamicEnqueueTPUEmbeddingArbitraryTensorBatchOp)

_簡化使用 tf.nn.embedding_lookup_sparse() 的程式碼移植。_

embedding_indices[i] 和 aggregation_weights[i] 對應於第 i 個特徵。

三個輸入清單 (sample_indices、embedding_indices 和 aggregation_weights) 中對應位置的張量必須具有相同的形狀,即秩為 1,且 dim_size() 等於對應特徵描述的表格的總查詢次數。

特性:SameVariadicOperandSize

介面:TF_TPUEmbeddingWriteEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::TPUEmbedding}

屬性

屬性MLIR 類型描述
combiners::mlir::ArrayAttr字串陣列屬性
N::mlir::Attribute衍生屬性
T1::mlir::Attribute衍生屬性
T2::mlir::Attribute衍生屬性
T3::mlir::Attribute衍生屬性

運算元

運算元 描述
sample_indices_or_row_splits 32/64 位元有號整數值的張量變數
embedding_indices 32/64 位元有號整數值的張量變數
aggregation_weights 32/64 位元浮點數值的張量變數
mode_override 字串值的張量
device_ordinal 32 位元整數值的張量

tf.DynamicPartition (TF::DynamicPartitionOp)

使用來自 partitions 的索引,將 data 分割為 num_partitions 個張量。

對於大小為 partitions.ndim 的每個索引元組 js,切片 data[js, ...] 會變成 outputs[partitions[js]] 的一部分。partitions[js] = i 的切片會依 js 的詞典編纂順序放置在 outputs[i] 中,且 outputs[i] 的第一個維度是 partitions 中等於 i 的條目數。詳情如下:

    outputs[i].shape = [sum(partitions == i)] + data.shape[partitions.ndim:]

    outputs[i] = pack([data[js, ...] for js if partitions[js] == i])

data.shape 必須以 partitions.shape 開頭。

例如

    # Scalar partitions.
    partitions = 1
    num_partitions = 2
    data = [10, 20]
    outputs[0] = []  # Empty with shape [0, 2]
    outputs[1] = [[10, 20]]

    # Vector partitions.
    partitions = [0, 0, 1, 1, 0]
    num_partitions = 2
    data = [10, 20, 30, 40, 50]
    outputs[0] = [10, 20, 50]
    outputs[1] = [30, 40]

請參閱 dynamic_stitch 以取得如何將分割區合併回去的範例。

引發

  • 在下列情況中引發 InvalidArgumentError
    • 如果 partitions 不在範圍 [0, num_partiions)
    • 如果 partitions.shapedata.shape 引數的前綴不符。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
num_partitions::mlir::Attribute衍生屬性

運算元

運算元 描述
data tf.dtype 值的張量
partitions 32 位元整數值的張量

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf.DynamicStitch (TF::DynamicStitchOp)

data 張量的值交錯放入單一張量。

建構一個合併的張量,使得

    merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]

例如,如果每個 indices[m] 是純量或向量,則我們有

    # Scalar indices:
    merged[indices[m], ...] = data[m][...]

    # Vector indices:
    merged[indices[m][i], ...] = data[m][i, ...]

每個 data[i].shape 必須以對應的 indices[i].shape 開頭,且 data[i].shape 的其餘部分必須相對於 i 保持恆定。也就是說,我們必須有 data[i].shape = indices[i].shape + constant。根據此 constant,輸出形狀為

merged.shape = [max(indices) + 1] + constant

值會依序合併,因此如果索引同時出現在 indices[m][i]indices[n][j] 中,且 (m,i) < (n,j),則切片 data[n][j] 將會出現在合併結果中。如果您不需要此保證,則 ParallelDynamicStitch 在某些裝置上可能會表現更好。

例如

    indices[0] = 6
    indices[1] = [4, 1]
    indices[2] = [[5, 2], [0, 3]]
    data[0] = [61, 62]
    data[1] = [[41, 42], [11, 12]]
    data[2] = [[[51, 52], [21, 22]], [[1, 2], [31, 32]]]
    merged = [[1, 2], [11, 12], [21, 22], [31, 32], [41, 42],
              [51, 52], [61, 62]]

此方法可用於合併由 dynamic_partition 建立的分割區,如下列範例所示

    # Apply function (increments x_i) on elements for which a certain condition
    # apply (x_i != -1 in this example).
    x=tf.constant([0.1, -1., 5.2, 4.3, -1., 7.4])
    condition_mask=tf.not_equal(x,tf.constant(-1.))
    partitioned_data = tf.dynamic_partition(
        x, tf.cast(condition_mask, tf.int32) , 2)
    partitioned_data[1] = partitioned_data[1] + 1.0
    condition_indices = tf.dynamic_partition(
        tf.range(tf.shape(x)[0]), tf.cast(condition_mask, tf.int32) , 2)
    x = tf.dynamic_stitch(condition_indices, partitioned_data)
    # Here x=[1.1, -1., 6.2, 5.3, -1, 8.4], the -1. values remain
    # unchanged.

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
indices 32 位元整數值的張量的變數
data tf.dtype 值的張量的可變參數

結果

結果 描述
merged tf.dtype 值的張量

tf.Einsum (TF::EinsumOp)

根據愛因斯坦求和約定進行張量縮併。

實作廣義張量縮併和縮減。每個輸入張量都必須在方程式的逗號分隔左側具有對應的輸入下標。方程式的右側包含輸出下標。輸入下標和輸出下標應包含零或多個具名軸標籤和最多一個省略號 (...)。

具名軸標籤可以是任何單一字元,但具有特殊含義的字元除外,即 ,.->。如果此 Op 收到格式錯誤的方程式,則此 Op 的行為未定義;由於驗證是在圖形建構時完成的,因此我們在執行階段省略了格式驗證檢查。

根據下列規則將運算套用至輸入:

(a) 廣義對角線:對於對應於在同一個輸入下標中出現多次的軸標籤的輸入維度,我們採用廣義(k 維)對角線。例如,在方程式 iii->i 中,輸入形狀為 [3, 3, 3],廣義對角線將包含索引 (0, 0, 0)(1, 1, 1)(2, 2, 2) 處的 3 個元素,以建立形狀為 [3] 的張量。

(b) 縮減:對應於僅在一個輸入下標中出現但未在輸出下標中出現的標籤的軸,在張量縮併之前會被加總。例如,在方程式 ab,bc->b 中,軸標籤 ac 是縮減軸標籤。

(c) 批次維度:對應於出現在每個輸入下標以及輸出下標中的標籤的軸,構成張量縮併中的批次維度。對應於省略號 (...) 的未命名軸標籤也對應於批次維度。例如,對於表示批次矩陣乘法的方程式 bij,bjk->bik,軸標籤 b 對應於批次維度。

(d) 縮併:在二元 einsum 的情況下,對應於出現在兩個不同輸入(且未在輸出中)中的標籤的軸會彼此縮併。再次考慮批次矩陣乘法方程式 (bij,bjk->bik),縮併軸標籤為 j

(e) 展開對角線:如果輸出下標包含重複的(明確)軸標籤,則會套用 (a) 的相反運算。例如,在方程式 i->iii 和輸入形狀 [3] 中,形狀為 [3, 3, 3] 的輸出全部為零,但(廣義)對角線除外,該對角線會填入來自輸入的值。注意:np.einsumtf.einsum 不支援此運算;提供此運算旨在啟用計算 tf.einsum 的符號梯度。

輸出下標必須僅包含出現在至少一個輸入下標中的標籤。此外,對應於相同軸標籤的所有維度都必須相等。

任何輸入和輸出下標都可能最多包含一個省略號 (...)。這些省略號會對應於不對應於任何具名軸標籤的維度。如果兩個輸入包含省略號,則會根據標準 NumPy 廣播 規則 廣播它們。

廣播維度會放置在輸出下標中省略號的對應位置。如果廣播維度為非空,且輸出下標不包含省略號,則會引發 InvalidArgument 錯誤。

@compatibility(numpy) 類似於 numpy.einsum

numpy.einsum 比較

  • 此 Op 僅支援 numpy.einsum 的一元和二元形式。
  • 此 Op 不支援隱含形式。(即沒有 -> 的方程式)。
  • 此 Op 也支援輸出下標中重複的索引,numpy.einsum 不支援此功能。@end_compatibility

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
equation::mlir::StringAttr字串屬性
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Elu (TF::EluOp)

計算指數線性函數。

ELU 函數定義為

  • \( e ^ x - 1 \) 如果 \( x < 0 \)
  • \( x \) 如果 \( x >= 0 \)

範例

tf.nn.elu(1.0)tf.nn.elu(0.0)tf.nn.elu(-1000.0)

請參閱 指數線性單位 (ELU) 的快速且準確的深度網路學習

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features 浮點數值的張量

結果

結果 描述
activations 浮點數值的張量

tf.EluGrad (TF::EluGradOp)

計算指數線性 (Elu) 運算的梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 浮點數值的張量
outputs 浮點數值的張量

結果

結果 描述
backprops 浮點數值的張量

tf.Empty (TF::EmptyOp)

_建立具有指定形狀的張量。

此運算會建立具有 shapedtype 的張量。_

屬性

屬性MLIR 類型描述
init::mlir::BoolAttr布林屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.EmptyTensorList (TF::EmptyTensorListOp)

建立並傳回空的張量清單。

所有清單元素都必須是 dtype element_dtype 的張量,且形狀與 element_shape 相容。

handle:空的張量清單。element_dtype:清單中元素的類型。element_shape:與清單中元素的形狀相容的形狀。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
shape_type::mlir::Attribute衍生屬性
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
element_shape 32/64 位元帶正負號的整數值的張量
max_num_elements 32 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.EncodePng (TF::EncodePngOp)

PNG 編碼影像。

image 是形狀為 [height, width, channels] 的 3D uint8 或 uint16 張量,其中 channels

  • 1:用於灰階。
  • 2:用於灰階 + Alpha。
  • 3:用於 RGB。
  • 4:用於 RGBA。

ZLIB 壓縮層級 compression 可以是 PNG 編碼器預設值 -1 或介於 0 到 9 之間的值。9 是最高壓縮層級,產生最小的輸出,但速度較慢。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
compression::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
image 16 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
contents 字串值的張量

tf.EnqueueTPUEmbeddingArbitraryTensorBatch (TF::EnqueueTPUEmbeddingArbitraryTensorBatchOp)

_簡化使用 tf.nn.embedding_lookup_sparse() 的程式碼移植。_

embedding_indices[i] 和 aggregation_weights[i] 對應於第 i 個特徵。

三個輸入清單 (sample_indices、embedding_indices 和 aggregation_weights) 中對應位置的張量必須具有相同的形狀,即秩為 1,且 dim_size() 等於對應特徵描述的表格的總查詢次數。

特性:SameVariadicOperandSize

介面:GetResourceInstanceInterfaceTF_TPUEmbeddingWriteEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::TPUEmbedding}

屬性

屬性MLIR 類型描述
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
combiners::mlir::ArrayAttr字串陣列屬性
N::mlir::Attribute衍生屬性
T1::mlir::Attribute衍生屬性
T2::mlir::Attribute衍生屬性
T3::mlir::Attribute衍生屬性

運算元

運算元 描述
sample_indices_or_row_splits 32/64 位元有號整數值的張量變數
embedding_indices 32/64 位元有號整數值的張量變數
aggregation_weights 32/64 位元浮點數值的張量變數
mode_override 字串值的張量

tf.EnqueueTPUEmbeddingBatch (TF::EnqueueTPUEmbeddingBatchOp)

一個將輸入批次張量清單排入 TPUEmbedding 佇列的運算。

一個將輸入批次張量清單排入 TPUEmbedding 佇列的運算。

介面:GetResourceInstanceInterfaceTF_TPUEmbeddingWriteEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::TPUEmbedding}

屬性

屬性MLIR 類型描述
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
combiners::mlir::ArrayAttr字串陣列屬性
N::mlir::Attribute衍生屬性

運算元

運算元 描述
batch 字串值的張量的可變參數
mode_override 字串值的張量

tf.EnqueueTPUEmbeddingIntegerBatch (TF::EnqueueTPUEmbeddingIntegerBatchOp)

一個將輸入批次張量清單排入 TPUEmbedding 佇列的運算。

介面:GetResourceInstanceInterfaceTF_TPUEmbeddingWriteEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::TPUEmbedding}

屬性

屬性MLIR 類型描述
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
N::mlir::Attribute衍生屬性

運算元

運算元 描述
batch 32 位元整數值的張量的變數
mode_override 字串值的張量

tf.EnqueueTPUEmbeddingRaggedTensorBatch (TF::EnqueueTPUEmbeddingRaggedTensorBatchOp)

_簡化使用 tf.nn.embeddinglookup() 的程式碼移植。

sample_splits[i]、embedding_indices[i] 和 aggregation_weights[i] 對應於第 i 個特徵。table_ids[i] 指出要查閱第 i 個特徵的嵌入表。

輸入清單中兩個對應位置的張量(embedding_indices 和 aggregation_weights)必須具有相同的形狀,即等級 1,且 dim_size() 等於查閱對應特徵所描述的表中的總次數。

特性:SameVariadicOperandSize

介面:GetResourceInstanceInterfaceTF_TPUEmbeddingWriteEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::TPUEmbedding}

屬性

屬性MLIR 類型描述
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
combiners::mlir::ArrayAttr字串陣列屬性
table_ids::mlir::ArrayAttr64 位元整數陣列屬性
max_sequence_lengths::mlir::ArrayAttr64 位元整數陣列屬性
num_features::mlir::ArrayAttr64 位元整數陣列屬性
N::mlir::Attribute衍生屬性
T1::mlir::Attribute衍生屬性
T2::mlir::Attribute衍生屬性
T3::mlir::Attribute衍生屬性

運算元

運算元 描述
sample_splits 32/64 位元有號整數值的張量變數
embedding_indices 32/64 位元有號整數值的張量變數
aggregation_weights 32/64 位元浮點數值的張量變數
mode_override 字串值的張量

tf.EnqueueTPUEmbeddingSparseBatch (TF::EnqueueTPUEmbeddingSparseBatchOp)

一個從 SparseTensor 將 TPUEmbedding 輸入索引排入佇列的運算。

此 Op 簡化了使用 embedding_lookup_sparse() 的程式碼移植,儘管需要對 SparseTensor 引數進行一些 Python 預先處理,才能產生此 Op 的引數,因為每個訓練步驟只允許一個 EnqueueTPUEmbeddingSparseBatch Op。

三個輸入清單中對應位置的張量必須具有相同的形狀,即等級 1,且 dim_size() 等於查閱對應 table_id 所描述的表中的總次數。

特性:SameVariadicOperandSize

介面:GetResourceInstanceInterfaceTF_TPUEmbeddingWriteEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::TPUEmbedding}

屬性

屬性MLIR 類型描述
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
combiners::mlir::ArrayAttr字串陣列屬性
N::mlir::Attribute衍生屬性
T1::mlir::Attribute衍生屬性
T2::mlir::Attribute衍生屬性
T3::mlir::Attribute衍生屬性

運算元

運算元 描述
sample_indices 32/64 位元有號整數值的張量變數
embedding_indices 32/64 位元有號整數值的張量變數
aggregation_weights 32/64 位元浮點數值的張量變數
mode_override 字串值的張量

tf.EnqueueTPUEmbeddingSparseTensorBatch (TF::EnqueueTPUEmbeddingSparseTensorBatchOp)

_簡化使用 tf.nn.embedding_lookup_sparse() 的程式碼移植。_

sample_indices[i]、embedding_indices[i] 和 aggregation_weights[i] 對應於第 i 個特徵。table_ids[i] 指出要查閱第 i 個特徵的嵌入表。

三個輸入清單 (sample_indices、embedding_indices 和 aggregation_weights) 中對應位置的張量必須具有相同的形狀,即秩為 1,且 dim_size() 等於對應特徵描述的表格的總查詢次數。

特性:SameVariadicOperandSize

介面:GetResourceInstanceInterfaceTF_TPUEmbeddingWriteEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::TPUEmbedding}

屬性

屬性MLIR 類型描述
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性
combiners::mlir::ArrayAttr字串陣列屬性
table_ids::mlir::ArrayAttr64 位元整數陣列屬性
max_sequence_lengths::mlir::ArrayAttr64 位元整數陣列屬性
num_features::mlir::ArrayAttr64 位元整數陣列屬性
N::mlir::Attribute衍生屬性
T1::mlir::Attribute衍生屬性
T2::mlir::Attribute衍生屬性
T3::mlir::Attribute衍生屬性

運算元

運算元 描述
sample_indices 32/64 位元有號整數值的張量變數
embedding_indices 32/64 位元有號整數值的張量變數
aggregation_weights 32/64 位元浮點數值的張量變數
mode_override 字串值的張量

tf.EnsureShape (TF::EnsureShapeOp)

確保張量的形狀符合預期形狀。

如果輸入張量的形狀與指定的形狀不符,則會引發錯誤。否則傳回輸入張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
shape::mlir::AttributeTensorFlow 形狀屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Equal (TF::EqualOp)

傳回 (x == y) 元素方式的真值。

x = tf.constant([2, 4])
y = tf.constant(2)
tf.math.equal(x, y) ==> array([True, False])

x = tf.constant([2, 4])
y = tf.constant([2, 4])
tf.math.equal(x, y) ==> array([True,  True])

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
incompatible_shape_error::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
y tf.dtype 值的張量

結果

結果 描述
z 布林值的張量

tf.Erf (TF::ErfOp)

以元素方式計算 x高斯誤差函數。在統計學中,對於 \(x\) 的非負值,誤差函數具有以下解釋:對於隨機變數 \(Y\),其常態分佈的平均值為 0,變異數為 \(1/\sqrt{2}\),\(erf(x)\) 是 \(Y\) 落在範圍 \([−x, x]\) 內的機率。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.Erfc (TF::ErfcOp)

以元素方式計算 x 的互補誤差函數。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.Erfinv (TF::ErfinvOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.ExecuteTPUEmbeddingPartitioner (TF::ExecuteTPUEmbeddingPartitionerOp)

一個在中央組態上執行 TPUEmbedding 分割器的運算

裝置,並計算 TPUEmbedding 運算所需的 HBM 大小(以位元組為單位)。

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性

結果

結果 描述
common_config 字串值的張量

tf.Exp (TF::ExpOp)

以元素方式計算 x 的指數。\(y = e^x\)。

此函數計算輸入張量中每個元素的指數。即 exp(x)e^(x),其中 x 是輸入張量。e 表示歐拉數,約等於 2.718281。對於任何實數輸入,輸出均為正數。

  x = tf.constant(2.0)
  tf.math.exp(x) ==> 7.389056

  x = tf.constant([2.0, 8.0])
  tf.math.exp(x) ==> array([7.389056, 2980.958], dtype=float32)

對於複數,指數值的計算方式如下

  e^(x+iy) = e^x * e^iy = e^x * (cos y + i sin y)

讓我們以複數 1+1j 為例。e^1 * (cos 1 + i sin 1) = 2.7182818284590 * (0.54030230586+0.8414709848j)

  x = tf.constant(1 + 1j)
  tf.math.exp(x) ==> 1.4686939399158851+2.2873552871788423j

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.ExpandDims (TF::ExpandDimsOp)

在張量的形狀中插入維度 1。

給定張量 input,此運算會在 input 形狀的維度索引 axis 處插入維度 1。維度索引 axis 從零開始;如果您為 axis 指定負數,則會從結尾向後計數。

如果您想要將批次維度新增至單一元素,則此運算很有用。例如,如果您有一個形狀為 [height, width, channels] 的單一影像,則可以使用 expand_dims(image, 0) 將其設為 1 個影像的批次,這會使形狀變為 [1, height, width, channels]

其他範例

# 't' is a tensor of shape [2]
shape(expand_dims(t, 0)) ==> [1, 2]
shape(expand_dims(t, 1)) ==> [2, 1]
shape(expand_dims(t, -1)) ==> [2, 1]

# 't2' is a tensor of shape [2, 3, 5]
shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5]
shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5]
shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]

此運算需要滿足以下條件

-1-input.dims() <= dim <= input.dims()

此運算與 squeeze() 相關,後者會移除大小為 1 的維度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tdim::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
dim 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Expm1 (TF::Expm1Op)

以元素方式計算 exp(x) - 1

exp(x) - 1e^(x) - 1,其中 x 是輸入張量。e 表示歐拉數,約等於 2.718281。

  x = tf.constant(2.0)
  tf.math.expm1(x) ==> 6.389056

  x = tf.constant([2.0, 8.0])
  tf.math.expm1(x) ==> array([6.389056, 2979.958], dtype=float32)

  x = tf.constant(1 + 1j)
  tf.math.expm1(x) ==> (0.46869393991588515+2.2873552871788423j)

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.ExtractImagePatches (TF::ExtractImagePatchesOp)

images 擷取 patches,並將它們放入「深度」輸出維度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksizes::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
rates::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元不帶正負號的整數或 32 位元不帶正負號的整數或 64 位元不帶正負號的整數或 8 位元不帶正負號的整數值的張量

結果

結果 描述
patches bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元不帶正負號的整數或 32 位元不帶正負號的整數或 64 位元不帶正負號的整數或 8 位元不帶正負號的整數值的張量

tf.FakeParam (TF::FakeParamOp)

此運算在 If 分支函數中用作預留位置。它在執行時不會提供有效的輸出,因此必須移除(例如,替換為函數輸入)或保證不使用(例如,如果鏡像另一個分支的梯度計算所需的中間輸出)。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
shape::mlir::AttributeTensorFlow 形狀屬性
dtype::mlir::Attribute衍生屬性

結果

結果 描述
輸出 tf.dtype 值的張量

tf.FakeQuantWithMinMaxArgs (TF::FakeQuantWithMinMaxArgsOp)

虛假量化 'inputs' 張量(浮點類型)為形狀和類型相同的 'outputs' 張量。

量化稱為虛假量化,因為輸出仍為浮點數。API 會將輸入轉換為 [min 和 max] 範圍內的值,並作為輸出傳回。

屬性

  • [min; max] 定義 inputs 資料的鉗位範圍。
  • inputs 值會量化到量化範圍(當 narrow_range 為 false 時為 [0; 2^num_bits - 1],當為 true 時為 [1; 2^num_bits - 1]),然後反量化並作為 [min; max] 間隔中的浮點數輸出。
  • num_bits 是量化的位元寬度;介於 2 和 16 之間,包含 2 和 16。

在量化之前,會使用以下邏輯調整 minmax 值。建議讓 min <= 0 <= max。如果 0 不在值範圍內,則行為可能出乎意料

  • 如果 0 < min < maxmin_adj = 0max_adj = max - min
  • 如果 min < max < 0min_adj = min - maxmax_adj = 0
  • 如果 min <= 0 <= maxscale = (max - min) / (2^num_bits - 1)min_adj = scale * round(min / scale)max_adj = max + min_adj - min

範例


inp = tf.constant ([10.03, -10.23, 3])
out = tf.quantization.fake_quant_with_min_max_args(inp, min=-5, max=5,
                                                   num_bits=16)
print(out)

#  Output:
#  tf.Tensor([ 4.9999237 -5.0000763  3.0000763], shape=(3,), dtype=float32)

引發

  • InvalidArgumentError
    • 如果 num_bits 超出範圍 [2, 16]。
    • 如果 min >= max。
  • ValueError:如果 inputs 是 float32 以外的任何其他類型。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
min::mlir::FloatAttr32 位元浮點屬性
max::mlir::FloatAttr32 位元浮點屬性
num_bits::mlir::IntegerAttr64 位元無號整數屬性
narrow_range::mlir::BoolAttr布林屬性

運算元

運算元 描述
inputs 32 位元浮點數值的張量

結果

結果 描述
outputs 32 位元浮點數值的張量

tf.FakeQuantWithMinMaxArgsGradient (TF::FakeQuantWithMinMaxArgsGradientOp)

計算 FakeQuantWithMinMaxArgs 運算的梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
min::mlir::FloatAttr32 位元浮點屬性
max::mlir::FloatAttr32 位元浮點屬性
num_bits::mlir::IntegerAttr64 位元無號整數屬性
narrow_range::mlir::BoolAttr布林屬性

運算元

運算元 描述
gradients 32 位元浮點數值的張量
inputs 32 位元浮點數值的張量

結果

結果 描述
backprops 32 位元浮點數值的張量

tf.FakeQuantWithMinMaxVars (TF::FakeQuantWithMinMaxVarsOp)

透過全域浮點純量虛假量化 'inputs' 張量(浮點類型)

透過全域浮點純量 minmaxinputs 張量(浮點類型)虛假量化為與 inputs 形狀相同的 outputs 張量。

屬性

  • [min; max] 定義 inputs 資料的鉗位範圍。
  • inputs 值會量化到量化範圍(當 narrow_range 為 false 時為 [0; 2^num_bits - 1],當為 true 時為 [1; 2^num_bits - 1]),然後反量化並作為 [min; max] 間隔中的浮點數輸出。
  • num_bits 是量化的位元寬度;介於 2 和 16 之間,包含 2 和 16。

在量化之前,會使用以下邏輯調整 minmax 值。建議讓 min <= 0 <= max。如果 0 不在值範圍內,則行為可能出乎意料

  • 如果 0 < min < maxmin_adj = 0max_adj = max - min
  • 如果 min < max < 0min_adj = min - maxmax_adj = 0
  • 如果 min <= 0 <= maxscale = (max - min) / (2^num_bits - 1)min_adj = scale * round(min / scale)max_adj = max + min_adj - min

此運算具有梯度,因此允許訓練 minmax 值。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_bits::mlir::IntegerAttr64 位元無號整數屬性
narrow_range::mlir::BoolAttr布林屬性

運算元

運算元 描述
inputs 32 位元浮點數值的張量
min 32 位元浮點數值的張量
max 32 位元浮點數值的張量

結果

結果 描述
outputs 32 位元浮點數值的張量

tf.FakeQuantWithMinMaxVarsGradient (TF::FakeQuantWithMinMaxVarsGradientOp)

計算 FakeQuantWithMinMaxVars 運算的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_bits::mlir::IntegerAttr64 位元無號整數屬性
narrow_range::mlir::BoolAttr布林屬性

運算元

運算元 描述
gradients 32 位元浮點數值的張量
inputs 32 位元浮點數值的張量
min 32 位元浮點數值的張量
max 32 位元浮點數值的張量

結果

結果 描述
backprops_wrt_input 32 位元浮點數值的張量
backprop_wrt_min 32 位元浮點數值的張量
backprop_wrt_max 32 位元浮點數值的張量

tf.FakeQuantWithMinMaxVarsPerChannel (TF::FakeQuantWithMinMaxVarsPerChannelOp)

透過逐通道浮點數虛假量化 'inputs' 張量(浮點類型)

透過逐通道浮點數 minmax(形狀為 [d])將 inputs 張量(浮點類型)逐通道虛假量化,且形狀為:[d][b, d] [b, h, w, d],以產生與 inputs 形狀相同的 outputs 張量。

屬性

  • [min; max] 定義 inputs 資料的鉗位範圍。
  • inputs 值會量化到量化範圍(當 narrow_range 為 false 時為 [0; 2^num_bits - 1],當為 true 時為 [1; 2^num_bits - 1]),然後反量化並作為 [min; max] 間隔中的浮點數輸出。
  • num_bits 是量化的位元寬度;介於 2 和 16 之間,包含 2 和 16。

在量化之前,會使用以下邏輯調整 minmax 值。建議讓 min <= 0 <= max。如果 0 不在值範圍內,則行為可能出乎意料

  • 如果 0 < min < maxmin_adj = 0max_adj = max - min
  • 如果 min < max < 0min_adj = min - maxmax_adj = 0
  • 如果 min <= 0 <= maxscale = (max - min) / (2^num_bits - 1)min_adj = scale * round(min / scale)max_adj = max + min_adj - min

此運算具有梯度,因此允許訓練 minmax 值。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_bits::mlir::IntegerAttr64 位元無號整數屬性
narrow_range::mlir::BoolAttr布林屬性

運算元

運算元 描述
inputs 32 位元浮點數值的張量
min 32 位元浮點數值的張量
max 32 位元浮點數值的張量

結果

結果 描述
outputs 32 位元浮點數值的張量

tf.FakeQuantWithMinMaxVarsPerChannelGradient (TF::FakeQuantWithMinMaxVarsPerChannelGradientOp)

計算 FakeQuantWithMinMaxVarsPerChannel 運算的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_bits::mlir::IntegerAttr64 位元無號整數屬性
narrow_range::mlir::BoolAttr布林屬性

運算元

運算元 描述
gradients 32 位元浮點數值的張量
inputs 32 位元浮點數值的張量
min 32 位元浮點數值的張量
max 32 位元浮點數值的張量

結果

結果 描述
backprops_wrt_input 32 位元浮點數值的張量
backprop_wrt_min 32 位元浮點數值的張量
backprop_wrt_max 32 位元浮點數值的張量

tf.FFT (TF::FFTOp)

快速傅立葉轉換。

計算 input 最內層維度上的一維離散傅立葉轉換。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.FFT2D (TF::FFT2DOp)

2D 快速傅立葉轉換。

計算 input 最內層 2 個維度上的二維離散傅立葉轉換。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.FFT3D (TF::FFT3DOp)

3D 快速傅立葉轉換。

計算 input 最內層 3 個維度上的三維離散傅立葉轉換。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.Fill (TF::FillOp)

建立以純量值填滿的張量。

此運算會建立形狀為 dims 的張量,並以 value 填滿它。

例如

# Output tensor has shape [2, 3].
fill([2, 3], 9) ==> [[9, 9, 9]
                     [9, 9, 9]]

tf.fill 在幾個方面與 tf.constant 不同

  • tf.fill 僅支援純量內容,而 tf.constant 支援張量值。
  • tf.fill 在計算圖中建立一個 Op,該 Op 會在執行階段建構實際的張量值。這與 tf.constant 相反,後者會將整個張量與 Const 節點一起嵌入圖形中。
  • 由於 tf.fill 在圖形執行階段評估,因此它支援基於其他執行階段張量的動態形狀,這與 tf.constant 不同。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
index_type::mlir::Attribute衍生屬性

運算元

運算元 描述
dims 32/64 位元帶正負號的整數值的張量
value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.FinalizeDataset (TF::FinalizeDatasetOp)

_透過將 tf.data.Options 套用至 input_dataset 來建立資料集。_

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
has_captured_ref::mlir::BoolAttr布林屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

運算元

運算元 描述
input_dataset 變體值的張量

結果

結果 描述
handle 變體值的張量

tf.FinalizeTPUEmbedding (TF::FinalizeTPUEmbeddingOp)

一個完成 TPUEmbedding 組態的運算。

運算元

運算元 描述
common_config 字串值的張量
memory_config 字串值的張量

tf.FlatMapDataset (TF::FlatMapDatasetOp)

建立一個將 f 套用至 input_dataset 輸出的資料集。

與 MapDataset 不同,FlatMapDataset 中的 f 預期會傳回 Dataset 變體,而 FlatMapDataset 會將連續的結果扁平化為單一 Dataset。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性
Targuments::mlir::Attribute衍生屬性

運算元

運算元 描述
input_dataset 變體值的張量
other_arguments tf.dtype 值的張量的可變參數

結果

結果 描述
handle 變體值的張量

tf.Floor (TF::FloorOp)

傳回元素方式不大於 x 的最大整數。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.FloorDiv (TF::FloorDivOp)

傳回 x // y 元素方式。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.FloorMod (TF::FloorModOp)

傳回元素方式的除法餘數。

這遵循 Python 語意,因為此處的結果與底板除法一致。例如,floor(x / y) * y + floormod(x, y) = x,無論 x 和 y 的符號為何。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數或浮點數值的張量
y 整數或浮點數值的張量

結果

結果 描述
z 整數或浮點數值的張量

tf.FlushSummaryWriter (TF::FlushSummaryWriterOp)

刷新寫入器的未寫入事件。

writer:摘要寫入器資源的控制代碼。

運算元

運算元 描述
writer 資源值的張量

tf.FusedBatchNorm (TF::FusedBatchNormOp)

批次正規化。

請注意,4D 張量的大小由 "NHWC" 或 "NCHW" 定義。1D 張量的大小與 4D 張量的維度 C 相符。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
epsilon::mlir::FloatAttr32 位元浮點屬性
exponential_avg_factor::mlir::FloatAttr32 位元浮點屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
is_training::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 32 位元浮點數值的張量
scale 32 位元浮點數值的張量
offset 32 位元浮點數值的張量
mean 32 位元浮點數值的張量
variance 32 位元浮點數值的張量

結果

結果 描述
y 32 位元浮點數值的張量
batch_mean 32 位元浮點數值的張量
batch_variance 32 位元浮點數值的張量
reserve_space_1 32 位元浮點數值的張量
reserve_space_2 32 位元浮點數值的張量

tf.FusedBatchNormGrad (TF::FusedBatchNormGradOp)

批次正規化的梯度。

請注意,4D 張量的大小由 "NHWC" 或 "NCHW" 定義。1D 張量的大小與 4D 張量的維度 C 相符。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
epsilon::mlir::FloatAttr32 位元浮點屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
is_training::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
y_backprop 32 位元浮點數值的張量
x 32 位元浮點數值的張量
scale 32 位元浮點數值的張量
reserve_space_1 32 位元浮點數值的張量
reserve_space_2 32 位元浮點數值的張量

結果

結果 描述
x_backprop 32 位元浮點數值的張量
scale_backprop 32 位元浮點數值的張量
offset_backprop 32 位元浮點數值的張量
reserve_space_3 32 位元浮點數值的張量
reserve_space_4 32 位元浮點數值的張量

tf.FusedBatchNormGradV2 (TF::FusedBatchNormGradV2Op)

批次正規化的梯度。

請注意,4D 張量的大小由 "NHWC" 或 "NCHW" 定義。1D 張量的大小與 4D 張量的維度 C 相符。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
epsilon::mlir::FloatAttr32 位元浮點屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
is_training::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
U::mlir::Attribute衍生屬性

運算元

運算元 描述
y_backprop bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
x bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
scale 32 位元浮點數值的張量
reserve_space_1 32 位元浮點數值的張量
reserve_space_2 32 位元浮點數值的張量

結果

結果 描述
x_backprop bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
scale_backprop 32 位元浮點數值的張量
offset_backprop 32 位元浮點數值的張量
reserve_space_3 32 位元浮點數值的張量
reserve_space_4 32 位元浮點數值的張量

tf.FusedBatchNormGradV3 (TF::FusedBatchNormGradV3Op)

批次正規化的梯度。

請注意,4D 張量的大小由 "NHWC" 或 "NCHW" 定義。1D 張量的大小與 4D 張量的維度 C 相符。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)TF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
epsilon::mlir::FloatAttr32 位元浮點屬性
data_format::mlir::StringAttr字串屬性,其值為 NHWC、NCHW、NDHWC 或 NCDHW
is_training::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
U::mlir::Attribute衍生屬性

運算元

運算元 描述
y_backprop bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
x bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
scale 32 位元浮點數值的張量
reserve_space_1 32 位元浮點數值的張量
reserve_space_2 32 位元浮點數值的張量
reserve_space_3 32 位元浮點數值的張量

結果

結果 描述
x_backprop bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
scale_backprop 32 位元浮點數值的張量
offset_backprop 32 位元浮點數值的張量
reserve_space_4 32 位元浮點數值的張量
reserve_space_5 32 位元浮點數值的張量

tf.FusedBatchNormV2 (TF::FusedBatchNormV2Op)

批次正規化。

請注意,4D 張量的大小由 "NHWC" 或 "NCHW" 定義。1D 張量的大小與 4D 張量的維度 C 相符。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)TF_FoldOperandsTransposeInterfaceTF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
epsilon::mlir::FloatAttr32 位元浮點屬性
exponential_avg_factor::mlir::FloatAttr32 位元浮點屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
is_training::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
U::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
scale 32 位元浮點數值的張量
offset 32 位元浮點數值的張量
mean 32 位元浮點數值的張量
variance 32 位元浮點數值的張量

結果

結果 描述
y bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
batch_mean 32 位元浮點數值的張量
batch_variance 32 位元浮點數值的張量
reserve_space_1 32 位元浮點數值的張量
reserve_space_2 32 位元浮點數值的張量

tf.FusedBatchNormV3 (TF::FusedBatchNormV3Op)

批次正規化。

請注意,4D 張量的大小由 "NHWC" 或 "NCHW" 定義。1D 張量的大小與 4D 張量的維度 C 相符。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)TF_FoldOperandsTransposeInterfaceTF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
epsilon::mlir::FloatAttr32 位元浮點屬性
exponential_avg_factor::mlir::FloatAttr32 位元浮點屬性
data_format::mlir::StringAttr字串屬性,其值為 NHWC、NCHW、NDHWC 或 NCDHW
is_training::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
U::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
scale bfloat16 或 32 位元浮點數值的張量
offset bfloat16 或 32 位元浮點數值的張量
mean bfloat16 或 32 位元浮點數值的張量
variance bfloat16 或 32 位元浮點數值的張量

結果

結果 描述
y bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
batch_mean bfloat16 或 32 位元浮點數值的張量
batch_variance bfloat16 或 32 位元浮點數值的張量
reserve_space_1 bfloat16 或 32 位元浮點數值的張量
reserve_space_2 bfloat16 或 32 位元浮點數值的張量
reserve_space_3 bfloat16 或 32 位元浮點數值的張量

tf.Gather (TF::GatherOp)

根據 indicesparams 收集切片。

indices 必須是任何維度(通常為 0D 或 1D)的整數張量。產生形狀為 indices.shape + params.shape[1:] 的輸出張量,其中

    # Scalar indices
    output[:, ..., :] = params[indices, :, ... :]

    # Vector indices
    output[i, :, ..., :] = params[indices[i], :, ... :]

    # Higher rank indices
    output[i, ..., j, :, ... :] = params[indices[i, ..., j], :, ..., :]

如果 indices 是排列且 len(indices) == params.shape[0],則此運算會相應地排列 params

validate_indices:已淘汰。如果此運算指派給 CPU,則始終會驗證 indices 中的值是否在範圍內。如果指派給 GPU,則超出範圍的索引會導致安全但未指定的行為,其中可能包括引發錯誤。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
validate_indices::mlir::BoolAttr布林屬性
Tindices::mlir::Attribute衍生屬性
Tparams::mlir::Attribute衍生屬性

運算元

運算元 描述
params tf.dtype 值的張量
indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.GatherNd (TF::GatherNdOp)

params 收集切片到形狀由 indices 指定的張量中。

indices 是 K 維整數張量,最好將其視為進入 params 的 (K-1) 維索引張量,其中每個元素定義 params 的切片

output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]]

tf.gather 中,indices 定義進入 paramsaxis 維度的切片,而在 tf.gather_nd 中,indices 定義進入 params 的前 N 個維度的切片,其中 N = indices.shape[-1]

indices 的最後一個維度最多可以是 params 的等級

indices.shape[-1] <= params.rank

indices 的最後一個維度對應於沿著 params 的維度 indices.shape[-1] 的元素(如果 indices.shape[-1] == params.rank)或切片(如果 indices.shape[-1] < params.rank)。輸出張量的形狀為

indices.shape[:-1] + params.shape[indices.shape[-1]:]

請注意,在 CPU 上,如果找到超出範圍的索引,則會傳回錯誤。在 GPU 上,如果找到超出範圍的索引,則會在對應的輸出值中儲存 0。

以下是一些範例。

簡單的索引編製到矩陣中

    indices = [[0, 0], [1, 1]]
    params = [['a', 'b'], ['c', 'd']]
    output = ['a', 'd']

切片索引編製到矩陣中

    indices = [[1], [0]]
    params = [['a', 'b'], ['c', 'd']]
    output = [['c', 'd'], ['a', 'b']]

索引編製到 3 張量中

    indices = [[1]]
    params = [[['a0', 'b0'], ['c0', 'd0']],
              [['a1', 'b1'], ['c1', 'd1']]]
    output = [[['a1', 'b1'], ['c1', 'd1']]]


    indices = [[0, 1], [1, 0]]
    params = [[['a0', 'b0'], ['c0', 'd0']],
              [['a1', 'b1'], ['c1', 'd1']]]
    output = [['c0', 'd0'], ['a1', 'b1']]


    indices = [[0, 0, 1], [1, 0, 1]]
    params = [[['a0', 'b0'], ['c0', 'd0']],
              [['a1', 'b1'], ['c1', 'd1']]]
    output = ['b0', 'b1']

批次索引編製到矩陣中

    indices = [[[0, 0]], [[0, 1]]]
    params = [['a', 'b'], ['c', 'd']]
    output = [['a'], ['b']]

批次切片索引編製到矩陣中

    indices = [[[1]], [[0]]]
    params = [['a', 'b'], ['c', 'd']]
    output = [[['c', 'd']], [['a', 'b']]]

批次索引編製到 3 張量中

    indices = [[[1]], [[0]]]
    params = [[['a0', 'b0'], ['c0', 'd0']],
              [['a1', 'b1'], ['c1', 'd1']]]
    output = [[[['a1', 'b1'], ['c1', 'd1']]],
              [[['a0', 'b0'], ['c0', 'd0']]]]

    indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]]
    params = [[['a0', 'b0'], ['c0', 'd0']],
              [['a1', 'b1'], ['c1', 'd1']]]
    output = [[['c0', 'd0'], ['a1', 'b1']],
              [['a0', 'b0'], ['c1', 'd1']]]


    indices = [[[0, 0, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0]]]
    params = [[['a0', 'b0'], ['c0', 'd0']],
              [['a1', 'b1'], ['c1', 'd1']]]
    output = [['b0', 'b1'], ['d0', 'c1']]

另請參閱 tf.gathertf.batch_gather

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
Tparams::mlir::Attribute衍生屬性

運算元

運算元 描述
params tf.dtype 值的張量
indices 16 位元整數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.GatherV2 (TF::GatherV2Op)

根據 indicesparamsaxis 收集切片。

indices 必須是任何維度(通常為 0D 或 1D)的整數張量。產生形狀為 params.shape[:axis] + indices.shape[batch_dims:] + params.shape[axis + 1:] 的輸出張量,其中

    # Scalar indices (output is rank(params) - 1).
    output[a_0, ..., a_n, b_0, ..., b_n] =
      params[a_0, ..., a_n, indices, b_0, ..., b_n]

    # Vector indices (output is rank(params)).
    output[a_0, ..., a_n, i, b_0, ..., b_n] =
      params[a_0, ..., a_n, indices[i], b_0, ..., b_n]

    # Higher rank indices (output is rank(params) + rank(indices) - 1).
    output[a_0, ..., a_n, i, ..., j, b_0, ... b_n] =
      params[a_0, ..., a_n, indices[i, ..., j], b_0, ..., b_n]

請注意,在 CPU 上,如果找到超出範圍的索引,則會傳回錯誤。在 GPU 上,如果找到超出範圍的索引,則會在對應的輸出值中儲存 0。

另請參閱 tf.batch_gathertf.gather_nd

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
batch_dims::mlir::IntegerAttr64 位元無號整數屬性
Taxis::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tparams::mlir::Attribute衍生屬性

運算元

運算元 描述
params tf.dtype 值的張量
indices 16 位元整數或 32 位元整數或 64 位元整數值的張量
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.GeneratorDataset (TF::GeneratorDatasetOp)

建立一個調用函數以產生元素的資料集。

Traits: AttrSizedOperandSegments

介面:TF_GeneratorOpSideEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::GeneratorOp}

屬性

屬性MLIR 類型描述
init_func (初始化函式)::mlir::SymbolRefAttr符號參考屬性
next_func (下一個函式)::mlir::SymbolRefAttr符號參考屬性
finalize_func (最終化函式)::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性
Tfinalize_func_args (T最終化函式引數)::mlir::Attribute衍生屬性
Tinit_func_args (T初始化函式引數)::mlir::Attribute衍生屬性
Tnext_func_args (T下一個函式引數)::mlir::Attribute衍生屬性

運算元

運算元 描述
init_func_other_args (初始化函式其他引數) tf.dtype 值的張量的可變參數
next_func_other_args (下一個函式其他引數) tf.dtype 值的張量的可變參數
finalize_func_other_args (最終化函式其他引數) tf.dtype 值的張量的可變參數

結果

結果 描述
handle 變體值的張量

tf.GeneratorDatasetRegion (TF::GeneratorDatasetRegionOp)

GeneratorDataset 的區域版本

建立一個資料集,該資料集會調用其 'next' 區域來產生元素。從概念上講,在 MLIR 中,我們將此運算視為立即用所有結果填滿緩衝區,然後將這些結果(透過變體張量結果)傳遞給 MakeIterator / IteratorGetNext。請注意,實際的 TF 實作有所不同:它會在 IteratorGetNext 期間即時產生下一個元素。

init_extra_args:傳遞給 'init' 的額外引數。next_extra_args:傳遞給 'next' 的額外引數。(在來自 'init' 回傳值的正常引數之後傳遞。)finalize_extra_args:傳遞給 'finalize' 的額外引數。(在來自 'init' 回傳值的正常引數之後傳遞。)

特性: AttrSizedOperandSegments, SingleBlockImplicitTerminator<YieldOp>, SingleBlock

介面: RegionBranchOpInterface, TF_GeneratorOpSideEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::GeneratorOp}

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性
Tinit_func_args (T初始化函式引數)::mlir::Attribute衍生屬性
Tnext_func_args (T下一個函式引數)::mlir::Attribute衍生屬性
Tfinalize_func_args (T最終化函式引數)::mlir::Attribute衍生屬性

運算元

運算元 描述
init_func_other_args (初始化函式其他引數) tf.dtype 值的張量的可變參數
next_func_other_args (下一個函式其他引數) tf.dtype 值的張量的可變參數
finalize_func_other_args (最終化函式其他引數) tf.dtype 值的張量的可變參數

結果

結果 描述
handle 變體值的張量

tf.GetMinibatchesInCsrWithPhysicalReplica (TF::GetMinibatchesInCsrWithPhysicalReplicaOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_replica::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_minibatches_per_sc::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_ids_per_chip_per_sample::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_vocab_size::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
feature_width::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_sc_per_chip::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性
mini_batch_in_csr (CSR 格式的小批次)::mlir::StringAttr字串屬性

運算元

運算元 描述
program_key (程式金鑰) 字串值的張量
row_ids 32 位元整數值的張量
col_ids 32 位元整數值的張量
gains 32 位元浮點數值的張量
splits 64 位元整數值的張量
id_counts (ID 計數) 32 位元整數值的張量

結果

結果 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
row_pointers_unpadded_size 32 位元整數值的張量
ids_unpadded_size 32 位元整數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

tf.GetMinibatchSplitsWithPhysicalReplica (TF::GetMinibatchSplitsWithPhysicalReplicaOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_replica::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_vocab_size::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
feature_width::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_sc_per_chip::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性
mini_batch_splits (小批次分割)::mlir::StringAttr字串屬性

運算元

運算元 描述
program_key (程式金鑰) 字串值的張量
row_ids 32 位元整數值的張量
col_ids 32 位元整數值的張量
gains 32 位元浮點數值的張量

結果

結果 描述
sorted_row_ids (已排序的列 ID) 32 位元整數值的張量
sorted_col_ids (已排序的欄 ID) 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
splits 64 位元整數值的張量
id_counts (ID 計數) 32 位元整數值的張量
max_ids (最大 ID 數) 32 位元整數值的張量
max_uniques (最大不重複 ID 數) 32 位元整數值的張量

tf.GetStatsFromListOfSparseCoreCooTensors (TF::GetStatsFromListOfSparseCoreCooTensorsOp)

_一個運算,用於計算給定表格的 max_ids/uniques。

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count_list (樣本計數列表)::mlir::ArrayAttr64 位元整數陣列屬性
col_offset_list (欄偏移列表)::mlir::ArrayAttr64 位元整數陣列屬性
num_replica::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_vocab_size::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
feature_width::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_sc_per_chip::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性
N::mlir::Attribute衍生屬性

運算元

運算元 描述
row_ids_list 32 位元整數值的張量的變數
col_ids_list 32 位元整數值的張量的變數
gains_list 32 位元浮點數值的張量的可變參數

結果

結果 描述
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數) 32 位元整數值的張量
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數) 32 位元整數值的張量

tf.GlobalIterId (TF::GlobalIterIdOp)

取得全域步驟 ID 的運算。

此運算取得每個迴圈迭代的步驟 ID。

介面: GetResourceInstanceInterface, TF_GlobalIterIdEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::GlobalIterId}

結果

結果 描述
iter_id (迭代 ID) 64 位元整數值的張量

tf.Greater (TF::GreaterOp)

逐元素傳回 (x > y) 的真值。

範例

x = tf.constant([5, 4, 6])
y = tf.constant([5, 2, 5])
tf.math.greater(x, y) ==> [False, True, True]

x = tf.constant([5, 4, 6])
y = tf.constant([5])
tf.math.greater(x, y) ==> [False, False, True]

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數或浮點數值的張量
y 整數或浮點數值的張量

結果

結果 描述
z 布林值的張量

tf.GreaterEqual (TF::GreaterEqualOp)

逐元素傳回 (x >= y) 的真值。

範例

x = tf.constant([5, 4, 6, 7])
y = tf.constant([5, 2, 5, 10])
tf.math.greater_equal(x, y) ==> [True, True, True, False]

x = tf.constant([5, 4, 6, 7])
y = tf.constant([5])
tf.math.greater_equal(x, y) ==> [True, False, True, True]

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數或浮點數值的張量
y 整數或浮點數值的張量

結果

結果 描述
z 布林值的張量

tf.HashTable (TF::HashTableOp)

建立一個未初始化的雜湊表。

此運算會建立一個雜湊表,指定其鍵和值的類型。在使用表格之前,您必須先初始化它。初始化後,表格將會是不可變的。

屬性

屬性MLIR 類型描述
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
use_node_name_sharing (使用節點名稱共用)::mlir::BoolAttr布林屬性
key_dtype (鍵資料類型)::mlir::TypeAttr任何類型屬性
value_dtype (值資料類型)::mlir::TypeAttr任何類型屬性

結果

結果 描述
table_handle (表格句柄) 字串值的張量

tf.HashTableV2 (TF::HashTableV2Op)

建立一個未初始化的雜湊表。

此運算會建立一個雜湊表,指定其鍵和值的類型。在使用表格之前,您必須先初始化它。初始化後,表格將會是不可變的。

屬性

屬性MLIR 類型描述
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
use_node_name_sharing (使用節點名稱共用)::mlir::BoolAttr布林屬性
key_dtype (鍵資料類型)::mlir::TypeAttr任何類型屬性
value_dtype (值資料類型)::mlir::TypeAttr任何類型屬性

結果

結果 描述
table_handle (表格句柄) 資源值的張量

tf.HSVToRGB (TF::HSVToRGBOp)

將一個或多個影像從 HSV 轉換為 RGB。

輸出與 images 張量形狀相同的張量,其中包含像素的 RGB 值。只有當 images 中的值在 [0,1] 範圍內時,輸出才是明確定義的。

有關 HSV 編碼的描述,請參閱 rgb_to_hsv

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.Identity (TF::IdentityOp)

傳回與輸入張量或值具有相同形狀和內容的張量。

特性: AlwaysSpeculatableImplTrait, TF_NoConstantFold, TF_OperandsSameAsResultsTypeOrRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.IdentityN (TF::IdentityNOp)

傳回與輸入具有相同形狀和內容的張量列表

張量。

此運算可用於覆寫複雜函式的梯度。例如,假設 y = f(x),我們希望套用自訂函式 g 進行反向傳播,使得 dx = g(dy)。在 Python 中,

with tf.get_default_graph().gradient_override_map(
    {'IdentityN': 'OverrideGradientWithG'}):
  y, _ = identity_n([f(x), x])

@tf.RegisterGradient('OverrideGradientWithG')
def ApplyG(op, dy, _):
  return [None, g(dy)]  # Do not backprop to f(x).

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.If (TF::IfOp)

_Output = cond ? then_branch(input) : else_branch(input)_

output = cond ? then_branch(input) : else_branch(input)

cond:一個張量。如果張量是非布林類型的純量,則根據以下規則將純量轉換為布林值:如果純量是數值,則非零表示 True,零表示 False;如果純量是字串,則非空表示 True,空表示 False。如果張量不是純量,則為空表示 False,非空表示 True。input:輸入張量列表。then_branch:一個接受 'inputs' 並傳回張量列表的函式,其類型與 else_branch 傳回的類型相同。else_branch:一個接受 'inputs' 並傳回張量列表的函式,其類型與 then_branch 傳回的類型相同。

介面:SymbolUserOpInterface

屬性

屬性MLIR 類型描述
then_branch (then 分支)::mlir::FlatSymbolRefAttr扁平符號參考屬性
else_branch (else 分支)::mlir::FlatSymbolRefAttr扁平符號參考屬性
is_stateless::mlir::BoolAttr布林屬性
Tcond (T條件)::mlir::Attribute衍生屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性
output_shapes::mlir::Attribute衍生屬性

運算元

運算元 描述
cond (條件) tf.dtype 值的張量
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.IFFT (TF::IFFTOp)

反向快速傅立葉轉換。

計算 input 最內層維度的反向一維離散傅立葉轉換。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.IFFT2D (TF::IFFT2DOp)

反向 2D 快速傅立葉轉換。

計算 input 最內層 2 個維度的反向二維離散傅立葉轉換。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.IFFT3D (TF::IFFT3DOp)

反向 3D 快速傅立葉轉換。

計算 input 最內層 3 個維度的反向三維離散傅立葉轉換。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.IfRegion (TF::IfRegionOp)

_Output = cond ? then_branch output : else_branch output_

"output = cond ? then_branch output : else_branch output"

cond:一個張量。如果張量是非布林類型的純量,則根據以下規則將純量轉換為布林值:如果純量是數值,則非零表示 True,零表示 False;如果純量是字串,則非空表示 True,空表示 False。如果張量不是純量,則為空表示 False,非空表示 True。then_branch:一個區域,如果 cond = true,則計算運算的輸出。它使用 tf.yield (作為終止符) 傳回張量列表。這些傳回張量的類型與 else_branch 的類型相同。else_branch:一個區域,如果 cond = false,則計算運算的輸出。它使用 tf.yield (作為終止符) 傳回張量列表。這些傳回張量的類型與 then_branch 的類型相同

特性:NoRegionArgumentsSingleBlockImplicitTerminator<YieldOp>SingleBlock

介面: RegionBranchOpInterface

屬性

屬性MLIR 類型描述
is_stateless::mlir::BoolAttr布林屬性
_then_func_name (then 函式名稱)::mlir::StringAttr字串屬性
_else_func_name (else 函式名稱)::mlir::StringAttr字串屬性

運算元

運算元 描述
cond (條件) 0D 張量,包含 1 位元無號整數值

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.Igamma (TF::IgammaOp)

計算下不完全 Gamma 函數 P(a, x)

下不完全 Gamma 函數定義為

\(P(a, x) = gamma(a, x) / Gamma(a) = 1 - Q(a, x)\)

其中

\(gamma(a, x) = \\int_{0}^{x} t^{a-1} exp(-t) dt\)

是下不完全 Gamma 函數。

注意,以上 Q(a, x) (Igammac) 是上不完全 Gamma 函數。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 浮點數值的張量
x 浮點數值的張量

結果

結果 描述
z 浮點數值的張量

tf.Igammac (TF::IgammacOp)

計算上不完全 Gamma 函數 Q(a, x)

上不完全 Gamma 函數定義為

\(Q(a, x) = Gamma(a, x) / Gamma(a) = 1 - P(a, x)\)

其中

\(Gamma(a, x) = \int_{x}^{\infty} t^{a-1} exp(-t) dt\)

是上不完全 Gamma 函數。

注意,以上 P(a, x) (Igamma) 是下不完全 Gamma 函數。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 浮點數值的張量
x 浮點數值的張量

結果

結果 描述
z 浮點數值的張量

tf.IgammaGradA (TF::IgammaGradAOp)

計算 igamma(a, x) 相對於 a 的梯度。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 32/64 位元浮點數值的張量
x 32/64 位元浮點數值的張量

結果

結果 描述
z 32/64 位元浮點數值的張量

tf.Imag (TF::ImagOp)

傳回複數的虛部。

給定複數的張量 input,此運算傳回類型為 float 的張量,它是 input 中每個元素的虛部。 input 中的所有元素都必須是 \(a + bj\) 形式的複數,其中 a 是實部,b 是此運算傳回的虛部。

例如

# tensor 'input' is [-2.25 + 4.75j, 3.25 + 5.75j]
tf.imag(input) ==> [4.75, 5.75]

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.ImportEvent (TF::ImportEventOp)

輸出 tf.Event 協定緩衝區。

當使用 CreateSummaryDbWriter 時,此運算可用於從事件日誌匯入資料。

writer (寫入器):摘要寫入器的句柄。event (事件):包含二進位編碼 tf.Event proto 的字串。

運算元

運算元 描述
writer 資源值的張量
event (事件) 字串值的張量

tf.InfeedDequeue (TF::InfeedDequeueOp)

將值饋送到計算中的佔位符運算。

屬性

屬性MLIR 類型描述
shape::mlir::AttributeTensorFlow 形狀屬性
dtype::mlir::Attribute衍生屬性

結果

結果 描述
輸出 tf.dtype 值的張量

tf.InfeedDequeueTuple (TF::InfeedDequeueTupleOp)

從 infeed 提取多個值作為 XLA 元組。

屬性

屬性MLIR 類型描述
_XlaSharding::mlir::StringAttr字串屬性
layouts (版面配置)::mlir::ArrayAttr陣列屬性
shapes (形狀)::mlir::Attribute衍生屬性
dtypes (資料類型)::mlir::Attribute衍生屬性

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf.InfeedEnqueueTuple (TF::InfeedEnqueueTupleOp)

將多個張量值作為 XLA 元組饋送到計算中。

屬性

屬性MLIR 類型描述
dtypes (資料類型)::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
shapes (形狀)::mlir::ArrayAttrtensorflow 形狀屬性陣列
layouts (版面配置)::mlir::ArrayAttr64 位元整數陣列屬性
device_ordinal::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

tf.InitializeTable (TF::InitializeTableOp)

表格初始化器,分別採用兩個張量作為鍵和值。

屬性

屬性MLIR 類型描述
Tkey (T鍵)::mlir::Attribute衍生屬性
Tval (T值)::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 字串值的張量
keys (鍵) tf.dtype 值的張量
values tf.dtype 值的張量

tf.InitializeTableFromDataset (TF::InitializeTableFromDatasetOp)

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量
dataset (資料集) 變體值的張量

tf.InitializeTableFromTextFile (TF::InitializeTableFromTextFileOp)

從文字檔初始化表格。

它為檔案的每一行插入一個鍵值對。鍵和值從整行內容、基於 delimiter 分割行的元素或行號(從零開始)中提取。從行中提取鍵和值的位置由 key_indexvalue_index 指定。

  • 值 -1 表示使用行號(從零開始),預期為 int64
  • 值 -2 表示使用整行內容,預期為 string
  • 值 >= 0 表示使用基於 delimiter 分割行的索引(從零開始)。

屬性

屬性MLIR 類型描述
key_index (鍵索引)::mlir::IntegerAttr64 位元無號整數屬性,最小值為 -2
value_index (值索引)::mlir::IntegerAttr64 位元無號整數屬性,最小值為 -2
vocab_size (詞彙大小)::mlir::IntegerAttr64 位元無號整數屬性,最小值為 -1
delimiter (分隔符號)::mlir::StringAttr字串屬性
offset::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
table_handle (表格句柄) 字串值的張量
filename 字串值的張量

tf.InitializeTableFromTextFileV2 (TF::InitializeTableFromTextFileV2Op)

從文字檔初始化表格。

它為檔案的每一行插入一個鍵值對。鍵和值從整行內容、基於 delimiter 分割行的元素或行號(從零開始)中提取。從行中提取鍵和值的位置由 key_indexvalue_index 指定。

  • 值 -1 表示使用行號(從零開始),預期為 int64
  • 值 -2 表示使用整行內容,預期為 string
  • 值 >= 0 表示使用基於 delimiter 分割行的索引(從零開始)。

屬性

屬性MLIR 類型描述
key_index (鍵索引)::mlir::IntegerAttr64 位元無號整數屬性,最小值為 -2
value_index (值索引)::mlir::IntegerAttr64 位元無號整數屬性,最小值為 -2
vocab_size (詞彙大小)::mlir::IntegerAttr64 位元無號整數屬性,最小值為 -1
delimiter (分隔符號)::mlir::StringAttr字串屬性
offset::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量
filename 字串值的張量

tf.InitializeTableV2 (TF::InitializeTableV2Op)

表格初始化器,分別採用兩個張量作為鍵和值。

屬性

屬性MLIR 類型描述
Tkey (T鍵)::mlir::Attribute衍生屬性
Tval (T值)::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量
keys (鍵) tf.dtype 值的張量
values tf.dtype 值的張量

tf.InplaceAdd (TF::InplaceAddOp)

將 v 加入 x 的指定列。

計算 y = x; y[i, :] += v; 傳回 y。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
i (索引 i) 32 位元整數值的張量
v tf.dtype 值的張量

結果

結果 描述
y tf.dtype 值的張量

tf.InplaceUpdate (TF::InplaceUpdateOp)

使用值 'v' 更新指定的列 'i'。

計算 x[i, :] = v; return x

最初此函數是可變的,但為了編譯,我們使此運算建立/操作 x 的副本。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
i (索引 i) 32 位元整數值的張量
v tf.dtype 值的張量

結果

結果 描述
y tf.dtype 值的張量

tf.InTopKV2 (TF::InTopKV2Op)

表示目標是否在前 K 個預測中。

這會輸出一個 batch_size 布林陣列,如果目標類別的預測在所有範例 i 的所有預測中的前 k 個預測中,則條目 out[i]true。請注意,InTopK 的行為與 TopK 運算在處理並列關係方面有所不同;如果多個類別具有相同的預測值並跨越 top-k 邊界,則所有這些類別都被視為在前 k 個中。

更正式地說,讓

\(predictions_i\) 是範例 i 的所有類別的預測,\(targets_i\) 是範例 i 的目標類別,\(out_i\) 是範例 i 的輸出,

\[out_i = predictions_{i, targets_i} \in TopKIncludingTies(predictions_i)\]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
predictions (預測) 32 位元浮點數值的張量
targets (目標) 32/64 位元帶正負號的整數值的張量
k 32/64 位元帶正負號的整數值的張量

結果

結果 描述
precision 布林值的張量

tf.Inv (TF::InvOp)

逐元素計算 x 的倒數。

即,\(y = 1 / x\)。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

結果

結果 描述
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

tf.Invert (TF::InvertOp)

反轉(翻轉)支援類型的每個位元;例如,類型 uint8 值 01010101 變成 10101010。

翻轉支援類型的每個位元。例如,類型 int8(十進制 2)二進制 00000010 變成(十進制 -3)二進制 11111101。此運算在張量引數 x 的每個元素上執行。

範例

import tensorflow as tf
from tensorflow.python.ops import bitwise_ops

# flip 2 (00000010) to -3 (11111101)
tf.assert_equal(-3, bitwise_ops.invert(2))

dtype_list = [dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64,
              dtypes.uint8, dtypes.uint16, dtypes.uint32, dtypes.uint64]

inputs = [0, 5, 3, 14]
for dtype in dtype_list:
  # Because of issues with negative numbers, let's test this indirectly.
  # 1. invert(a) and a = 0
  # 2. invert(a) or a = invert(0)
  input_tensor = tf.constant([0, 5, 3, 14], dtype=dtype)
  not_a_and_a, not_a_or_a, not_0 = [bitwise_ops.bitwise_and(
                                      input_tensor, bitwise_ops.invert(input_tensor)),
                                    bitwise_ops.bitwise_or(
                                      input_tensor, bitwise_ops.invert(input_tensor)),
                                    bitwise_ops.invert(
                                      tf.constant(0, dtype=dtype))]

  expected = tf.constant([0, 0, 0, 0], dtype=tf.float32)
  tf.assert_equal(tf.cast(not_a_and_a, tf.float32), expected)

  expected = tf.cast([not_0] * 4, tf.float32)
  tf.assert_equal(tf.cast(not_a_or_a, tf.float32), expected)

  # For unsigned dtypes let's also check the result directly.
  if dtype.is_unsigned:
    inverted = bitwise_ops.invert(input_tensor)
    expected = tf.constant([dtype.max - x for x in inputs], dtype=tf.float32)
    tf.assert_equal(tf.cast(inverted, tf.float32), tf.cast(expected, tf.float32))

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_Involution

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數值的張量

結果

結果 描述
y 整數值的張量

tf.InvertPermutation (TF::InvertPermutationOp)

計算張量的反向排列。

此運算計算索引排列的反向。它採用一維整數張量 x,它表示以零為基礎的陣列的索引,並將每個值與其索引位置交換。換句話說,對於輸出張量 y 和輸入張量 x,此運算計算以下內容

y[x[i]] = i for i in [0, 1, ..., len(x) - 1]

這些值必須包含 0。不能有重複值或負值。

例如

# tensor `x` is [3, 4, 0, 2, 1]
invert_permutation(x) ==> [2, 4, 3, 0, 1]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 32/64 位元帶正負號的整數值的張量

結果

結果 描述
y 32/64 位元帶正負號的整數值的張量

tf.IRFFT (TF::IRFFTOp)

反向實值快速傅立葉轉換。

計算 input 最內層維度的實值訊號的反向一維離散傅立葉轉換。

input 的最內層維度被假定為 RFFT 的結果:實值訊號的 DFT 的 fft_length / 2 + 1 個唯一分量。如果未提供 fft_length,則從 input 最內層維度的大小計算 (fft_length = 2 * (inner - 1))。如果用於計算 input 的 FFT 長度是奇數,則應提供它,因為它無法正確推斷。

沿著計算 IRFFT 的軸,如果 fft_length / 2 + 1 小於 input 的相應維度,則會裁剪該維度。如果它更大,則會用零填充該維度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性
Treal (T實數)::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量
fft_length (FFT 長度) 32 位元整數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.IRFFT2D (TF::IRFFT2DOp)

反向 2D 實值快速傅立葉轉換。

計算 input 最內層 2 個維度的實值訊號的反向二維離散傅立葉轉換。

input 的最內層 2 個維度被假定為 RFFT2D 的結果:最內層維度包含實值訊號的 DFT 的 fft_length / 2 + 1 個唯一分量。如果未提供 fft_length,則從 input 最內層 2 個維度的大小計算。如果用於計算 input 的 FFT 長度是奇數,則應提供它,因為它無法正確推斷。

沿著計算 IRFFT2D 的每個軸,如果 fft_length(或最內層維度的 fft_length / 2 + 1)小於 input 的相應維度,則會裁剪該維度。如果它更大,則會用零填充該維度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性
Treal (T實數)::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量
fft_length (FFT 長度) 32 位元整數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.IRFFT3D (TF::IRFFT3DOp)

反向 3D 實值快速傅立葉轉換。

計算 input 最內層 3 個維度的實值訊號的反向三維離散傅立葉轉換。

input 的最內層 3 個維度被假定為 RFFT3D 的結果:最內層維度包含實值訊號的 DFT 的 fft_length / 2 + 1 個唯一分量。如果未提供 fft_length,則從 input 最內層 3 個維度的大小計算。如果用於計算 input 的 FFT 長度是奇數,則應提供它,因為它無法正確推斷。

沿著計算 IRFFT3D 的每個軸,如果 fft_length(或最內層維度的 fft_length / 2 + 1)小於 input 的相應維度,則會裁剪該維度。如果它更大,則會用零填充該維度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tcomplex::mlir::Attribute衍生屬性
Treal (T實數)::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量
fft_length (FFT 長度) 32 位元整數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.IsFinite (TF::IsFiniteOp)

傳回 x 的哪些元素是有限的。

@compatibility(numpy) 等效於 np.isfinite @end_compatibility

範例

x = tf.constant([5.0, 4.8, 6.8, np.inf, np.nan])
tf.math.is_finite(x) ==> [True, True, True, False, False]

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 布林值的張量

tf.IsInf (TF::IsInfOp)

傳回 x 的哪些元素是 Inf。

@compatibility(numpy) 等效於 np.isinf @end_compatibility

範例

x = tf.constant([5.0, np.inf, 6.8, np.inf])
tf.math.is_inf(x) ==> [False, True, False, True]

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 布林值的張量

tf.IsNan (TF::IsNanOp)

傳回 x 的哪些元素是 NaN。

@compatibility(numpy) 等效於 np.isnan @end_compatibility

範例

x = tf.constant([5.0, np.nan, 6.8, np.nan, np.inf])
tf.math.is_nan(x) ==> [False, True, False, True, False]

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 布林值的張量

tf.Iterator (TF::IteratorOp)

迭代器資源的容器。

屬性

屬性MLIR 類型描述
shared_name::mlir::StringAttr字串屬性
container::mlir::StringAttr字串屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量

tf.IteratorFromStringHandle (TF::IteratorFromStringHandleOp)

將給定的字串(表示迭代器的句柄)轉換為資源。

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr類型陣列屬性
output_shapes::mlir::ArrayAttrtensorflow 形狀屬性陣列

運算元

運算元 描述
string_handle (字串句柄) 字串值的張量

結果

結果 描述
resource_handle 資源值的張量

tf.IteratorFromStringHandleV2 (TF::IteratorFromStringHandleV2Op)

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr類型陣列屬性
output_shapes::mlir::ArrayAttrtensorflow 形狀屬性陣列

運算元

運算元 描述
string_handle (字串句柄) 字串值的張量

結果

結果 描述
resource_handle 資源值的張量

tf.IteratorGetNext (TF::IteratorGetNextOp)

從給定的迭代器取得下一個輸出。

屬性

屬性MLIR 類型描述
output_shapes::mlir::Attribute衍生屬性
output_types::mlir::Attribute衍生屬性

運算元

運算元 描述
iterator (迭代器) 資源值的張量

結果

結果 描述
components (組件) tf.dtype 值的張量的可變參數

tf.IteratorGetNextAsOptional (TF::IteratorGetNextAsOptionalOp)

從給定的迭代器取得下一個輸出作為 Optional 變體。

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

運算元

運算元 描述
iterator (迭代器) 資源值的張量

結果

結果 描述
optional (可選) 變體值的張量

tf.IteratorGetNextSync (TF::IteratorGetNextSyncOp)

從給定的迭代器取得下一個輸出。

此運算是 IteratorGetNext 的同步版本。它應該僅在迭代器不阻塞調用線程,或者調用線程不是用於執行並行運算的線程池的成員(例如,在 eager 模式下)的情況下使用。

屬性

屬性MLIR 類型描述
output_shapes::mlir::Attribute衍生屬性
output_types::mlir::Attribute衍生屬性

運算元

運算元 描述
iterator (迭代器) 資源值的張量

結果

結果 描述
components (組件) tf.dtype 值的張量的可變參數

tf.IteratorToStringHandle (TF::IteratorToStringHandleOp)

將給定的 resource_handle(表示迭代器)轉換為字串。

運算元

運算元 描述
resource_handle 資源值的張量

結果

結果 描述
string_handle (字串句柄) 字串值的張量

tf.IteratorV2 (TF::IteratorV2Op)

屬性

屬性MLIR 類型描述
shared_name::mlir::StringAttr字串屬性
container::mlir::StringAttr字串屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量

tf.KthOrderStatistic (TF::KthOrderStatisticOp)

計算資料集的第 K 個順序統計量。目前的

實作使用二元搜尋,需要對輸入資料進行 32 次傳遞。執行時間與輸入大小成線性關係。中位數的中位數演算法可能更快,但在 XLA 中難以有效率地實作。此實作對浮點數施加總排序。排序與通常的部分排序一致。正 NaN 大於正無窮大。負 NaN 小於負無窮大。具有不同有效負載的 NaN 被視為不同。次正規數被保留(不會刷新為零)。正無窮大於所有數字。負無窮小於所有數字。正零大於負零。小於第 k 個順序統計量的值少於 k 個。大於或等於第 K 個順序統計量的值至少有 k 個。語義與 top_k_unique 不同。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
k::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
輸入 32 位元浮點數值的張量

結果

結果 描述
輸出 32 位元浮點數值的張量

tf.L2Loss (TF::L2LossOp)

L2 損失。

計算張量的 L2 範數的一半,不含 sqrt

output = sum(t ** 2) / 2

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.LeakyRelu (TF::LeakyReluOp)

計算線性整流:max(features, features * alpha)

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
alpha (Alpha)::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features 浮點數值的張量

結果

結果 描述
activations 浮點數值的張量

tf.LeakyReluGrad (TF::LeakyReluGradOp)

計算 LeakyRelu 運算的線性整流梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
alpha (Alpha)::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 浮點數值的張量
features 浮點數值的張量

結果

結果 描述
backprops 浮點數值的張量

tf.LeftShift (TF::LeftShiftOp)

逐元素計算 xy 的位元左移。

如果 y 為負數,或大於或等於 x 的位元寬度,則結果是實作定義的。

範例

import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
import numpy as np
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64]

for dtype in dtype_list:
  lhs = tf.constant([-1, -5, -3, -14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)

  left_shift_result = bitwise_ops.left_shift(lhs, rhs)

  print(left_shift_result)

# This will print:
# tf.Tensor([ -32   -5 -128    0], shape=(4,), dtype=int8)
# tf.Tensor([   -32     -5   -384 -28672], shape=(4,), dtype=int16)
# tf.Tensor([   -32     -5   -384 -28672], shape=(4,), dtype=int32)
# tf.Tensor([   -32     -5   -384 -28672], shape=(4,), dtype=int64)

lhs = np.array([-2, 64, 101, 32], dtype=np.int8)
rhs = np.array([-1, -5, -3, -14], dtype=np.int8)
bitwise_ops.left_shift(lhs, rhs)
# <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2,  64, 101,  32], dtype=int8)>

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數值的張量
y 整數值的張量

結果

結果 描述
z 整數值的張量

tf.LegacyCall (TF::LegacyCallOp)

傳回 f(inputs),其中 f 是一個函式。

LegacyCall 運算表示直接調用與調用在相同符號範圍內的函式,並映射到以函式名稱作為運算名稱的 GraphDef 節點。與 PartitionedCall(表示跨多個裝置異步執行函式)不同,LegacyCall 忽略附加函式中運算的規範,而是在分配給此運算的裝置上執行它。

Traits: AlwaysSpeculatableImplTrait

介面: CallOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SymbolUserOpInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::FlatSymbolRefAttr扁平符號參考屬性
_disable_call_shape_inference (停用調用形狀推斷)::mlir::BoolAttr布林屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.Less (TF::LessOp)

逐元素傳回 (x < y) 的真值。

範例

x = tf.constant([5, 4, 6])
y = tf.constant([5])
tf.math.less(x, y) ==> [False, True, False]

x = tf.constant([5, 4, 6])
y = tf.constant([5, 6, 7])
tf.math.less(x, y) ==> [False, True, True]

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數或浮點數值的張量
y 整數或浮點數值的張量

結果

結果 描述
z 布林值的張量

tf.LessEqual (TF::LessEqualOp)

逐元素傳回 (x <= y) 的真值。

範例

x = tf.constant([5, 4, 6])
y = tf.constant([5])
tf.math.less_equal(x, y) ==> [True, True, False]

x = tf.constant([5, 4, 6])
y = tf.constant([5, 6, 6])
tf.math.less_equal(x, y) ==> [True, True, True]

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數或浮點數值的張量
y 整數或浮點數值的張量

結果

結果 描述
z 布林值的張量

tf.Lgamma (TF::LgammaOp)

逐元素計算 Gamma(x) 絕對值的對數。

對於正數,此函數計算張量中每個元素的 log((input - 1)!)。lgamma(5) = log((5-1)!) = log(4!) = log(24) = 3.1780539

範例

x = tf.constant([0, 0.5, 1, 4.5, -4, -5.6])
tf.math.lgamma(x) ==> [inf, 0.5723649, 0., 2.4537368, inf, -4.6477685]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.LinSpace (TF::LinSpaceOp)

在間隔中產生值。

產生從 start 開始的 num 個均勻間隔值的序列。如果 num > 1,則序列中的值增加 (stop - start) / (num - 1),使得最後一個值正好是 stop

例如

tf.linspace(10.0, 12.0, 3, name="linspace") => [ 10.0  11.0  12.0]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
start (開始) 浮點數值的張量
stop (停止) 浮點數值的張量
num (數量) 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.ListDiff (TF::ListDiffOp)

計算兩個數字或字串列表之間的差異。

給定列表 x 和列表 y,此運算傳回列表 out,它表示 x 中但不在 y 中的所有值。傳回的列表 out 以數字在 x 中出現的相同順序排序(重複項會被保留)。此運算還傳回列表 idx,它表示 out 中每個元素在 x 中的位置。換句話說

out[i] = x[idx[i]] for i in [0, 1, ..., len(out) - 1]

例如,給定此輸入

x = [1, 2, 3, 4, 5, 6]
y = [1, 3, 5]

此運算將傳回

out ==> [2, 4, 6]
idx ==> [1, 3, 5]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
out_idx (輸出索引)::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
y tf.dtype 值的張量

結果

結果 描述
out tf.dtype 值的張量
idx (索引) 32/64 位元帶正負號的整數值的張量

tf.LoadTPUEmbeddingAdadeltaParameters (TF::LoadTPUEmbeddingAdadeltaParametersOp)

載入 Adadelta 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
updates (更新) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingAdadeltaParametersGradAccumDebug (TF::LoadTPUEmbeddingAdadeltaParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
updates (更新) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingAdagradParameters (TF::LoadTPUEmbeddingAdagradParametersOp)

載入 Adagrad 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingAdagradParametersGradAccumDebug (TF::LoadTPUEmbeddingAdagradParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingADAMParameters (TF::LoadTPUEmbeddingADAMParametersOp)

載入 ADAM 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
velocities (速度) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingADAMParametersGradAccumDebug (TF::LoadTPUEmbeddingADAMParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
velocities (速度) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingCenteredRMSPropParameters (TF::LoadTPUEmbeddingCenteredRMSPropParametersOp)

載入居中 RMSProp 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
ms (均方) 32 位元浮點數值的張量
mom (動量) 32 位元浮點數值的張量
mg (動量梯度) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingFTRLParameters (TF::LoadTPUEmbeddingFTRLParametersOp)

載入 FTRL 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
linears (線性項) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingFTRLParametersGradAccumDebug (TF::LoadTPUEmbeddingFTRLParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
linears (線性項) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingMDLAdagradLightParameters (TF::LoadTPUEmbeddingMDLAdagradLightParametersOp)

載入 MDL Adagrad Light 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
weights 32 位元浮點數值的張量
benefits (效益) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingMomentumParameters (TF::LoadTPUEmbeddingMomentumParametersOp)

載入 Momentum 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingMomentumParametersGradAccumDebug (TF::LoadTPUEmbeddingMomentumParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingProximalAdagradParameters (TF::LoadTPUEmbeddingProximalAdagradParametersOp)

載入 Proximal Adagrad 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingProximalAdagradParametersGradAccumDebug (TF::LoadTPUEmbeddingProximalAdagradParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingProximalYogiParameters (TF::LoadTPUEmbeddingProximalYogiParametersOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
v 32 位元浮點數值的張量
m 32 位元浮點數值的張量

tf.LoadTPUEmbeddingProximalYogiParametersGradAccumDebug (TF::LoadTPUEmbeddingProximalYogiParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
v 32 位元浮點數值的張量
m 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingRMSPropParameters (TF::LoadTPUEmbeddingRMSPropParametersOp)

載入 RMSProp 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
ms (均方) 32 位元浮點數值的張量
mom (動量) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingRMSPropParametersGradAccumDebug (TF::LoadTPUEmbeddingRMSPropParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
ms (均方) 32 位元浮點數值的張量
mom (動量) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingStochasticGradientDescentParameters (TF::LoadTPUEmbeddingStochasticGradientDescentParametersOp)

載入 SGD 嵌入參數。

一個將最佳化參數載入 HBM 以進行嵌入的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,該運算會設定正確的嵌入表配置。例如,此運算用於安裝從檢查點載入的參數,然後再執行訓練迴圈。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量

tf.LoadTPUEmbeddingStochasticGradientDescentParametersGradAccumDebug (TF::LoadTPUEmbeddingStochasticGradientDescentParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

運算元

運算元 描述
parameters (參數) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.Log (TF::LogOp)

逐元素計算 x 的自然對數。

I.e., \(y = \log_e x\).

範例

x = tf.constant([0, 0.5, 1, 5])
tf.math.log(x) ==> [-inf, -0.6931472,  0. ,  1.609438]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Log1p (TF::Log1pOp)

逐元素計算 (1 + x) 的自然對數。

I.e., \(y = \log_e (1 + x)\).

範例

x = tf.constant([0, 0.5, 1, 5])
tf.math.log1p(x) ==> [0., 0.4054651, 0.6931472, 1.7917595]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_CwiseUnary

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.LogicalAnd (TF::LogicalAndOp)

逐元素回傳 x AND y 的真值。

特性:AlwaysSpeculatableImplTraitCommutativeResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
x 布林值的張量
y 布林值的張量

結果

結果 描述
z 布林值的張量

tf.LogicalNot (TF::LogicalNotOp)

逐元素回傳 NOT x 的真值。

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_Involution

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
x 布林值的張量

結果

結果 描述
y 布林值的張量

tf.LogicalOr (TF::LogicalOrOp)

逐元素回傳 x OR y 的真值。

特性:AlwaysSpeculatableImplTraitCommutativeResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
x 布林值的張量
y 布林值的張量

結果

結果 描述
z 布林值的張量

tf.LogSoftmax (TF::LogSoftmaxOp)

計算 log softmax 激活。

對於每個批次 i 和類別 j,我們有

logsoftmax[i, j] = logits[i, j] - log(sum(exp(logits[i])))

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
logits 浮點數值的張量

結果

結果 描述
logsoftmax 浮點數值的張量

tf.LookupTableExportV2 (TF::LookupTableExportV2Op)

輸出表格中所有的鍵和值。

屬性

屬性MLIR 類型描述
Tkeys::mlir::Attribute衍生屬性
Tvalues::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量

結果

結果 描述
keys (鍵) tf.dtype 值的張量
values tf.dtype 值的張量

tf.LookupTableFind (TF::LookupTableFindOp)

在表格中查找鍵,並輸出對應的值。

張量 keys 的類型必須與表格的鍵類型相同。輸出 values 的類型為表格的值類型。

純量 default_value 是當鍵在表格中不存在時輸出的值。它也必須與表格的值類型相同。

屬性

屬性MLIR 類型描述
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 字串值的張量
keys (鍵) tf.dtype 值的張量
default_value tf.dtype 值的張量

結果

結果 描述
values tf.dtype 值的張量

tf.LookupTableFindV2 (TF::LookupTableFindV2Op)

在表格中查找鍵,並輸出對應的值。

張量 keys 的類型必須與表格的鍵類型相同。輸出 values 的類型為表格的值類型。

純量 default_value 是當鍵在表格中不存在時輸出的值。它也必須與表格的值類型相同。

屬性

屬性MLIR 類型描述
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量
keys (鍵) tf.dtype 值的張量
default_value tf.dtype 值的張量

結果

結果 描述
values tf.dtype 值的張量

tf.LookupTableImportV2 (TF::LookupTableImportV2Op)

使用指定的鍵和值替換表格的內容。

張量 keys 的類型必須與表格的鍵類型相同。張量 values 的類型必須為表格的值類型。

屬性

屬性MLIR 類型描述
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量
keys (鍵) tf.dtype 值的張量
values tf.dtype 值的張量

tf.LookupTableInsertV2 (TF::LookupTableInsertV2Op)

更新表格以將鍵與值關聯。

張量 keys 的類型必須與表格的鍵類型相同。張量 values 的類型必須為表格的值類型。

屬性

屬性MLIR 類型描述
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量
keys (鍵) tf.dtype 值的張量
values tf.dtype 值的張量

tf.LookupTableRemoveV2 (TF::LookupTableRemoveV2Op)

從表格中移除鍵及其關聯的值。

張量 keys 的類型必須與表格的鍵類型相同。表格中不存在的鍵會被靜默忽略。

屬性

屬性MLIR 類型描述
Tin::mlir::Attribute衍生屬性

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量
keys (鍵) tf.dtype 值的張量

tf.LookupTableSize (TF::LookupTableSizeOp)

計算給定表格中的元素數量。

運算元

運算元 描述
table_handle (表格句柄) 字串值的張量

結果

結果 描述
size 64 位元整數值的張量

tf.LookupTableSizeV2 (TF::LookupTableSizeV2Op)

計算給定表格中的元素數量。

運算元

運算元 描述
table_handle (表格句柄) 資源值的張量

結果

結果 描述
size 64 位元整數值的張量

tf.LowerBound (TF::LowerBoundOp)

_沿著每一列套用 lower_bound(sorted_searchvalues, values)。_

在 (sorted_inputs, values) 中具有相同索引的每組列都會被獨立處理。結果列等同於呼叫 np.searchsorted(sorted_inputs, values, side='left')

結果不是整個 Tensor 的全域索引,而只是最後一個維度中的索引。

二維範例:sorted_sequence = [[0, 3, 9, 9, 10], [1, 2, 3, 4, 5]] values = [[2, 4, 9], [0, 2, 6]]

result = LowerBound(sorted_sequence, values)

result == [[1, 2, 2], [0, 1, 5]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
sorted_inputs tf.dtype 值的張量
values tf.dtype 值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.LRN (TF::LRNOp)

區域響應正規化。

4 維 input 張量被視為 1 維向量(沿最後一個維度)的 3 維陣列,並且每個向量都獨立正規化。在給定向量中,每個分量都除以 depth_radius 範圍內輸入的加權平方和。詳細來說,

sqr_sum[a, b, c, d] =
    sum(input[a, b, c, d - depth_radius : d + depth_radius + 1] ** 2)
output = input / (bias + alpha * sqr_sum) ** beta

詳細資訊請參閱 Krizhevsky 等人,《ImageNet classification with deep convolutional neural networks》(NIPS 2012)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
depth_radius::mlir::IntegerAttr64 位元無號整數屬性
bias::mlir::FloatAttr32 位元浮點屬性
alpha (Alpha)::mlir::FloatAttr32 位元浮點屬性
beta::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

tf.LRNGrad (TF::LRNGradOp)

區域響應正規化的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
depth_radius::mlir::IntegerAttr64 位元無號整數屬性
bias::mlir::FloatAttr32 位元浮點屬性
alpha (Alpha)::mlir::FloatAttr32 位元浮點屬性
beta::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
input_grads bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
input_image bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
output_image bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

tf.MakeIterator (TF::MakeIteratorOp)

從給定的 dataset 建立新的迭代器,並將其儲存在 iterator 中。

此操作可以執行多次。每次執行都會將 iterator 中的迭代器重設為 dataset 的第一個元素。

運算元

運算元 描述
dataset (資料集) 變體值的張量
iterator (迭代器) 資源值的張量

tf.MakeUnique (TF::MakeUniqueOp)

使非批次維度中的所有元素都是唯一的,但「接近」於

它們的初始值。永遠不會回傳次正規數。永遠不會回傳零。每個輸入元素的符號始終與對應輸出元素的符號相同。對於無限元素的行為未定義。對於次正規元素的行為未定義。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
輸入 32 位元浮點數值的張量

結果

結果 描述
輸出 32 位元浮點數值的張量

tf.MapAndBatchDataset (TF::MapAndBatchDatasetOp)

建立一個將映射與批次處理融合的資料集。

建立一個資料集,該資料集將 f 應用於 input_dataset 的輸出,然後將它們批次處理為 batch_size

與依序套用 f 的「MapDataset」不同,此資料集會平行調用最多 batch_size * num_parallel_batchesf 的副本。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
preserve_cardinality::mlir::BoolAttr布林屬性
metadata::mlir::StringAttr字串屬性
Targuments::mlir::Attribute衍生屬性

運算元

運算元 描述
input_dataset 變體值的張量
other_arguments tf.dtype 值的張量的可變參數
batch_size 64 位元整數值的張量
num_parallel_calls 64 位元整數值的張量
drop_remainder 布林值的張量

結果

結果 描述
handle 變體值的張量

tf.MapDataset (TF::MapDatasetOp)

建立一個將 f 套用至 input_dataset 輸出的資料集。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
use_inter_op_parallelism::mlir::BoolAttr布林屬性
preserve_cardinality::mlir::BoolAttr布林屬性
metadata::mlir::StringAttr字串屬性
Targuments::mlir::Attribute衍生屬性

運算元

運算元 描述
input_dataset 變體值的張量
other_arguments tf.dtype 值的張量的可變參數

結果

結果 描述
handle 變體值的張量

tf.MatMul (TF::MatMulOp)

將矩陣「a」乘以矩陣「b」。

輸入必須是二維矩陣,且「a」的內維度(如果 transpose_a 為 true 則轉置後)必須與「b」的外維度(如果 transposed_b 為 true 則轉置後)相符。

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
transpose_a::mlir::BoolAttr布林屬性
transpose_b::mlir::BoolAttr布林屬性
grad_a::mlir::BoolAttr布林屬性
grad_b::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
b bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
product bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.MatrixBandPart (TF::MatrixBandPartOp)

複製張量,並將每個最內層矩陣的中心帶之外的所有內容設為零。

band 部分的計算方式如下:假設 input 具有 k 個維度 [I, J, K, ..., M, N],則輸出是具有相同形狀的張量,其中

band[i, j, k, ..., m, n] = in_band(m, n) * input[i, j, k, ..., m, n].

指示函數

in_band(m, n) = (num_lower < 0 || (m-n) <= num_lower)) && (num_upper < 0 || (n-m) <= num_upper).

例如

# if 'input' is [[ 0,  1,  2, 3]
#                [-1,  0,  1, 2]
#                [-2, -1,  0, 1]
#                [-3, -2, -1, 0]],

tf.linalg.band_part(input, 1, -1) ==> [[ 0,  1,  2, 3]
                                       [-1,  0,  1, 2]
                                       [ 0, -1,  0, 1]
                                       [ 0,  0, -1, 0]],

tf.linalg.band_part(input, 2, 1) ==> [[ 0,  1,  0, 0]
                                      [-1,  0,  1, 0]
                                      [-2, -1,  0, 1]
                                      [ 0, -2, -1, 0]]

有用的特殊情況

 tf.linalg.band_part(input, 0, -1) ==> Upper triangular part.
 tf.linalg.band_part(input, -1, 0) ==> Lower triangular part.
 tf.linalg.band_part(input, 0, 0) ==> Diagonal.

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
num_lower 32/64 位元帶正負號的整數值的張量
num_upper 32/64 位元帶正負號的整數值的張量

結果

結果 描述
band tf.dtype 值的張量

tf.MatrixDiag (TF::MatrixDiagOp)

回傳具有給定批次對角線值的批次對角線張量。

給定 diagonal,此運算會傳回具有 diagonal 的張量,以及以零填補的所有其他內容。對角線的計算方式如下

假設 diagonal 具有 k 個維度 [I, J, K, ..., N],則輸出是秩為 k+1 的張量,其維度為 [I, J, K, ..., N, N],其中

output[i, j, k, ..., m, n] = 1{m=n} * diagonal[i, j, k, ..., n].

例如

# 'diagonal' is [[1, 2, 3, 4], [5, 6, 7, 8]]

and diagonal.shape = (2, 4)

tf.matrix_diag(diagonal) ==> [[[1, 0, 0, 0]
                                     [0, 2, 0, 0]
                                     [0, 0, 3, 0]
                                     [0, 0, 0, 4]],
                                    [[5, 0, 0, 0]
                                     [0, 6, 0, 0]
                                     [0, 0, 7, 0]
                                     [0, 0, 0, 8]]]

which has shape (2, 4, 4)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
diagonal tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MatrixDiagPartV3 (TF::MatrixDiagPartV3Op)

回傳批次張量的批次對角線部分。

回傳具有批次 input 的第 k[0] 個到第 k[1] 個對角線的張量。

假設 input 具有 r 個維度 [I, J, ..., L, M, N]。令 max_diag_len 為要提取的所有對角線中的最大長度,max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0))num_diags 為要提取的對角線數量,num_diags = k[1] - k[0] + 1

如果 num_diags == 1,則輸出張量的秩為 r - 1,形狀為 [I, J, ..., L, max_diag_len],值為

diagonal[i, j, ..., l, n]
  = input[i, j, ..., l, n+y, n+x] ; if 0 <= n+y < M and 0 <= n+x < N,
    padding_value                 ; otherwise.

其中 y = max(-k[1], 0)x = max(k[1], 0)

否則,輸出張量的秩為 r,維度為 [I, J, ..., L, num_diags, max_diag_len],值為

diagonal[i, j, ..., l, m, n]
  = input[i, j, ..., l, n+y, n+x] ; if 0 <= n+y < M and 0 <= n+x < N,
    padding_value                 ; otherwise.

其中 d = k[1] - my = max(-d, 0) - offset,且 x = max(d, 0) - offset

offset 為零,除非對角線的對齊方式為靠右對齊。

offset = max_diag_len - diag_len(d) ; if (`align` in {RIGHT_LEFT, RIGHT_RIGHT}
                                           and `d >= 0`) or
                                         (`align` in {LEFT_RIGHT, RIGHT_RIGHT}
                                           and `d <= 0`)
         0                          ; otherwise

其中 diag_len(d) = min(cols - max(d, 0), rows + min(d, 0))

輸入必須至少是一個矩陣。

例如

input = np.array([[[1, 2, 3, 4],  # Input shape: (2, 3, 4)
                   [5, 6, 7, 8],
                   [9, 8, 7, 6]],
                  [[5, 4, 3, 2],
                   [1, 2, 3, 4],
                   [5, 6, 7, 8]]])

# A main diagonal from each batch.
tf.matrix_diag_part(input) ==> [[1, 6, 7],  # Output shape: (2, 3)
                                [5, 2, 7]]

# A superdiagonal from each batch.
tf.matrix_diag_part(input, k = 1)
  ==> [[2, 7, 6],  # Output shape: (2, 3)
       [4, 3, 8]]

# A band from each batch.
tf.matrix_diag_part(input, k = (-1, 2))
  ==> [[[0, 3, 8],  # Output shape: (2, 4, 3)
        [2, 7, 6],
        [1, 6, 7],
        [5, 8, 0]],
       [[0, 3, 4],
        [4, 3, 8],
        [5, 2, 7],
        [1, 6, 0]]]

# LEFT_RIGHT alignment.
tf.matrix_diag_part(input, k = (-1, 2), align="LEFT_RIGHT")
  ==> [[[3, 8, 0],  # Output shape: (2, 4, 3)
        [2, 7, 6],
        [1, 6, 7],
        [0, 5, 8]],
       [[3, 4, 0],
        [4, 3, 8],
        [5, 2, 7],
        [0, 1, 6]]]

# max_diag_len can be shorter than the main diagonal.
tf.matrix_diag_part(input, k = (-2, -1))
  ==> [[[5, 8],
        [9, 0]],
       [[1, 6],
        [5, 0]]]

# padding_value = 9
tf.matrix_diag_part(input, k = (1, 3), padding_value = 9)
  ==> [[[9, 9, 4],  # Output shape: (2, 3, 3)
        [9, 3, 8],
        [2, 7, 6]],
       [[9, 9, 2],
        [9, 3, 4],
        [4, 3, 8]]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
align::mlir::StringAttr字串屬性,其值為 LEFT_RIGHT、RIGHT_LEFT、LEFT_LEFT 或 RIGHT_RIGHT
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
k 32 位元整數值的張量
padding_value tf.dtype 值的張量

結果

結果 描述
diagonal tf.dtype 值的張量

tf.MatrixDiagV2 (TF::MatrixDiagV2Op)

回傳具有給定批次對角線值的批次對角線張量。

回傳一個張量,其內容為 diagonal 作為矩陣的第 k[0] 個到第 k[1] 個對角線,所有其他內容都以 padding 填充。num_rowsnum_cols 指定輸出最內層矩陣的維度。如果兩者都未指定,則運算會假設最內層矩陣是方形的,並從 kdiagonal 的最內層維度推斷其大小。如果僅指定其中一個,則運算會根據其他準則假設未指定的值是最小的可能值。

diagonal 具有 r 個維度 [I, J, ..., L, M, N]。當僅給定一個對角線(k 為整數或 k[0] == k[1])時,輸出張量的秩為 r+1,形狀為 [I, J, ..., L, M, num_rows, num_cols]。否則,其秩為 r,形狀為 [I, J, ..., L, num_rows, num_cols]

diagonal 的第二個最內層維度具有雙重含義。當 k 為純量或 k[0] == k[1] 時,M 是批次大小 [I, J, ..., M] 的一部分,且輸出張量為

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, n-max(d_upper, 0)] ; if n - m == d_upper
    padding_value                             ; otherwise

否則,M 被視為同一批次中矩陣的對角線數量 (M = k[1]-k[0]+1),且輸出張量為

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, diag_index, index_in_diag] ; if k[0] <= d <= k[1]
    padding_value                                     ; otherwise

其中 d = n - mdiag_index = k[1] - d,且 index_in_diag = n - max(d, 0)

例如

# The main diagonal.
diagonal = np.array([[1, 2, 3, 4],            # Input shape: (2, 4)
                     [5, 6, 7, 8]])
tf.matrix_diag(diagonal) ==> [[[1, 0, 0, 0],  # Output shape: (2, 4, 4)
                               [0, 2, 0, 0],
                               [0, 0, 3, 0],
                               [0, 0, 0, 4]],
                              [[5, 0, 0, 0],
                               [0, 6, 0, 0],
                               [0, 0, 7, 0],
                               [0, 0, 0, 8]]]

# A superdiagonal (per batch).
diagonal = np.array([[1, 2, 3],  # Input shape: (2, 3)
                     [4, 5, 6]])
tf.matrix_diag(diagonal, k = 1)
  ==> [[[0, 1, 0, 0],  # Output shape: (2, 4, 4)
        [0, 0, 2, 0],
        [0, 0, 0, 3],
        [0, 0, 0, 0]],
       [[0, 4, 0, 0],
        [0, 0, 5, 0],
        [0, 0, 0, 6],
        [0, 0, 0, 0]]]

# A band of diagonals.
diagonals = np.array([[[1, 2, 3],  # Input shape: (2, 2, 3)
                       [4, 5, 0]],
                      [[6, 7, 9],
                       [9, 1, 0]]])
tf.matrix_diag(diagonals, k = (-1, 0))
  ==> [[[1, 0, 0],  # Output shape: (2, 3, 3)
        [4, 2, 0],
        [0, 5, 3]],
       [[6, 0, 0],
        [9, 7, 0],
        [0, 1, 9]]]

# Rectangular matrix.
diagonal = np.array([1, 2])  # Input shape: (2)
tf.matrix_diag(diagonal, k = -1, num_rows = 3, num_cols = 4)
  ==> [[0, 0, 0, 0],  # Output shape: (3, 4)
       [1, 0, 0, 0],
       [0, 2, 0, 0]]

# Rectangular matrix with inferred num_cols and padding_value = 9.
tf.matrix_diag(diagonal, k = -1, num_rows = 3, padding_value = 9)
  ==> [[9, 9],  # Output shape: (3, 2)
       [1, 9],
       [9, 2]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
diagonal tf.dtype 值的張量
k 32 位元整數值的張量
num_rows 32 位元整數值的張量
num_cols 32 位元整數值的張量
padding_value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MatrixDiagV3 (TF::MatrixDiagV3Op)

回傳具有給定批次對角線值的批次對角線張量。

回傳一個張量,其內容為 diagonal 作為矩陣的第 k[0] 個到第 k[1] 個對角線,所有其他內容都以 padding 填充。num_rowsnum_cols 指定輸出最內層矩陣的維度。如果兩者都未指定,則運算會假設最內層矩陣是方形的,並從 kdiagonal 的最內層維度推斷其大小。如果僅指定其中一個,則運算會根據其他準則假設未指定的值是最小的可能值。

diagonal 具有 r 個維度 [I, J, ..., L, M, N]。當僅給定一個對角線(k 為整數或 k[0] == k[1])時,輸出張量的秩為 r+1,形狀為 [I, J, ..., L, M, num_rows, num_cols]。否則,其秩為 r,形狀為 [I, J, ..., L, num_rows, num_cols]

diagonal 的第二個最內層維度具有雙重含義。當 k 為純量或 k[0] == k[1] 時,M 是批次大小 [I, J, ..., M] 的一部分,且輸出張量為

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, n-max(d_upper, 0)] ; if n - m == d_upper
    padding_value                             ; otherwise

否則,M 被視為同一批次中矩陣的對角線數量 (M = k[1]-k[0]+1),且輸出張量為

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, diag_index, index_in_diag] ; if k[0] <= d <= k[1]
    padding_value                                     ; otherwise

其中 d = n - mdiag_index = [k] - d,且 index_in_diag = n - max(d, 0) + offset

offset 為零,除非對角線的對齊方式為靠右對齊。

offset = max_diag_len - diag_len(d) ; if (`align` in {RIGHT_LEFT, RIGHT_RIGHT}
                                           and `d >= 0`) or
                                         (`align` in {LEFT_RIGHT, RIGHT_RIGHT}
                                           and `d <= 0`)
         0                          ; otherwise

其中 diag_len(d) = min(cols - max(d, 0), rows + min(d, 0))

例如

# The main diagonal.
diagonal = np.array([[1, 2, 3, 4],            # Input shape: (2, 4)
                     [5, 6, 7, 8]])
tf.matrix_diag(diagonal) ==> [[[1, 0, 0, 0],  # Output shape: (2, 4, 4)
                               [0, 2, 0, 0],
                               [0, 0, 3, 0],
                               [0, 0, 0, 4]],
                              [[5, 0, 0, 0],
                               [0, 6, 0, 0],
                               [0, 0, 7, 0],
                               [0, 0, 0, 8]]]

# A superdiagonal (per batch).
diagonal = np.array([[1, 2, 3],  # Input shape: (2, 3)
                     [4, 5, 6]])
tf.matrix_diag(diagonal, k = 1)
  ==> [[[0, 1, 0, 0],  # Output shape: (2, 4, 4)
        [0, 0, 2, 0],
        [0, 0, 0, 3],
        [0, 0, 0, 0]],
       [[0, 4, 0, 0],
        [0, 0, 5, 0],
        [0, 0, 0, 6],
        [0, 0, 0, 0]]]

# A tridiagonal band (per batch).
diagonals = np.array([[[0, 8, 9],  # Input shape: (2, 2, 3)
                       [1, 2, 3],
                       [4, 5, 0]],
                      [[0, 2, 3],
                       [6, 7, 9],
                       [9, 1, 0]]])
tf.matrix_diag(diagonals, k = (-1, 1))
  ==> [[[1, 8, 0],  # Output shape: (2, 3, 3)
        [4, 2, 9],
        [0, 5, 3]],
       [[6, 2, 0],
        [9, 7, 3],
        [0, 1, 9]]]

# LEFT_RIGHT alignment.
diagonals = np.array([[[8, 9, 0],  # Input shape: (2, 2, 3)
                       [1, 2, 3],
                       [0, 4, 5]],
                      [[2, 3, 0],
                       [6, 7, 9],
                       [0, 9, 1]]])
tf.matrix_diag(diagonals, k = (-1, 1), align="LEFT_RIGHT")
  ==> [[[1, 8, 0],  # Output shape: (2, 3, 3)
        [4, 2, 9],
        [0, 5, 3]],
       [[6, 2, 0],
        [9, 7, 3],
        [0, 1, 9]]]

# Rectangular matrix.
diagonal = np.array([1, 2])  # Input shape: (2)
tf.matrix_diag(diagonal, k = -1, num_rows = 3, num_cols = 4)
  ==> [[0, 0, 0, 0],  # Output shape: (3, 4)
       [1, 0, 0, 0],
       [0, 2, 0, 0]]

# Rectangular matrix with inferred num_cols and padding_value = 9.
tf.matrix_diag(diagonal, k = -1, num_rows = 3, padding_value = 9)
  ==> [[9, 9],  # Output shape: (3, 2)
       [1, 9],
       [9, 2]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
align::mlir::StringAttr字串屬性,其值為 LEFT_RIGHT、RIGHT_LEFT、LEFT_LEFT 或 RIGHT_RIGHT
T::mlir::Attribute衍生屬性

運算元

運算元 描述
diagonal tf.dtype 值的張量
k 32 位元整數值的張量
num_rows 32 位元整數值的張量
num_cols 32 位元整數值的張量
padding_value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MatrixInverse (TF::MatrixInverseOp)

計算一個或多個可逆方形矩陣或其伴隨矩陣(共軛轉置)的逆矩陣。

輸入是形狀為 [..., M, M] 的張量,其最內層的 2 個維度形成方形矩陣。輸出是與輸入形狀相同的張量,其中包含所有輸入子矩陣 [..., :, :] 的逆矩陣。

此運算使用帶有部分樞軸的 LU 分解來計算逆矩陣。

如果矩陣不可逆,則無法保證運算會執行什麼操作。它可能會偵測到該情況並引發例外,或者可能只是回傳垃圾結果。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
adjoint::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.MatrixSetDiag (TF::MatrixSetDiagOp)

回傳具有新批次對角線值的批次矩陣張量。

給定 inputdiagonal,此操作會回傳與 input 具有相同形狀和值的張量,但最內層矩陣的主對角線除外。這些將被 diagonal 中的值覆寫。

輸出的計算方式如下

假設 input 具有 k+1 個維度 [I, J, K, ..., M, N],而 diagonal 具有 k 個維度 [I, J, K, ..., min(M, N)]。則輸出是秩為 k+1 的張量,其維度為 [I, J, K, ..., M, N],其中

  • output[i, j, k, ..., m, n] = diagonal[i, j, k, ..., n],當 m == n 時。
  • output[i, j, k, ..., m, n] = input[i, j, k, ..., m, n],當 m != n 時。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
diagonal tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MatrixSetDiagV2 (TF::MatrixSetDiagV2Op)

回傳具有新批次對角線值的批次矩陣張量。

給定 inputdiagonal,此操作會回傳與 input 具有相同形狀和值的張量,但最內層矩陣的指定對角線除外。這些將被 diagonal 中的值覆寫。

input 具有 r+1 個維度 [I, J, ..., L, M, N]。當 k 為純量或 k[0] == k[1] 時,diagonal 具有 r 個維度 [I, J, ..., L, max_diag_len]。否則,它具有 r+1 個維度 [I, J, ..., L, num_diags, max_diag_len]num_diags 是對角線的數量,num_diags = k[1] - k[0] + 1max_diag_len 是範圍 [k[0], k[1]] 中最長的對角線,max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0))

輸出是秩為 k+1 的張量,其維度為 [I, J, ..., L, M, N]。如果 k 為純量或 k[0] == k[1]

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, n-max(k[1], 0)] ; if n - m == k[1]
    input[i, j, ..., l, m, n]              ; otherwise

否則,

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, diag_index, index_in_diag] ; if k[0] <= d <= k[1]
    input[i, j, ..., l, m, n]                         ; otherwise

其中 d = n - mdiag_index = k[1] - d,且 index_in_diag = n - max(d, 0)

例如

# The main diagonal.
input = np.array([[[7, 7, 7, 7],              # Input shape: (2, 3, 4)
                   [7, 7, 7, 7],
                   [7, 7, 7, 7]],
                  [[7, 7, 7, 7],
                   [7, 7, 7, 7],
                   [7, 7, 7, 7]]])
diagonal = np.array([[1, 2, 3],               # Diagonal shape: (2, 3)
                     [4, 5, 6]])
tf.matrix_set_diag(diagonal) ==> [[[1, 7, 7, 7],  # Output shape: (2, 3, 4)
                                   [7, 2, 7, 7],
                                   [7, 7, 3, 7]],
                                  [[4, 7, 7, 7],
                                   [7, 5, 7, 7],
                                   [7, 7, 6, 7]]]

# A superdiagonal (per batch).
tf.matrix_set_diag(diagonal, k = 1)
  ==> [[[7, 1, 7, 7],  # Output shape: (2, 3, 4)
        [7, 7, 2, 7],
        [7, 7, 7, 3]],
       [[7, 4, 7, 7],
        [7, 7, 5, 7],
        [7, 7, 7, 6]]]

# A band of diagonals.
diagonals = np.array([[[1, 2, 3],  # Diagonal shape: (2, 2, 3)
                       [4, 5, 0]],
                      [[6, 1, 2],
                       [3, 4, 0]]])
tf.matrix_set_diag(diagonals, k = (-1, 0))
  ==> [[[1, 7, 7, 7],  # Output shape: (2, 3, 4)
        [4, 2, 7, 7],
        [0, 5, 3, 7]],
       [[6, 7, 7, 7],
        [3, 1, 7, 7],
        [7, 4, 2, 7]]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
diagonal tf.dtype 值的張量
k 32 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MatrixSetDiagV3 (TF::MatrixSetDiagV3Op)

回傳具有新批次對角線值的批次矩陣張量。

給定 inputdiagonal,此操作會回傳與 input 具有相同形狀和值的張量,但最內層矩陣的指定對角線除外。這些將被 diagonal 中的值覆寫。

input 具有 r+1 個維度 [I, J, ..., L, M, N]。當 k 為純量或 k[0] == k[1] 時,diagonal 具有 r 個維度 [I, J, ..., L, max_diag_len]。否則,它具有 r+1 個維度 [I, J, ..., L, num_diags, max_diag_len]num_diags 是對角線的數量,num_diags = k[1] - k[0] + 1max_diag_len 是範圍 [k[0], k[1]] 中最長的對角線,max_diag_len = min(M + min(k[1], 0), N + min(-k[0], 0))

輸出是秩為 k+1 的張量,其維度為 [I, J, ..., L, M, N]。如果 k 為純量或 k[0] == k[1]

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, n-max(k[1], 0)] ; if n - m == k[1]
    input[i, j, ..., l, m, n]              ; otherwise

否則,

output[i, j, ..., l, m, n]
  = diagonal[i, j, ..., l, diag_index, index_in_diag] ; if k[0] <= d <= k[1]
    input[i, j, ..., l, m, n]                         ; otherwise

其中 d = n - mdiag_index = k[1] - d,且 index_in_diag = n - max(d, 0) + offset

offset 為零,除非對角線的對齊方式為靠右對齊。

offset = max_diag_len - diag_len(d) ; if (`align` in {RIGHT_LEFT, RIGHT_RIGHT}
                                           and `d >= 0`) or
                                         (`align` in {LEFT_RIGHT, RIGHT_RIGHT}
                                           and `d <= 0`)
         0                          ; otherwise

其中 diag_len(d) = min(cols - max(d, 0), rows + min(d, 0))

例如

# The main diagonal.
input = np.array([[[7, 7, 7, 7],              # Input shape: (2, 3, 4)
                   [7, 7, 7, 7],
                   [7, 7, 7, 7]],
                  [[7, 7, 7, 7],
                   [7, 7, 7, 7],
                   [7, 7, 7, 7]]])
diagonal = np.array([[1, 2, 3],               # Diagonal shape: (2, 3)
                     [4, 5, 6]])
tf.matrix_set_diag(input, diagonal)
  ==> [[[1, 7, 7, 7],  # Output shape: (2, 3, 4)
        [7, 2, 7, 7],
        [7, 7, 3, 7]],
       [[4, 7, 7, 7],
        [7, 5, 7, 7],
        [7, 7, 6, 7]]]

# A superdiagonal (per batch).
tf.matrix_set_diag(input, diagonal, k = 1)
  ==> [[[7, 1, 7, 7],  # Output shape: (2, 3, 4)
        [7, 7, 2, 7],
        [7, 7, 7, 3]],
       [[7, 4, 7, 7],
        [7, 7, 5, 7],
        [7, 7, 7, 6]]]

# A band of diagonals.
diagonals = np.array([[[0, 9, 1],  # Diagonal shape: (2, 4, 3)
                       [6, 5, 8],
                       [1, 2, 3],
                       [4, 5, 0]],
                      [[0, 1, 2],
                       [5, 6, 4],
                       [6, 1, 2],
                       [3, 4, 0]]])
tf.matrix_set_diag(input, diagonals, k = (-1, 2))
  ==> [[[1, 6, 9, 7],  # Output shape: (2, 3, 4)
        [4, 2, 5, 1],
        [7, 5, 3, 8]],
       [[6, 5, 1, 7],
        [3, 1, 6, 2],
        [7, 4, 2, 4]]]

# LEFT_RIGHT alignment.
diagonals = np.array([[[9, 1, 0],  # Diagonal shape: (2, 4, 3)
                       [6, 5, 8],
                       [1, 2, 3],
                       [0, 4, 5]],
                      [[1, 2, 0],
                       [5, 6, 4],
                       [6, 1, 2],
                       [0, 3, 4]]])
tf.matrix_set_diag(input, diagonals, k = (-1, 2), align="LEFT_RIGHT")
  ==> [[[1, 6, 9, 7],  # Output shape: (2, 3, 4)
        [4, 2, 5, 1],
        [7, 5, 3, 8]],
       [[6, 5, 1, 7],
        [3, 1, 6, 2],
        [7, 4, 2, 4]]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
align::mlir::StringAttr字串屬性,其值為 LEFT_RIGHT、RIGHT_LEFT、LEFT_LEFT 或 RIGHT_RIGHT
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
diagonal tf.dtype 值的張量
k 32 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MatrixSolve (TF::MatrixSolveOp)

求解線性方程式系統。

Matrix 是形狀為 [..., M, M] 的張量,其最內層的 2 個維度形成方形矩陣。Rhs 是形狀為 [..., M, K] 的張量。輸出是張量形狀 [..., M, K]。如果 adjointFalse,則每個輸出矩陣都滿足 matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]。如果 adjointTrue,則每個輸出矩陣都滿足 adjoint(matrix[..., :, :]) * output[..., :, :] = rhs[..., :, :]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
adjoint::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
matrix 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
rhs 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.MatrixTriangularSolve (TF::MatrixTriangularSolveOp)

透過反向替換求解具有上三角或下三角矩陣的線性方程式系統。

matrix 是形狀為 [..., M, M] 的張量,其最內層的 2 個維度形成方形矩陣。如果 lowerTrue,則假設每個最內層矩陣的嚴格上三角部分為零且未被存取。如果 lowerFalse,則假設每個最內層矩陣的嚴格下三角部分為零且未被存取。rhs 是形狀為 [..., M, N] 的張量。

輸出是形狀為 [..., M, N] 的張量。如果 adjointTrue,則 output 中的最內層矩陣滿足矩陣方程式 matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]。如果 adjointFalse,則嚴格來說,output 中的最內層矩陣滿足矩陣方程式 adjoint(matrix[..., i, k]) * output[..., k, j] = rhs[..., i, j]

注意,輸入的批次形狀只需要廣播。

範例


a = tf.constant([[3,  0,  0,  0],
                 [2,  1,  0,  0],
                 [1,  0,  1,  0],
                 [1,  1,  1,  1]], dtype=tf.float32)

b = tf.constant([[4],
                 [2],
                 [4],
                 [2]], dtype=tf.float32)

x = tf.linalg.triangular_solve(a, b, lower=True)
x
# <tf.Tensor: shape=(4, 1), dtype=float32, numpy=
# array([[ 1.3333334 ],
#        [-0.66666675],
#        [ 2.6666665 ],
#        [-1.3333331 ]], dtype=float32)>

# in python3 one can use `a@x`
tf.matmul(a, x)
# <tf.Tensor: shape=(4, 1), dtype=float32, numpy=
# array([[4.       ],
#        [2.       ],
#        [4.       ],
#        [1.9999999]], dtype=float32)>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
lower::mlir::BoolAttr布林屬性
adjoint::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
matrix 浮點數或複數值的張量
rhs 浮點數或複數值的張量

結果

結果 描述
輸出 浮點數或複數值的張量

tf.Max (TF::MaxOp)

計算張量維度中元素的最大值。

沿著 axis 中指定的維度縮減 input。除非 keep_dims 為 true,否則張量的等級會針對 axis 中的每個項目減少 1。如果 keep_dims 為 true,則縮減的維度會保留長度 1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
reduction_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.Maximum (TF::MaximumOp)

逐元素回傳 x 和 y 的最大值(即 x > y ? x : y)。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數或浮點數值的張量
y 整數或浮點數值的張量

結果

結果 描述
z 整數或浮點數值的張量

tf.MaxPool (TF::MaxPoolOp)

對輸入執行最大池化。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)TF_FoldOperandsTransposeInterfaceTF_LayoutSensitiveInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr值為 NHWC、NCHW 或 NCHW_VECT_C 的字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元量化整數或 16 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元量化整數或 16 位元無號整數或 8 位元無號整數值的張量

tf.MaxPool3D (TF::MaxPool3DOp)

對輸入執行 3D 最大池化。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

tf.MaxPool3DGrad (TF::MaxPool3DGradOp)

計算 3D 最大池化函數的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
T::mlir::Attribute衍生屬性
TInput::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
orig_output bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量
grad bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數值的張量

tf.MaxPool3DGradGrad (TF::MaxPool3DGradGradOp)

計算最大池化函數的二階梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 5 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr字串屬性,其值為 NDHWC 或 NCDHW
T::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input 整數或浮點數值的張量
orig_output 整數或浮點數值的張量
grad 整數或浮點數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.MaxPoolGrad (TF::MaxPoolGradOp)

計算最大池化函數的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr值為 SAME、VALID 或 EXPLICIT 的字串屬性
explicit_paddings::mlir::ArrayAttr64 位元整數陣列屬性
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input 整數或浮點數值的張量
orig_output 整數或浮點數值的張量
grad 整數或浮點數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.MaxPoolGradGrad (TF::MaxPoolGradGradOp)

計算最大池化函數的二階梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
ksize::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
strides::mlir::ArrayAttr具有至少 4 個元素的 64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input 整數或浮點數值的張量
orig_output 整數或浮點數值的張量
grad 整數或浮點數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.MaxPoolGradGradV2 (TF::MaxPoolGradGradV2Op)

計算最大池化函數的二階梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input 整數或浮點數值的張量
orig_output 整數或浮點數值的張量
grad 整數或浮點數值的張量
ksize 32 位元整數值的張量
strides 32 位元整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.MaxPoolGradV2 (TF::MaxPoolGradV2Op)

計算最大池化函數的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr'NHWC' 或 'NCHW' convnet 資料格式
T::mlir::Attribute衍生屬性

運算元

運算元 描述
orig_input 整數或浮點數值的張量
orig_output 整數或浮點數值的張量
grad 整數或浮點數值的張量
ksize 32 位元整數值的張量
strides 32 位元整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.MaxPoolV2 (TF::MaxPoolV2Op)

對輸入執行最大池化。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
padding::mlir::StringAttr字串屬性,其值為 SAME 或 VALID
data_format::mlir::StringAttr值為 NHWC、NCHW 或 NCHW_VECT_C 的字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元量化整數或 16 位元無號整數或 8 位元無號整數值的張量
ksize 32 位元整數值的張量
strides 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元量化整數或 16 位元無號整數或 8 位元無號整數值的張量

tf.Mean (TF::MeanOp)

計算張量維度中元素的平均值。

沿著 axis 中指定的維度縮減 input。除非 keep_dims 為 true,否則張量的等級會針對 axis 中的每個項目減少 1。如果 keep_dims 為 true,則縮減的維度會保留長度 1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TF_FoldOperandsTransposeInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 數字值的張量
reduction_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.MergeSummary (TF::MergeSummaryOp)

合併摘要。

此運算會建立一個 Summary 協定緩衝區,其中包含輸入摘要中所有值的聯集。

當運算執行時,如果多個要合併的摘要中的值使用相同的標籤,則會報告 InvalidArgument 錯誤。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs 字串值的張量的可變參數

結果

結果 描述
summary 字串值的張量

tf.MergeV2Checkpoints (TF::MergeV2CheckpointsOp)

V2 格式特定:合併分片檢查點的中繼資料檔案。此

結果是一個邏輯檢查點,具有一個實體中繼資料檔案和重新命名的資料檔案。

旨在「分組」分片檢查點設定中的多個檢查點。

如果 delete_old_dirs 為 true,則嘗試遞迴刪除輸入 checkpoint_prefixes 中每個路徑的 dirname。當這些路徑是非使用者面對的暫時位置時,這非常有用。

如果 allow_missing_files 為 true,只要至少存在一個檔案,就會合併檢查點前綴。否則,如果不存在任何檔案,則會擲回錯誤。allow_missing_files 的預設值為 false。

屬性

屬性MLIR 類型描述
delete_old_dirs::mlir::BoolAttr布林屬性
allow_missing_files::mlir::BoolAttr布林屬性

運算元

運算元 描述
checkpoint_prefixes 字串值的張量
destination_prefix 字串值的張量

tf.Min (TF::MinOp)

計算張量維度中元素的最小值。

沿著 axis 中指定的維度縮減 input。除非 keep_dims 為 true,否則張量的等級會針對 axis 中的每個項目減少 1。如果 keep_dims 為 true,則縮減的維度會保留長度 1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
reduction_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.Minimum (TF::MinimumOp)

逐元素回傳 x 和 y 的最小值(即 x < y ? x : y)。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數或浮點數值的張量
y 整數或浮點數值的張量

結果

結果 描述
z 整數或浮點數值的張量

tf.MirrorPad (TF::MirrorPadOp)

使用鏡像值填充張量。

此操作會根據您指定的 paddings 使用鏡像值填充 inputpaddings 是一個形狀為 [n, 2] 的整數張量,其中 n 是 input 的秩。對於 input 的每個維度 D,paddings[D, 0] 指示在該維度中 input 的內容之前要新增多少個值,而 paddings[D, 1] 指示在該維度中 input 的內容之後要新增多少個值。如果 copy_border 為 true(如果為 false,則分別為 input.dim_size(D) - 1),則 paddings[D, 0]paddings[D, 1] 都必須不超過 input.dim_size(D) (或 input.dim_size(D) - 1)。

輸出每個維度 D 的填充大小為

paddings(D, 0) + input.dim_size(D) + paddings(D, 1)

例如

# 't' is [[1, 2, 3], [4, 5, 6]].
# 'paddings' is [[1, 1]], [2, 2]].
# 'mode' is SYMMETRIC.
# rank of 't' is 2.
pad(t, paddings) ==> [[2, 1, 1, 2, 3, 3, 2]
                      [2, 1, 1, 2, 3, 3, 2]
                      [5, 4, 4, 5, 6, 6, 5]
                      [5, 4, 4, 5, 6, 6, 5]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
mode::mlir::StringAttr字串屬性,其值為 REFLECT 或 SYMMETRIC
T::mlir::Attribute衍生屬性
Tpaddings::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
paddings 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MirrorPadGrad (TF::MirrorPadGradOp)

MirrorPad 運算的梯度運算。此運算會摺疊鏡像填充的張量。

此操作會根據您指定的 paddings,透過 MirrorPad 摺疊 input 的填充區域。paddings 必須與提供給對應 MirrorPad 運算的 paddings 引數相同。

輸出每個維度 D 的摺疊大小為

input.dim_size(D) - paddings(D, 0) - paddings(D, 1)

例如

# 't' is [[1, 2, 3], [4, 5, 6], [7, 8, 9]].
# 'paddings' is [[0, 1]], [0, 1]].
# 'mode' is SYMMETRIC.
# rank of 't' is 2.
pad(t, paddings) ==> [[ 1,  5]
                      [11, 28]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
mode::mlir::StringAttr字串屬性,其值為 REFLECT 或 SYMMETRIC
T::mlir::Attribute衍生屬性
Tpaddings::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
paddings 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.MlirLocalVarOp (TF::MlirLocalVarOp)

建立範圍內變數的控制代碼。

由內部傳遞使用,用於暫時表示本機狀態,最終將被移除。

結果

結果 描述
resource 資源值的張量

tf.MlirPassthroughOp (TF::MlirPassthroughOp)

包裝表示為具有 main() 函數的模組的任意 MLIR 計算。

此操作沒有關聯的核心,並且不旨在在常規 TensorFlow 會期中執行。相反,它旨在用於測試或特殊情況,其中使用者打算透過 TensorFlow 圖傳遞自訂 MLIR 計算,目的是讓自訂工具在下游處理它(當目標為不同的環境時,例如 TensorFlow Lite)。MLIR 模組預期具有 main() 函數,該函數將用作進入點。運算的輸入將作為引數傳遞給 main() 函數,並且 main 函數的回傳值會映射到輸出。範例用法

import tensorflow as tf
from tensorflow.compiler.mlir.tensorflow.gen_mlir_passthrough_op import mlir_passthrough_op

mlir_module = '''python
func @main(%arg0 : tensor<10xf32>, %arg1 : tensor<10xf32>) -> tensor<10x10xf32> {
   %add = "magic.op"(%arg0, %arg1) : (tensor<10xf32>, tensor<10xf32>) -> tensor<10x10xf32>
   return %ret : tensor<10x10xf32>
}
'''

@tf.function
def foo(x, y):
  return mlir_passthrough_op([x, y], mlir_module, Toutputs=[tf.float32])

graph_def = foo.get_concrete_function(tf.TensorSpec([10], tf.float32), tf.TensorSpec([10], tf.float32)).graph.as_graph_def()

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
mlir_module::mlir::StringAttr字串屬性
Tinputs::mlir::Attribute衍生屬性
Toutputs::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf.Mod (TF::ModOp)

回傳元素級除法餘數。這模擬 C 語義,因為

此處的結果與截斷除法一致。例如,tf.truncatediv(x, y) * y + truncate_mod(x, y) = x

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或 32/64 位元帶號整數值的張量
y 浮點數或 32/64 位元帶號整數值的張量

結果

結果 描述
z 浮點數或 32/64 位元帶號整數值的張量

tf.ModelDataset (TF::ModelDatasetOp)

模擬效能的恆等轉換。

模擬效能的恆等轉換。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
algorithm::mlir::IntegerAttr64 位元無號整數屬性
cpu_budget::mlir::IntegerAttr64 位元無號整數屬性
ram_budget::mlir::IntegerAttr64 位元無號整數屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

運算元

運算元 描述
input_dataset 變體值的張量

結果

結果 描述
handle 變體值的張量

tf.Mul (TF::MulOp)

逐元素回傳 x * y。

Traits: AlwaysSpeculatableImplTrait, Commutative, ResultsBroadcastableShape, TF_CwiseBinary, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.MulNoNan (TF::MulNoNanOp)

逐元素回傳 x * y。如果 y 為零,則回傳零,即使 x 為無限或 NaN。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量
y 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.MultiDeviceIterator (TF::MultiDeviceIteratorOp)

建立 MultiDeviceIterator 資源。

屬性

屬性MLIR 類型描述
devices::mlir::ArrayAttr至少有 1 個元素的字串陣列屬性
shared_name::mlir::StringAttr字串屬性
container::mlir::StringAttr字串屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列

結果

結果 描述
handle 資源值的張量

tf.MultiDeviceIteratorFromStringHandle (TF::MultiDeviceIteratorFromStringHandleOp)

從其提供的字串控制代碼產生 MultiDeviceIterator 資源。

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr類型陣列屬性
output_shapes::mlir::ArrayAttrtensorflow 形狀屬性陣列

運算元

運算元 描述
string_handle (字串句柄) 字串值的張量

結果

結果 描述
multi_device_iterator 資源值的張量

tf.MultiDeviceIteratorGetNextFromShard (TF::MultiDeviceIteratorGetNextFromShardOp)

取得提供的分片編號的下一個元素。

屬性

屬性MLIR 類型描述
output_shapes::mlir::Attribute衍生屬性
output_types::mlir::Attribute衍生屬性

運算元

運算元 描述
multi_device_iterator 資源值的張量
shard_num 32 位元整數值的張量
incarnation_id 64 位元整數值的張量

結果

結果 描述
components (組件) tf.dtype 值的張量的可變參數

tf.MultiDeviceIteratorInit (TF::MultiDeviceIteratorInitOp)

使用給定的資料集初始化多裝置迭代器。

運算元

運算元 描述
dataset (資料集) 變體值的張量
multi_device_iterator 資源值的張量
max_buffer_size 64 位元整數值的張量

結果

結果 描述
incarnation_id 64 位元整數值的張量

tf.MultiDeviceIteratorToStringHandle (TF::MultiDeviceIteratorToStringHandleOp)

為給定的 MultiDeviceIterator 產生字串控制代碼。

運算元

運算元 描述
multi_device_iterator 資源值的張量

結果

結果 描述
string_handle (字串句柄) 字串值的張量

tf.Multinomial (TF::MultinomialOp)

從多項式分佈中繪製樣本。

Traits: TF_CannotDuplicate

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
output_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
logits 整數或浮點數值的張量
num_samples 32 位元整數值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.MutableDenseHashTableV2 (TF::MutableDenseHashTableV2Op)

建立一個空的雜湊表,該雜湊表使用張量作為後端儲存。

它使用「開放定址」和二次再探測來解決衝突。

此運算建立一個可變雜湊表,指定其鍵和值的類型。每個值都必須是純量。可以使用插入操作將資料插入到表格中。它不支援初始化操作。

屬性

屬性MLIR 類型描述
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
use_node_name_sharing (使用節點名稱共用)::mlir::BoolAttr布林屬性
value_dtype (值資料類型)::mlir::TypeAttr任何類型屬性
value_shape::mlir::AttributeTensorFlow 形狀屬性
initial_num_buckets::mlir::IntegerAttr64 位元無號整數屬性
max_load_factor::mlir::FloatAttr32 位元浮點屬性
key_dtype (鍵資料類型)::mlir::Attribute衍生屬性

運算元

運算元 描述
empty_key tf.dtype 值的張量
deleted_key tf.dtype 值的張量

結果

結果 描述
table_handle (表格句柄) 資源值的張量

tf.MutableHashTableOfTensorsV2 (TF::MutableHashTableOfTensorsV2Op)

建立一個空的雜湊表。

此運算建立一個可變雜湊表,指定其鍵和值的類型。每個值都必須是向量。可以使用插入操作將資料插入到表格中。它不支援初始化操作。

屬性

屬性MLIR 類型描述
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
use_node_name_sharing (使用節點名稱共用)::mlir::BoolAttr布林屬性
key_dtype (鍵資料類型)::mlir::TypeAttr任何類型屬性
value_dtype (值資料類型)::mlir::TypeAttr任何類型屬性
value_shape::mlir::AttributeTensorFlow 形狀屬性

結果

結果 描述
table_handle (表格句柄) 資源值的張量

tf.MutableHashTableV2 (TF::MutableHashTableV2Op)

建立一個空的雜湊表。

此運算建立一個可變雜湊表,指定其鍵和值的類型。每個值都必須是純量。可以使用插入操作將資料插入到表格中。它不支援初始化操作。

屬性

屬性MLIR 類型描述
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
use_node_name_sharing (使用節點名稱共用)::mlir::BoolAttr布林屬性
key_dtype (鍵資料類型)::mlir::TypeAttr任何類型屬性
value_dtype (值資料類型)::mlir::TypeAttr任何類型屬性

結果

結果 描述
table_handle (表格句柄) 資源值的張量

tf.NcclAllReduce (TF::NcclAllReduceOp)

輸出一個張量,其中包含跨所有輸入張量的縮減結果。

輸出一個張量,其中包含跨相同 shared_name 中運算傳遞的所有輸入張量的縮減結果。

圖形應建構為:如果一個運算以 shared_name 值 c 執行,則 num_devices 個運算將以 shared_name 值 c 執行。否則,將導致圖形執行失敗而無法完成。

輸入:縮減的輸入資料:跨所有 num_devices 裝置的縮減值。縮減:要執行的縮減運算。num_devices:參與此縮減的裝置數量。shared_name:在相同縮減的運算之間共用的識別符。

特性:InferTensorTypeTF::SameOperandsAndResultTypeResolveRef

Interfaces: GetResourceInstanceInterface, InferShapedTypeOpInterface, InferTypeOpInterface, TF_NcclAllReduceOrderingEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::NcclAllReduceOrdering}

屬性

屬性MLIR 類型描述
reduction::mlir::StringAttr字串屬性,其值為 min、max、prod 或 sum
num_devices::mlir::IntegerAttr64 位元無號整數屬性
shared_name::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
data 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.Ndtri (TF::NdtriOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.Neg (TF::NegOp)

逐元素計算數值負值。

I.e., \(y = -x\).

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_CwiseUnary, TF_Involution

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

結果

結果 描述
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

tf.NextAfter (TF::NextAfterOp)

逐元素回傳 x2 方向上 x1 的下一個可表示值。

此操作回傳與 C++ std::nextafter 函數相同的結果。

它也可以回傳次正規數。

@compatibility(cpp) 等同於 C++ std::nextafter 函數。 @end_compatibility

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x1 32/64 位元浮點數值的張量
x2 32/64 位元浮點數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.NonMaxSuppressionV3 (TF::NonMaxSuppressionV3Op)

貪婪地選擇邊界框的子集,並依分數降序排列,

修剪掉與先前選取的框具有高交集聯合 (IOU) 重疊的框。分數小於 score_threshold 的邊界框將被移除。邊界框以 [y1, x1, y2, x2] 的形式提供,其中 (y1, x1) 和 (y2, x2) 是框角任何對角線對的座標,並且座標可以提供為正規化(即,位於區間 [0, 1] 中)或絕對值。請注意,此演算法與座標系統中原點的位置無關,並且更廣泛地說,對於座標系統的正交變換和平移是不變的;因此,座標系統的平移或反射會導致演算法選取相同的框。此操作的輸出是一組整數,這些整數索引到代表選取框的邊界框輸入集合中。然後可以使用 tf.gather operation 取得對應於選取索引的邊界框座標。例如:selected_indices = tf.image.non_max_suppression_v2( boxes, scores, max_output_size, iou_threshold, score_threshold) selected_boxes = tf.gather(boxes, selected_indices)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
T_threshold::mlir::Attribute衍生屬性

運算元

運算元 描述
boxes 16 位元浮點數或 32 位元浮點數值的張量
scores 16 位元浮點數或 32 位元浮點數值的張量
max_output_size 32 位元整數值的張量
iou_threshold 16 位元浮點數或 32 位元浮點數值的張量
score_threshold 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
selected_indices 32 位元整數值的張量

tf.NonMaxSuppressionV4 (TF::NonMaxSuppressionV4Op)

貪婪地選擇邊界框的子集,並依分數降序排列,

修剪掉與先前選取的框具有高交集聯合 (IOU) 重疊的框。分數小於 score_threshold 的邊界框將被移除。邊界框以 [y1, x1, y2, x2] 的形式提供,其中 (y1, x1) 和 (y2, x2) 是框角任何對角線對的座標,並且座標可以提供為正規化(即,位於區間 [0, 1] 中)或絕對值。請注意,此演算法與座標系統中原點的位置無關,並且更廣泛地說,對於座標系統的正交變換和平移是不變的;因此,座標系統的平移或反射會導致演算法選取相同的框。此操作的輸出是一組整數,這些整數索引到代表選取框的邊界框輸入集合中。然後可以使用 tf.gather operation 取得對應於選取索引的邊界框座標。例如:selected_indices = tf.image.non_max_suppression_v2( boxes, scores, max_output_size, iou_threshold, score_threshold) selected_boxes = tf.gather(boxes, selected_indices)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
pad_to_max_output_size::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
T_threshold::mlir::Attribute衍生屬性

運算元

運算元 描述
boxes 16 位元浮點數或 32 位元浮點數值的張量
scores 16 位元浮點數或 32 位元浮點數值的張量
max_output_size 32 位元整數值的張量
iou_threshold 16 位元浮點數或 32 位元浮點數值的張量
score_threshold 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
selected_indices 32 位元整數值的張量
valid_outputs 32 位元整數值的張量

tf.NonMaxSuppressionV5 (TF::NonMaxSuppressionV5Op)

貪婪地選擇邊界框的子集,並依分數降序排列,

移除與先前選取框有高度交疊(Intersection-over-Union, IOU)的框。分數低於 score_threshold 的邊界框將被移除。邊界框以 [y1, x1, y2, x2] 的形式提供,其中 (y1, x1) 和 (y2, x2) 是框角任何對角線對的坐標,且坐標可以標準化(即位於區間 [0, 1])或絕對值形式提供。請注意,此演算法與坐標系統中原點的位置無關,更廣泛地說,它對於坐標系統的正交變換和平移是不變的;因此,坐標系統的平移或反射會導致演算法選取相同的框。此操作的輸出是一組整數,索引到代表所選框的邊界框輸入集合中。然後可以使用 tf.gather operation 取得與所選索引對應的邊界框坐標。例如:selected_indices = tf.image.non_max_suppression_v2( boxes, scores, max_output_size, iou_threshold, score_threshold) selected_boxes = tf.gather(boxes, selected_indices) 此運算也支援 Soft-NMS(具有高斯權重)模式(參考 Bodla et al, https://arxiv.org/abs/1704.04503),其中框會降低其他重疊框的分數,而不是直接導致它們被移除。若要啟用此 Soft-NMS 模式,請將 soft_nms_sigma 參數設定為大於 0。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
pad_to_max_output_size::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
boxes 16 位元浮點數或 32 位元浮點數值的張量
scores 16 位元浮點數或 32 位元浮點數值的張量
max_output_size 32 位元整數值的張量
iou_threshold 16 位元浮點數或 32 位元浮點數值的張量
score_threshold 16 位元浮點數或 32 位元浮點數值的張量
soft_nms_sigma 16 位元浮點數或 32 位元浮點數值的張量

結果

結果 描述
selected_indices 32 位元整數值的張量
selected_scores 16 位元浮點數或 32 位元浮點數值的張量
valid_outputs 32 位元整數值的張量

tf.NoOp (TF::NoOp)

不做任何事。僅作為控制邊的佔位符很有用。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

tf.NotEqual (TF::NotEqualOp)

逐元素傳回 (x != y) 的真值。

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
incompatible_shape_error::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
y tf.dtype 值的張量

結果

結果 描述
z 布林值的張量

tf.OneHot (TF::OneHotOp)

傳回 one-hot 張量。

indices 中的索引表示的位置取值 on_value,而所有其他位置取值 off_value

如果輸入 indices 的秩為 N,則輸出將具有秩 N+1。新軸建立於維度 axis(預設值:新軸附加在末尾)。

如果 indices 是純量,則輸出形狀將是長度為 depth 的向量。

如果 indices 是長度為 features 的向量,則輸出形狀將為

  features x depth if axis == -1
  depth x features if axis == 0

如果 indices 是形狀為 [batch, features] 的矩陣(批次),則輸出形狀將為

  batch x features x depth if axis == -1
  batch x depth x features if axis == 1
  depth x batch x features if axis == 0

範例

假設

  indices = [0, 2, -1, 1]
  depth = 3
  on_value = 5.0
  off_value = 0.0
  axis = -1

則輸出為 [4 x 3]

output =
  [5.0 0.0 0.0]  // one_hot(0)
  [0.0 0.0 5.0]  // one_hot(2)
  [0.0 0.0 0.0]  // one_hot(-1)
  [0.0 5.0 0.0]  // one_hot(1)

假設

  indices = [0, 2, -1, 1]
  depth = 3
  on_value = 0.0
  off_value = 3.0
  axis = 0

則輸出為 [3 x 4]

output =
  [0.0 3.0 3.0 3.0]
  [3.0 3.0 3.0 0.0]
  [3.0 3.0 3.0 3.0]
  [3.0 0.0 3.0 3.0]
//  ^                one_hot(0)
//      ^            one_hot(2)
//          ^        one_hot(-1)
//              ^    one_hot(1)

假設

  indices = [[0, 2], [1, -1]]
  depth = 3
  on_value = 1.0
  off_value = 0.0
  axis = -1

則輸出為 [2 x 2 x 3]

output =
  [
    [1.0, 0.0, 0.0]  // one_hot(0)
    [0.0, 0.0, 1.0]  // one_hot(2)
  ][
    [0.0, 1.0, 0.0]  // one_hot(1)
    [0.0, 0.0, 0.0]  // one_hot(-1)
  ]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
axis::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
TI::mlir::Attribute衍生屬性

運算元

運算元 描述
indices 32 位元整數或 64 位元整數或 8 位元整數或 8 位元無號整數值的張量
depth 32 位元整數值的張量
on_value tf.dtype 值的張量
off_value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.OneShotIterator (TF::OneShotIteratorOp)

建立只能迭代一次的「單次」迭代器。

單次迭代器將定義資料集和迭代器狀態的邏輯捆綁在單一運算中,這允許定義簡單的輸入管線,而無需額外的初始化 ("MakeIterator") 步驟。

單次迭代器有以下限制:

  • 它們不支援參數化:用於建立基礎資料集的所有邏輯都必須捆綁在 dataset_factory 函數中。
  • 它們不可重設。一旦單次迭代器到達其基礎資料集的末尾,後續對該迭代器的 "IteratorGetNext" 運算將始終產生 OutOfRange 錯誤。

為了獲得更大的彈性,請使用 "Iterator" 和 "MakeIterator" 來定義使用任意子圖的迭代器,該子圖可以捕獲張量(包括饋送值)作為參數,並且可以透過重新執行 "MakeIterator" 多次重設。

屬性

屬性MLIR 類型描述
dataset_factory::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性

結果

結果 描述
handle 資源值的張量

tf.OnesLike (TF::OnesLikeOp)

傳回與 x 具有相同形狀和類型的一張全為 1 的張量。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元不帶正負號的整數或 32 位元不帶正負號的整數或 64 位元不帶正負號的整數或 8 位元不帶正負號的整數值的張量

結果

結果 描述
y bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元不帶正負號的整數或 32 位元不帶正負號的整數或 64 位元不帶正負號的整數或 8 位元不帶正負號的整數值的張量

tf.OptimizeDatasetV2 (TF::OptimizeDatasetV2Op)

透過將相關最佳化套用至 input_dataset 來建立資料集。

透過將相關最佳化套用至 input_dataset 來建立資料集。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
optimization_configs::mlir::ArrayAttr字串陣列屬性

運算元

運算元 描述
input_dataset 變體值的張量
optimizations_enabled 字串值的張量
optimizations_disabled 字串值的張量
optimizations_default 字串值的張量

結果

結果 描述
handle 變體值的張量

tf.OptionalFromValue (TF::OptionalFromValueOp)

從張量元組建構 Optional 變體。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Toutput_types::mlir::Attribute衍生屬性

運算元

運算元 描述
components (組件) tf.dtype 值的張量的可變參數

結果

結果 描述
optional (可選) 變體值的張量

tf.OptionalGetValue (TF::OptionalGetValueOp)

傳回儲存在 Optional 變體中的值,如果不存在則引發錯誤。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_shapes::mlir::Attribute衍生屬性
output_types::mlir::Attribute衍生屬性

運算元

運算元 描述
optional (可選) 變體值的張量

結果

結果 描述
components (組件) tf.dtype 值的張量的可變參數

tf.OptionalHasValue (TF::OptionalHasValueOp)

當且僅當給定的 Optional 變體具有值時,傳回 true。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
optional (可選) 變體值的張量

結果

結果 描述
has_value 布林值的張量

tf.OptionalNone (TF::OptionalNoneOp)

建立沒有值的 Optional 變體。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

結果

結果 描述
optional (可選) 變體值的張量

tf.OutfeedEnqueue (TF::OutfeedEnqueueOp)

將張量排入計算輸出佇列。

屬性

屬性MLIR 類型描述
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

tf.OutfeedEnqueueTuple (TF::OutfeedEnqueueTupleOp)

將多個張量值排入計算輸出佇列。

屬性

屬性MLIR 類型描述
dtypes (資料類型)::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

tf.Pack (TF::PackOp)

N 個秩為 R 的張量列表封裝成一個秩為 (R+1) 的張量。

透過沿著 axis 維度封裝,將 values 中的 N 個張量封裝成秩比 values 中每個張量高一級的張量。給定形狀為 (A, B, C) 的張量列表;

如果 axis == 0,則 output 張量的形狀將為 (N, A, B, C)。如果 axis == 1,則 output 張量的形狀將為 (A, N, B, C)。依此類推。

例如

# 'x' is [1, 4]
# 'y' is [2, 5]
# 'z' is [3, 6]
pack([x, y, z]) => [[1, 4], [2, 5], [3, 6]]  # Pack along first dim.
pack([x, y, z], axis=1) => [[1, 2, 3], [4, 5, 6]]

這與 unpack 相反。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
axis::mlir::IntegerAttr64 位元無號整數屬性
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
values tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Pad (TF::PadOp)

用零填充張量。

此運算會根據您指定的 paddings 用零填充 inputpaddings 是形狀為 [Dn, 2] 的整數張量,其中 n 是 input 的秩。對於 input 的每個維度 D,paddings[D, 0] 指示在該維度中 input 的內容之前要新增多少個零,而 paddings[D, 1] 指示在該維度中 input 的內容之後要新增多少個零。

輸出每個維度 D 的填充大小為

paddings(D, 0) + input.dim_size(D) + paddings(D, 1)

例如

# 't' is [[1, 1], [2, 2]]
# 'paddings' is [[1, 1], [2, 2]]
# rank of 't' is 2
pad(t, paddings) ==> [[0, 0, 0, 0, 0, 0]
                      [0, 0, 1, 1, 0, 0]
                      [0, 0, 2, 2, 0, 0]
                      [0, 0, 0, 0, 0, 0]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), TF_FoldOperandsTransposeInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tpaddings::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
paddings 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.PadV2 (TF::PadV2Op)

填充張量。

此運算會根據您指定的 paddingsconstant_values 填充 inputpaddings 是形狀為 [Dn, 2] 的整數張量,其中 n 是 input 的秩。對於 input 的每個維度 D,paddings[D, 0] 指示在該維度中 input 的內容之前要新增多少個填充值,而 paddings[D, 1] 指示在該維度中 input 的內容之後要新增多少個填充值。constant_values 是與 input 相同類型的純量張量,指示用於填充 input 的值。

輸出每個維度 D 的填充大小為

paddings(D, 0) + input.dim_size(D) + paddings(D, 1)

例如

# 't' is [[1, 1], [2, 2]]
# 'paddings' is [[1, 1], [2, 2]]
# 'constant_values' is 0
# rank of 't' is 2
pad(t, paddings) ==> [[0, 0, 0, 0, 0, 0]
                      [0, 0, 1, 1, 0, 0]
                      [0, 0, 2, 2, 0, 0]
                      [0, 0, 0, 0, 0, 0]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tpaddings::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
paddings 32/64 位元帶正負號的整數值的張量
constant_values tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.ParallelDynamicStitch (TF::ParallelDynamicStitchOp)

data 張量的值交錯放入單一張量。

建構一個合併的張量,使得

    merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]

例如,如果每個 indices[m] 是純量或向量,則我們有

    # Scalar indices:
    merged[indices[m], ...] = data[m][...]

    # Vector indices:
    merged[indices[m][i], ...] = data[m][i, ...]

每個 data[i].shape 必須以對應的 indices[i].shape 開頭,且 data[i].shape 的其餘部分必須相對於 i 保持恆定。也就是說,我們必須有 data[i].shape = indices[i].shape + constant。根據此 constant,輸出形狀為

merged.shape = [max(indices)] + constant

值可能會並行合併,因此如果索引同時出現在 indices[m][i]indices[n][j] 中,則結果可能無效。這與在該情況下定義行為的正常 DynamicStitch 運算符不同。

例如

    indices[0] = 6
    indices[1] = [4, 1]
    indices[2] = [[5, 2], [0, 3]]
    data[0] = [61, 62]
    data[1] = [[41, 42], [11, 12]]
    data[2] = [[[51, 52], [21, 22]], [[1, 2], [31, 32]]]
    merged = [[1, 2], [11, 12], [21, 22], [31, 32], [41, 42],
              [51, 52], [61, 62]]

此方法可用於合併由 dynamic_partition 建立的分割區,如下列範例所示

    # Apply function (increments x_i) on elements for which a certain condition
    # apply (x_i != -1 in this example).
    x=tf.constant([0.1, -1., 5.2, 4.3, -1., 7.4])
    condition_mask=tf.not_equal(x,tf.constant(-1.))
    partitioned_data = tf.dynamic_partition(
        x, tf.cast(condition_mask, tf.int32) , 2)
    partitioned_data[1] = partitioned_data[1] + 1.0
    condition_indices = tf.dynamic_partition(
        tf.range(tf.shape(x)[0]), tf.cast(condition_mask, tf.int32) , 2)
    x = tf.dynamic_stitch(condition_indices, partitioned_data)
    # Here x=[1.1, -1., 6.2, 5.3, -1, 8.4], the -1. values remain
    # unchanged.

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
indices 32 位元整數值的張量的變數
data tf.dtype 值的張量的可變參數

結果

結果 描述
merged tf.dtype 值的張量

tf.ParallelMapDataset (TF::ParallelMapDatasetOp)

建立一個將 f 套用至 input_dataset 輸出的資料集。

與依序套用 f 的 "MapDataset" 不同,此資料集並行調用最多 num_parallel_callsf 副本。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
use_inter_op_parallelism::mlir::BoolAttr布林屬性
sloppy::mlir::BoolAttr布林屬性
preserve_cardinality::mlir::BoolAttr布林屬性
metadata::mlir::StringAttr字串屬性
Targuments::mlir::Attribute衍生屬性

運算元

運算元 描述
input_dataset 變體值的張量
other_arguments tf.dtype 值的張量的可變參數
num_parallel_calls 32 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.ParallelMapDatasetV2 (TF::ParallelMapDatasetV2Op)

建立一個將 f 套用至 input_dataset 輸出的資料集。

與依序套用 f 的 "MapDataset" 不同,此資料集並行調用最多 num_parallel_callsf 副本。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
use_inter_op_parallelism::mlir::BoolAttr布林屬性
deterministic::mlir::StringAttr字串屬性
preserve_cardinality::mlir::BoolAttr布林屬性
metadata::mlir::StringAttr字串屬性
Targuments::mlir::Attribute衍生屬性

運算元

運算元 描述
input_dataset 變體值的張量
other_arguments tf.dtype 值的張量的可變參數
num_parallel_calls 64 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.ParameterizedTruncatedNormal (TF::ParameterizedTruncatedNormalOp)

從常態分佈輸出隨機值。參數可以是

套用於整個輸出的純量,或長度為 shape[0] 的向量,其儲存每個批次的參數。

Traits: TF_CannotDuplicate

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
means 浮點數值的張量
stdevs 浮點數值的張量
minvals 浮點數值的張量
maxvals 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.ParseExample (TF::ParseExampleOp)

將 tf.Example 原型(作為字串)的向量轉換為類型化的張量。

特性:AlwaysSpeculatableImplTraitAttrSizedOperandSegmentsAttrSizedResultSegments

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dense_shapes::mlir::ArrayAttrtensorflow 形狀屬性陣列
Nsparse::mlir::Attribute衍生屬性
Ndense::mlir::Attribute衍生屬性
Tdense::mlir::Attribute衍生屬性
sparse_types::mlir::Attribute衍生屬性

運算元

運算元 描述
serialized 字串值的張量
names 字串值的張量
sparse_keys 字串值的張量的可變參數
dense_keys 字串值的張量的可變參數
dense_defaults 32 位元浮點數或 64 位元整數或字串值的張量的 variadic

結果

結果 描述
sparse_indices 64 位元整數值的張量的可變參數
sparse_values 32 位元浮點數或 64 位元整數或字串值的張量的 variadic
sparse_shapes 64 位元整數值的張量的可變參數
dense_values 32 位元浮點數或 64 位元整數或字串值的張量的 variadic

tf.ParseExampleV2 (TF::ParseExampleV2Op)

將 tf.Example 原型(作為字串)的向量轉換為類型化的張量。

特性:AlwaysSpeculatableImplTraitAttrSizedResultSegments

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_sparse::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
dense_shapes::mlir::ArrayAttrtensorflow 形狀屬性陣列
Tdense::mlir::Attribute衍生屬性
sparse_types::mlir::Attribute衍生屬性
ragged_value_types::mlir::Attribute衍生屬性
ragged_split_types::mlir::Attribute衍生屬性

運算元

運算元 描述
serialized 字串值的張量
names 字串值的張量
sparse_keys 字串值的張量
dense_keys 字串值的張量
ragged_keys 字串值的張量
dense_defaults 32 位元浮點數或 64 位元整數或字串值的張量的 variadic

結果

結果 描述
sparse_indices 64 位元整數值的張量的可變參數
sparse_values 32 位元浮點數或 64 位元整數或字串值的張量的 variadic
sparse_shapes 64 位元整數值的張量的可變參數
dense_values 32 位元浮點數或 64 位元整數或字串值的張量的 variadic
ragged_values 32 位元浮點數或 64 位元整數或字串值的張量的 variadic
ragged_row_splits 32 位元整數或 64 位元整數值的張量的 variadic

tf.PartitionedCall (TF::PartitionedCallOp)

傳回 f(inputs),其中 f 的主體被放置和分割。

非同步執行函數,可能跨多個裝置但在單一進程內。核心放置和分割給定函數的底層圖,並將每個分割的子圖作為函數執行。

Traits: AlwaysSpeculatableImplTrait

介面: CallOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), SymbolUserOpInterface

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
config::mlir::StringAttr字串屬性
config_proto::mlir::StringAttr字串屬性
executor_type::mlir::StringAttr字串屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.Placeholder (TF::PlaceholderOp)

Placeholder 運算

插入將始終饋送的張量的佔位符。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dtype::mlir::Attribute衍生屬性

結果

結果 描述
輸出 tf.dtype 值的張量

tf.PlaceholderWithDefault (TF::PlaceholderWithDefaultOp)

Placeholder 運算

當輸出未饋送時,傳遞輸入的佔位符運算。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dtype::mlir::Attribute衍生屬性
shape::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Polygamma (TF::PolygammaOp)

計算多伽瑪函數 \(\psi^{(n)}(x)\)。

多伽瑪函數定義為

\(\psi^{(a)}(x) = \frac{d^a}{dx^a} \psi(x)\)

其中 \(\psi(x)\) 是雙伽瑪函數。多伽瑪函數僅針對非負整數階 \a\ 定義。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 32/64 位元浮點數值的張量
x 32/64 位元浮點數值的張量

結果

結果 描述
z 32/64 位元浮點數值的張量

tf.PopulationCount (TF::PopulationCountOp)

逐元素計算人口數(又稱 popcount、bitsum、bitcount)。

對於 x 中的每個條目,計算該條目的二進位表示法中 1(開啟)位元的數量。

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數值的張量

結果

結果 描述
y 8 位元無號整數值的張量

tf.Pow (TF::PowOp)

計算一個值對另一個值的冪。

給定張量 x 和張量 y,此運算會計算 xy 中對應元素的 \(x^y\)。例如

# tensor 'x' is [[2, 2]], [3, 3]]
# tensor 'y' is [[8, 16], [2, 3]]
tf.pow(x, y) ==> [[256, 65536], [9, 27]]

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

tf.PrefetchDataset (TF::PrefetchDatasetOp)

建立一個資料集,以非同步方式從 input_dataset 預先提取元素。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
slack_period::mlir::IntegerAttr64 位元無號整數屬性
legacy_autotune::mlir::BoolAttr布林屬性
buffer_size_min::mlir::IntegerAttr64 位元無號整數屬性
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
buffer_size 64 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.PreventGradient (TF::PreventGradientOp)

如果請求梯度,則觸發錯誤的恆等運算。

在圖形中執行時,此運算會按原樣輸出其輸入張量。

在建構運算以計算梯度時,當嘗試查閱此運算的梯度時,TensorFlow 梯度系統將傳回錯誤,因為絕不能為此函數註冊梯度。此運算的存在是為了防止在某些邊角情況下靜默傳回未實作梯度的細微錯誤。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
message::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Print (TF::PrintOp)

列印張量列表。

input 傳遞到 output,並在評估時列印 data

屬性

屬性MLIR 類型描述
message::mlir::StringAttr字串屬性
first_n::mlir::IntegerAttr64 位元無號整數屬性
summarize::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
U::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
data tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量

tf.PrintV2 (TF::PrintV2Op)

列印字串純量。

將字串純量列印到所需的 output_stream。

屬性

屬性MLIR 類型描述
output_stream::mlir::StringAttr字串屬性
end::mlir::StringAttr字串屬性

運算元

運算元 描述
輸入 字串值的張量

tf.Prod (TF::ProdOp)

計算張量維度上的元素乘積。

沿著 axis 中指定的維度縮減 input。除非 keep_dims 為 true,否則張量的等級會針對 axis 中的每個項目減少 1。如果 keep_dims 為 true,則縮減的維度會保留長度 1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 數字值的張量
reduction_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.Qr (TF::QrOp)

計算一個或多個矩陣的 QR 分解。

計算 tensor 中每個內部矩陣的 QR 分解,使得 tensor[..., :, :] = q[..., :, :] * r[..., :,:])

目前,僅當內部矩陣的前 P 行線性獨立時,QR 分解的梯度才是明確定義的,其中 PMN 的最小值,即 tensor 的 2 個最內層維度。

# a is a tensor.
# q is a tensor of orthonormal matrices.
# r is a tensor of upper triangular matrices.
q, r = qr(a)
q_full, r_full = qr(a, full_matrices=True)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
full_matrices::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
q 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
r 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.QuantizeAndDequantize (TF::QuantizeAndDequantizeOp)

請改用 QuantizeAndDequantizeV2。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
signed_input::mlir::BoolAttr布林屬性
num_bits::mlir::IntegerAttr64 位元無號整數屬性
range_given::mlir::BoolAttr布林屬性
input_min::mlir::FloatAttr32 位元浮點屬性
input_max::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.QuantizeAndDequantizeV2 (TF::QuantizeAndDequantizeV2Op)

量化然後反量化張量。

此運算透過以下方式模擬來自量化正向傳遞的精確度損失:

  1. 將張量量化為定點數,這應與在推論中使用時的目標量化方法相符。
  2. 將其反量化回浮點數,以用於後續運算,最可能是矩陣乘法。

有不同的量化方式。此版本僅使用縮放,因此 0.0 對應到 0。

從量化輸出類型中指定的 'num_bits',它會判斷最小和最大可表示的量化值。

例如:

  • [-128, 127](適用於帶正負號),num_bits = 8,或
  • [0, 255](適用於不帶正負號),num_bits = 8。

如果 range_given == False,則初始 input_min、input_max 將自動判斷為輸入張量中的最小值和最大值,否則將使用指定的 input_min、input_max 值。

此運算判斷最大 scale_factor,該 scale_factor 會將初始 [input_min, input_max] 範圍對應到位於可表示的量化範圍內的一個範圍。

它從 input_min 和 input_max 中的一個判斷比例,然後更新另一個以最大化可表示範圍。

例如:

  • 如果輸出是帶正負號的,num_bits = 8,[input_min, input_max] = [-10.0, 5.0]:它將使用 -128 / -10.0 = 12.8 的 scale_factor。在這種情況下,它會將 input_max 更新為 127 / 12.8 = 9.921875
  • 如果輸出是帶正負號的,num_bits = 8,[input_min, input_max] = [-10.0, 10.0]:它將使用 127 / 10.0 = 12.7 的 scale_factor。在這種情況下,它會將 input_min 更新為 128.0 / 12.7 = -10.07874
  • 如果輸出是不帶正負號的,則強制 input_min 為 0,並且僅使用指定的 input_max。

在判斷 scale_factor 並更新輸入範圍之後,它將以下內容套用至 'input' 張量中的每個值。

output = round(clamp(value, input_min, input_max) * scale_factor) / scale_factor。

上面的 round 函數根據給定的 round_mode 對值進行四捨五入。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
signed_input::mlir::BoolAttr布林屬性
num_bits::mlir::IntegerAttr64 位元無號整數屬性
range_given::mlir::BoolAttr布林屬性
round_mode::mlir::StringAttr字串屬性,其值為 HALF_TO_EVEN 或 HALF_UP
narrow_range::mlir::BoolAttr布林屬性
axis::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
input_min 浮點數值的張量
input_max 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.QuantizeAndDequantizeV3 (TF::QuantizeAndDequantizeV3Op)

量化然後反量化張量。

這幾乎與 QuantizeAndDequantizeV2 相同,不同之處在於 num_bits 是一個張量,因此其值可以在訓練期間變更。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
signed_input::mlir::BoolAttr布林屬性
range_given::mlir::BoolAttr布林屬性
narrow_range::mlir::BoolAttr布林屬性
axis::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
input_min 浮點數值的張量
input_max 浮點數值的張量
num_bits 32 位元整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.QuantizeAndDequantizeV4 (TF::QuantizeAndDequantizeV4Op)

量化然後反量化張量。

這幾乎與 QuantizeAndDequantizeV2 相同,不同之處在於它會針對量化範圍內的輸入傳回梯度 1,否則傳回 0。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
signed_input::mlir::BoolAttr布林屬性
num_bits::mlir::IntegerAttr64 位元無號整數屬性
range_given::mlir::BoolAttr布林屬性
round_mode::mlir::StringAttr字串屬性,其值為 HALF_TO_EVEN 或 HALF_UP
narrow_range::mlir::BoolAttr布林屬性
axis::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 浮點數值的張量
input_min 浮點數值的張量
input_max 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.QuantizeV2 (TF::QuantizeV2Op)

將 'input' 張量(類型為浮點數)量化為 'output' 張量(類型為 'T')。

[min_range, max_range] 是純量浮點數,指定 'input' 資料的範圍。 'mode' 屬性精確控制用於將浮點數值轉換為其量化等效值的計算。 'round_mode' 屬性控制在將浮點數值四捨五入為其量化等效值時使用的四捨五入平手演算法。

在 'MIN_COMBINED' 模式中,張量的每個值都將經歷以下過程

out[i] = (in[i] - min_range) * range(T) / (max_range - min_range)
if T == qint8: out[i] -= (range(T) + 1) / 2.0

此處 range(T) = numeric_limits<T>::max() - numeric_limits<T>::min()

MIN_COMBINED 模式範例

假設輸入類型為浮點數,且可能範圍為 [0.0, 6.0],而輸出類型為 quint8 ([0, 255])。 min_range 和 max_range 值應指定為 0.0 和 6.0。從浮點數量化為 quint8 會將輸入的每個值乘以 255/6 並轉換為 quint8。

如果輸出類型為 qint8 ([-128, 127]),則運算還會在轉換之前從每個值中減去 128,以使值的範圍與 qint8 的範圍對齊。

如果模式為 'MIN_FIRST',則會使用此方法

num_discrete_values = 1 << (# of bits in T)
range_adjust = num_discrete_values / (num_discrete_values - 1)
range = (range_max - range_min) * range_adjust
range_scale = num_discrete_values / range
quantized = round(input * range_scale) - round(range_min * range_scale) +
  numeric_limits<T>::min()
quantized = max(quantized, numeric_limits<T>::min())
quantized = min(quantized, numeric_limits<T>::max())

此運算與 MIN_COMBINED 之間的最大區別在於,最小範圍會先四捨五入,然後再從四捨五入的值中減去。使用 MIN_COMBINED,會引入小的偏差,其中重複迭代量化和反量化會引入越來越大的誤差。

SCALED 模式範例

SCALED 模式符合 QuantizeAndDequantize{V2|V3} 中使用的量化方法。

如果模式為 SCALED,則量化是透過將每個輸入值乘以 scaling_factor 來執行的。 scaling_factor 是從 min_rangemax_range 判斷的,使其盡可能大,以便從 min_rangemax_range 的範圍可在 T 類型的值內表示。


  const int min_T = std::numeric_limits<T>::min();
  const int max_T = std::numeric_limits<T>::max();
  const float max_float = std::numeric_limits<float>::max();

  const float scale_factor_from_min_side =
      (min_T * min_range > 0) ? min_T / min_range : max_float;
  const float scale_factor_from_max_side =
      (max_T * max_range > 0) ? max_T / max_range : max_float;

  const float scale_factor = std::min(scale_factor_from_min_side,
                                      scale_factor_from_max_side);

接下來,我們使用 scale_factor 如下調整 min_range 和 max_range

      min_range = min_T / scale_factor;
      max_range = max_T / scale_factor;

例如,如果 T = qint8,且初始 min_range = -10,且 max_range = 9,我們將比較 -128/-10.0 = 12.8 與 127/9.0 = 14.11,並設定 scaling_factor = 12.8。在這種情況下,min_range 將保持 -10,但 max_range 將調整為 127 / 12.8 = 9.921875

因此,我們將量化範圍 (-10, 9.921875) 中的輸入值為 (-128, 127)。

現在可以透過將值裁剪到 min_rangemax_range 的範圍,然後乘以 scale_factor 如下來量化輸入張量

result = round(min(max_range, max(min_range, input)) * scale_factor)

調整後的 min_rangemax_range 作為此運算的輸出 2 和 3 傳回。這些輸出應作為任何進一步計算的範圍使用。

narrow_range (bool) 屬性

如果為 true,我們不會使用最小量化值。也就是說,對於 int8 的量化輸出,它將限制為範圍 -127..127,而不是完整的 -128..127 範圍。這是為了與某些推論後端相容而提供的。(僅適用於 SCALED 模式)

axis (int) 屬性

選用的 axis 屬性可以指定輸入張量的維度索引,以便沿該維度的張量的每個切片分別計算和套用量化範圍。這對於每個通道的量化很有用。

如果指定了 axis,則 min_range 和 max_range

如果 axis=None,則正常執行每個張量的量化。

ensure_minimum_range (float) 屬性

確保最小量化範圍至少為此值。此值的舊版預設值為 0.01,但強烈建議對於新用途將其設定為 0。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
mode::mlir::StringAttr字串屬性,其值為 MIN_COMBINED、MIN_FIRST 或 SCALED
round_mode::mlir::StringAttr字串屬性,其值為 HALF_AWAY_FROM_ZERO 或 HALF_TO_EVEN
narrow_range::mlir::BoolAttr布林屬性
axis::mlir::IntegerAttr64 位元無號整數屬性
ensure_minimum_range::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32 位元浮點數值的張量
min_range 32 位元浮點數值的張量
max_range 32 位元浮點數值的張量

結果

結果 描述
輸出 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數值的張量
output_min 32 位元浮點數值的張量
output_max 32 位元浮點數值的張量

tf.QueueDequeueV2 (TF::QueueDequeueV2Op)

從給定的佇列中取消佇列一個或多個張量的元組。

此運算具有 k 個輸出,其中 k 是儲存在給定佇列中的元組中的元件數,而輸出 i 是取消佇列的元組的第 i 個元件。

注意:如果佇列為空,則此運算將封鎖,直到元素已取消佇列(或經過 'timeout_ms',如果已指定)。

屬性

屬性MLIR 類型描述
timeout_ms::mlir::IntegerAttr64 位元無號整數屬性
component_types::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量

結果

結果 描述
components (組件) tf.dtype 值的張量的可變參數

tf.RaggedGather (TF::RaggedGatherOp)

根據 indicesparams0 收集參差不齊的切片。

輸出從 output_dense_valuesoutput_nested_splits 組成的 RaggedTensor 輸出,使得

output.shape = indices.shape + params.shape[1:]
output.ragged_rank = indices.shape.ndims + params.ragged_rank
output[i...j, d0...dn] = params[indices[i...j], d0...dn]

其中

  • params = ragged.from_nested_row_splits(params_dense_values, params_nested_splits) 提供應收集的值。
  • indices 是具有 dtype int32int64 的密集張量,指示應收集哪些值。
  • output = ragged.from_nested_row_splits(output_dense_values, output_nested_splits) 是輸出張量。

(注意:此 c++ 運算用於實作較高層級的 python tf.ragged.gather 運算,其也支援參差不齊的索引。)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
PARAMS_RAGGED_RANK::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tsplits::mlir::Attribute衍生屬性
Tvalues::mlir::Attribute衍生屬性
OUTPUT_RAGGED_RANK::mlir::Attribute衍生屬性

運算元

運算元 描述
params_nested_splits 32/64 位元有號整數值的張量變數
params_dense_values tf.dtype 值的張量
indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
output_nested_splits 32/64 位元有號整數值的張量變數
output_dense_values tf.dtype 值的張量

tf.RaggedRange (TF::RaggedRangeOp)

傳回包含指定數字序列的 RaggedTensor

傳回從 rt_dense_valuesrt_nested_splits 組成的 RaggedTensor result,使得 result[i] = range(starts[i], limits[i], deltas[i])

(rt_nested_splits, rt_dense_values) = ragged_range(
      starts=[2, 5, 8], limits=[3, 5, 12], deltas=1)
result = tf.ragged.from_row_splits(rt_dense_values, rt_nested_splits)
print(result)
<tf.RaggedTensor [[2], [], [8, 9, 10, 11]] >

輸入張量 startslimitsdeltas 可以是純量或向量。向量輸入必須都具有相同的大小。純量輸入會廣播以符合向量輸入的大小。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tsplits::mlir::Attribute衍生屬性

運算元

運算元 描述
starts bfloat16 或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量
limits bfloat16 或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量
deltas bfloat16 或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
rt_nested_splits 32/64 位元帶正負號的整數值的張量
rt_dense_values bfloat16 或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.RandomGamma (TF::RandomGammaOp)

從 alpha 描述的 Gamma 分佈輸出隨機值。

此運算使用 Marsaglia et al. 的演算法,透過從均勻和常態隨機變數對進行轉換-拒絕來取得樣本。請參閱 http://dl.acm.org/citation.cfm?id=358414

Traits: TF_CannotDuplicate

介面:TF_RandomGeneratorSideEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::RandomGenerator}

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
S::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
alpha (Alpha) 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.RandomGammaGrad (TF::RandomGammaGradOp)

計算 Gamma 隨機樣本相對於 alpha 的導數。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
alpha (Alpha) 32/64 位元浮點數值的張量
sample 32/64 位元浮點數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.RandomPoisson (TF::RandomPoissonOp)

請改用 RandomPoissonV2。

Traits: TF_CannotDuplicate

介面:TF_RandomGeneratorSideEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::RandomGenerator}

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
S::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
rate 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.RandomPoissonV2 (TF::RandomPoissonV2Op)

從 rate 描述的 Poisson 分佈輸出隨機值。

此運算使用兩種演算法,具體取決於 rate。如果 rate >= 10,則使用 Hormann 的演算法,透過轉換-拒絕來取得樣本。請參閱 http://www.sciencedirect.com/science/article/pii/0167668793909974

否則,Knuth 的演算法用於透過乘以均勻隨機變數來取得樣本。請參閱 Donald E. Knuth (1969)。 Seminumerical Algorithms. The Art of Computer Programming, Volume 2. Addison Wesley

Traits: TF_CannotDuplicate

介面:TF_RandomGeneratorSideEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::RandomGenerator}

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
R::mlir::Attribute衍生屬性
S::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
rate 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.RandomShuffle (TF::RandomShuffleOp)

沿著其第一個維度隨機改組張量。

張量沿著維度 0 改組,使得每個 value[j] 都對應到一個且僅一個 output[i]。例如,3x2 張量可能發生的對應是

[[1, 2],       [[5, 6],
 [3, 4],  ==>   [1, 2],
 [5, 6]]        [3, 4]]

特性:InferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_CannotDuplicate

介面:InferShapedTypeOpInterfaceInferTypeOpInterfaceTF_RandomGeneratorSideEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::RandomGenerator}

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.RandomStandardNormal (TF::RandomStandardNormalOp)

從常態分佈輸出隨機值。

產生的值將具有平均值 0 和標準差 1。

Traits: TF_CannotDuplicate

介面:TF_RandomGeneratorSideEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::RandomGenerator}

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.RandomUniform (TF::RandomUniformOp)

從均勻分佈輸出隨機值。

產生的值遵循範圍 [0, 1) 中的均勻分佈。下限 0 包含在範圍中,而上限 1 排除在範圍之外。

Traits: TF_CannotDuplicate

介面:GetResourceInstanceInterfaceTF_RandomGeneratorSideEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::RandomGenerator}

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.RandomUniformInt (TF::RandomUniformIntOp)

從均勻分佈輸出隨機整數。

產生的值是範圍 [minval, maxval) 中的均勻整數。下限 minval 包含在範圍中,而上限 maxval 排除在範圍之外。

除非 maxval - minval 是 2 的精確冪,否則隨機整數會略有偏差。對於顯著小於輸出範圍(2^322^64)的 maxval - minval 值,偏差很小。

Traits: TF_CannotDuplicate

介面:TF_RandomGeneratorSideEffect (MemoryEffectOpInterface)

效果:MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::RandomGenerator}

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
minval 32/64 位元帶正負號的整數值的張量
maxval 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.Range (TF::RangeOp)

建立數字序列。

此運算會建立一個數字序列,該序列從 start 開始,並以 delta 的增量延伸到但不包括 limit

例如

# 'start' is 3
# 'limit' is 18
# 'delta' is 3
tf.range(start, limit, delta) ==> [3, 6, 9, 12, 15]

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
start (開始) bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數值的張量
limit bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數值的張量
delta bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數值的張量

tf.RangeDataset (TF::RangeDatasetOp)

建立具有值範圍的資料集。對應於 python 的 xrange。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性
replicate_on_split::mlir::BoolAttr布林屬性

運算元

運算元 描述
start (開始) 64 位元整數值的張量
stop (停止) 64 位元整數值的張量
step 64 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.Rank (TF::RankOp)

傳回張量的秩。

此運算傳回一個整數,表示 input 的秩。

例如

# 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]
# shape of tensor 't' is [2, 2, 3]
rank(t) ==> 3

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 32 位元整數值的張量

tf.ReadFile (TF::ReadFileOp)

讀取並輸出輸入檔案名的完整內容。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
filename 字串值的張量

結果

結果 描述
contents 字串值的張量

tf.ReadVariableOp (TF::ReadVariableOp)

讀取變數的值。

此運算傳回的張量是不可變的。

此運算傳回的值保證會受到此運算直接或間接依賴的所有寫入的影響,並且不會受到任何直接或間接依賴於此運算的寫入的影響。

屬性

屬性MLIR 類型描述
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量

結果

結果 描述
value tf.dtype 值的張量

tf.Real (TF::RealOp)

傳回複數的實部。

給定複數的張量 input,此運算傳回類型為 float 的張量,它是 input 中每個元素的實部。input 中的所有元素都必須是 \(a + bj\) 形式的複數,其中 a 是此運算傳回的實部,而 b 是虛部。

例如

# tensor 'input' is [-2.25 + 4.75j, 3.25 + 5.75j]
tf.real(input) ==> [-2.25, 3.25]

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數值的張量

結果

結果 描述
輸出 32/64 位元浮點數值的張量

tf.RealDiv (TF::RealDivOp)

針對實數類型逐元素傳回 x / y。

如果 xy 是實數,這將傳回浮點除法。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_CwiseBinary

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.Reciprocal (TF::ReciprocalOp)

逐元素計算 x 的倒數。

即,\(y = 1 / x\)。

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_Involution

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

結果

結果 描述
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

tf.ReciprocalGrad (TF::ReciprocalGradOp)

計算 x 的倒數相對於其輸入的梯度。

具體而言,grad = -dy * y*y,其中 y = 1/x,而 dy 是對應的輸入梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
y 浮點數或複數值的張量
dy 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.Recv (TF::RecvOp)

_從 recv_device 上的 send_device 接收具名張量。

介面:TF_RecvSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
send_device::mlir::StringAttr字串屬性
send_device_incarnation::mlir::IntegerAttr64 位元無號整數屬性
recv_device::mlir::StringAttr字串屬性
client_terminated::mlir::BoolAttr布林屬性
tensor_type::mlir::Attribute衍生屬性

結果

結果 描述
tensor tf.dtype 值的張量

tf.RecvTPUEmbeddingActivations (TF::RecvTPUEmbeddingActivationsOp)

在 TPU 上接收嵌入激活的運算。

TPU 系統執行 TPUEmbeddingEnqueue(Integer/Sparse/SparseTensor)Batch 的引數指定的嵌入查找和聚合。這些聚合的結果對於 Tensorflow 圖形是可見的,作為 RecvTPUEmbeddingActivations 運算的輸出。此運算傳回一個列表,其中包含模型中指定的每個表格的一個激活張量。TPU 圖形中最多可以有一個 RecvTPUEmbeddingActivations 運算。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性
num_outputs::mlir::Attribute衍生屬性

結果

結果 描述
outputs 32 位元浮點數值的張量的可變參數

tf.ReduceDataset (TF::ReduceDatasetOp)

使用縮減函數將輸入資料集縮減為單例。

特性:SameVariadicOperandSize

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
Tstate::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
Targuments::mlir::ArrayAttr具有至少 0 個元素的類型陣列屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
use_inter_op_parallelism::mlir::BoolAttr布林屬性

運算元

運算元 描述
input_dataset 變體值的張量
initial_state tf.dtype 值的張量的可變參數
other_arguments tf.dtype 值的張量的可變參數

結果

結果 描述
components (組件) tf.dtype 值的張量的可變參數

tf.ReduceJoin (TF::ReduceJoinOp)

跨給定維度聯結字串張量。

計算給定形狀為 [\\(d_0, d_1, ..., d_{n-1}\\)] 的字串張量中跨維度的字串聯結。傳回透過使用給定分隔符號(預設值:空字串)聯結輸入字串而建立的新張量。負索引從末尾倒數,其中 -1 等效於 n - 1。如果未指定索引,則聯結從 n - 10 開始的所有維度。

例如

# tensor `a` is [["a", "b"], ["c", "d"]]
tf.reduce_join(a, 0) ==> ["ac", "bd"]
tf.reduce_join(a, 1) ==> ["ab", "cd"]
tf.reduce_join(a, -2) = tf.reduce_join(a, 0) ==> ["ac", "bd"]
tf.reduce_join(a, -1) = tf.reduce_join(a, 1) ==> ["ab", "cd"]
tf.reduce_join(a, 0, keep_dims=True) ==> [["ac", "bd"]]
tf.reduce_join(a, 1, keep_dims=True) ==> [["ab"], ["cd"]]
tf.reduce_join(a, 0, separator=".") ==> ["a.c", "b.d"]
tf.reduce_join(a, [0, 1]) ==> "acbd"
tf.reduce_join(a, [1, 0]) ==> "abcd"
tf.reduce_join(a, []) ==> [["a", "b"], ["c", "d"]]
tf.reduce_join(a) = tf.reduce_join(a, [1, 0]) ==> "abcd"

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
separator::mlir::StringAttr字串屬性

運算元

運算元 描述
inputs 字串值的張量
reduction_indices 32 位元整數值的張量

結果

結果 描述
輸出 字串值的張量

tf.Relu (TF::ReluOp)

計算線性整流:max(features, 0)

請參閱:https://en.wikipedia.org/wiki/Rectifier_(neural_networks) 用法範例

tf.nn.relu([-2., 0., 3.]).numpy() array([0., 0., 3.], dtype=float32)

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_IdempotentTF_LayoutAgnostic

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元量化整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
activations bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 8 位元量化整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.Relu6 (TF::Relu6Op)

計算線性整流 6:min(max(features, 0), 6)

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features 整數或浮點數值的張量

結果

結果 描述
activations 整數或浮點數值的張量

tf.Relu6Grad (TF::Relu6GradOp)

計算 Relu6 運算的線性整流 6 梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 整數或浮點數值的張量
features 整數或浮點數值的張量

結果

結果 描述
backprops 整數或浮點數值的張量

tf.ReluGrad (TF::ReluGradOp)

計算 Relu 運算的線性整流梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 整數或浮點數值的張量
features 整數或浮點數值的張量

結果

結果 描述
backprops 整數或浮點數值的張量

tf.RemoteCall (TF::RemoteCallOp)

target 指示的遠端裝置上執行函數 f

介面: CallOpInterface

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
目標 字串值的張量
args tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.RepeatDataset (TF::RepeatDatasetOp)

建立一個資料集,該資料集會發出 input_dataset 的輸出 count 次。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
次數 64 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.Reshape (TF::ReshapeOp)

重塑張量。

給定 tensor,此運算會傳回一個張量,其值與 tensor 相同,但形狀為 shape

如果 1 維張量 shape 的其中一個分量是特殊值 -1,則會計算該維度的大小,以使總大小保持不變。特別是,[-1]shape 會展平成 1 維。 shape 中最多只能有一個分量是未知的。

shape 必須是 1 維,且運算會傳回一個形狀為 shape 的張量,並以 tensor 的值填滿。在這種情況下,shape 所暗示的元素數量必須與 tensor 中的元素數量相同。

如果 shape 不是 1 維,則會發生錯誤。

例如

# tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9]
# tensor 't' has shape [9]
reshape(t, [3, 3]) ==> [[1, 2, 3],
                        [4, 5, 6],
                        [7, 8, 9]]

# tensor 't' is [[[1, 1], [2, 2]],
#                [[3, 3], [4, 4]]]
# tensor 't' has shape [2, 2, 2]
reshape(t, [2, 4]) ==> [[1, 1, 2, 2],
                        [3, 3, 4, 4]]

# tensor 't' is [[[1, 1, 1],
#                 [2, 2, 2]],
#                [[3, 3, 3],
#                 [4, 4, 4]],
#                [[5, 5, 5],
#                 [6, 6, 6]]]
# tensor 't' has shape [3, 2, 3]
# pass '[-1]' to flatten 't'
reshape(t, [-1]) ==> [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]

# -1 can also be used to infer the shape

# -1 is inferred to be 9:
reshape(t, [2, -1]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3],
                         [4, 4, 4, 5, 5, 5, 6, 6, 6]]
# -1 is inferred to be 2:
reshape(t, [-1, 9]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3],
                         [4, 4, 4, 5, 5, 5, 6, 6, 6]]
# -1 is inferred to be 3:
reshape(t, [ 2, -1, 3]) ==> [[[1, 1, 1],
                              [2, 2, 2],
                              [3, 3, 3]],
                             [[4, 4, 4],
                              [5, 5, 5],
                              [6, 6, 6]]]

# tensor 't' is [7]
# shape `[]` reshapes to a scalar
reshape(t, []) ==> 7

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tshape::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.ResizeBilinear (TF::ResizeBilinearOp)

使用雙線性插值將 images 調整大小為 size

輸入影像可以是不同的類型,但輸出影像永遠是浮點數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
align_corners::mlir::BoolAttr布林屬性
half_pixel_centers::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 8 位元無號整數值的張量
size 32 位元整數值的張量

結果

結果 描述
resized_images 32 位元浮點數值的張量

tf.ResizeBilinearGrad (TF::ResizeBilinearGradOp)

計算雙線性插值的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
align_corners::mlir::BoolAttr布林屬性
half_pixel_centers::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
grads 32 位元浮點數值的張量
original_image 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.ResizeNearestNeighbor (TF::ResizeNearestNeighborOp)

使用最近鄰插值將 images 調整大小為 size

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
align_corners::mlir::BoolAttr布林屬性
half_pixel_centers::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 8 位元無號整數值的張量
size 32 位元整數值的張量

結果

結果 描述
resized_images bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 8 位元無號整數值的張量

tf.ResizeNearestNeighborGrad (TF::ResizeNearestNeighborGradOp)

計算最近鄰插值的梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
align_corners::mlir::BoolAttr布林屬性
half_pixel_centers::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
grads bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 8 位元整數或 8 位元無符號整數值的張量
size 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 8 位元整數或 8 位元無符號整數值的張量

tf.ResourceApplyAdadelta (TF::ResourceApplyAdadeltaOp)

根據 Adadelta 方案更新 '*var'。

accum = rho() * accum + (1 - rho()) * grad.square(); update = (update_accum + epsilon).sqrt() * (accum + epsilon()).rsqrt() * grad; update_accum = rho() * update_accum + (1 - rho()) * update.square(); var -= update;

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
accum_update 資源值的張量
lr 數字值的張量
rho 數字值的張量
epsilon 數字值的張量
grad 數字值的張量

tf.ResourceApplyAdagrad (TF::ResourceApplyAdagradOp)

根據 Adagrad 方案更新 '*var'。

accum += grad * grad var -= lr * grad * (1 / sqrt(accum))

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
update_slots::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
lr 數字值的張量
grad 數字值的張量

tf.ResourceApplyAdagradDA (TF::ResourceApplyAdagradDAOp)

根據近端 Adagrad 方案更新 '*var'。

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
gradient_accumulator 資源值的張量
gradient_squared_accumulator 資源值的張量
grad 數字值的張量
lr 數字值的張量
l1 數字值的張量
l2 數字值的張量
global_step 64 位元整數值的張量

tf.ResourceApplyAdagradV2 (TF::ResourceApplyAdagradV2Op)

根據 Adagrad 方案更新 '*var'。

accum += grad * grad var -= lr * grad * (1 / (sqrt(accum) + epsilon))

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
update_slots::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
lr 數字值的張量
epsilon 數字值的張量
grad 數字值的張量

tf.ResourceApplyAdam (TF::ResourceApplyAdamOp)

根據 Adam 演算法更新 '*var'。

\[\text{lr}_t := \mathrm{lr} \cdot \frac{\sqrt{1 - \beta_2^t} }{1 - \beta_1^t}\]

\[m_t := \beta_1 \cdot m_{t-1} + (1 - \beta_1) \cdot g\]

\[v_t := \beta_2 \cdot v_{t-1} + (1 - \beta_2) \cdot g^2\]

\[\text{var} := \begin{cases} \text{var} - (m_t \beta_1 + g \cdot (1 - \beta_1))\cdot\text{lr}_t/(\sqrt{v_t} + \epsilon), &\text{if use_nesterov}\\\\ \text{var} - m_t \cdot \text{lr}_t /(\sqrt{v_t} + \epsilon), &\text{otherwise} \end{cases}\]

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
use_nesterov::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
m 資源值的張量
v 資源值的張量
beta1_power 數字值的張量
beta2_power 數字值的張量
lr 數字值的張量
beta1 數字值的張量
beta2 數字值的張量
epsilon 數字值的張量
grad 數字值的張量

tf.ResourceApplyAdaMax (TF::ResourceApplyAdaMaxOp)

根據 AdaMax 演算法更新 '*var'。

mt <- beta1 * m{t-1} + (1 - beta1) * g vt <- max(beta2 * v{t-1}, abs(g)) variable <- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon)

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
m 資源值的張量
v 資源值的張量
beta1_power 數字值的張量
lr 數字值的張量
beta1 數字值的張量
beta2 數字值的張量
epsilon 數字值的張量
grad 數字值的張量

tf.ResourceApplyAddSign (TF::ResourceApplyAddSignOp)

根據 AddSign 更新 '*var'。

mt <- beta1 * m{t-1} + (1 - beta1) * g update <- (alpha + sign_decay * sign(g) *sign(m)) * g variable <- variable - lr_t * update

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
m 資源值的張量
lr 數字值的張量
alpha (Alpha) 數字值的張量
sign_decay 數字值的張量
beta 數字值的張量
grad 數字值的張量

tf.ResourceApplyCenteredRMSProp (TF::ResourceApplyCenteredRMSPropOp)

根據中心 RMSProp 演算法更新 '*var'。

中心 RMSProp 演算法使用中心二階動差(即變異數)的估計值進行正規化,而不是使用(非中心)二階動差的正規 RMSProp。這通常有助於訓練,但在計算和記憶體方面稍微昂貴一些。

請注意,在此演算法的密集實作中,即使梯度為零,mg、ms 和 mom 也會更新,但在這個稀疏實作中,mg、ms 和 mom 在梯度為零的迭代期間不會更新。

mean_square = decay * mean_square + (1-decay) * gradient ** 2 mean_grad = decay * mean_grad + (1-decay) * gradient

Delta = learning_rate * gradient / sqrt(mean_square + epsilon - mean_grad ** 2)

mg <- rho * mg{t-1} + (1-rho) * grad ms <- rho * ms{t-1} + (1-rho) * grad * grad mom <- momentum * mom_{t-1} + lr * grad / sqrt(ms - mg * mg + epsilon) var <- var - mom

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
mg (動量梯度) 資源值的張量
ms (均方) 資源值的張量
mom (動量) 資源值的張量
lr 數字值的張量
rho 數字值的張量
momentum 數字值的張量
epsilon 數字值的張量
grad 數字值的張量

tf.ResourceApplyFtrl (TF::ResourceApplyFtrlOp)

根據 Ftrl 近端方案更新 '*var'。

accum_new = accum + grad * grad linear += grad - (accum_new^(-lr_power) - accum^(-lr_power)) / lr * var quadratic = 1.0 / (accum_new^(lr_power) * lr) + 2 * l2 var = (sign(linear) * l1 - linear) / quadratic if |linear| > l1 else 0.0 accum = accum_new

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
multiply_linear_by_lr::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
linear 資源值的張量
grad 數字值的張量
lr 數字值的張量
l1 數字值的張量
l2 數字值的張量
lr_power 數字值的張量

tf.ResourceApplyFtrlV2 (TF::ResourceApplyFtrlV2Op)

根據 Ftrl 近端方案更新 '*var'。

accum_new = accum + grad * grad grad_with_shrinkage = grad + 2 * l2_shrinkage * var linear += grad_with_shrinkage + (accum_new^(-lr_power) - accum^(-lr_power)) / lr * var quadratic = 1.0 / (accum_new^(lr_power) * lr) + 2 * l2 var = (sign(linear) * l1 - linear) / quadratic if |linear| > l1 else 0.0 accum = accum_new

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
multiply_linear_by_lr::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
linear 資源值的張量
grad 數字值的張量
lr 數字值的張量
l1 數字值的張量
l2 數字值的張量
l2_shrinkage 數字值的張量
lr_power 數字值的張量

tf.ResourceApplyGradientDescent (TF::ResourceApplyGradientDescentOp)

從 '*var' 中減去 'alpha' * 'delta' 以更新 '*var'。

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
alpha (Alpha) 數字值的張量
delta 數字值的張量

tf.ResourceApplyKerasMomentum (TF::ResourceApplyKerasMomentumOp)

根據動量方案更新 '*var'。

如果您想使用 Nesterov 動量,請設定 use_nesterov = True。

accum = accum * momentum - lr * grad var += accum

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
use_nesterov::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
lr 數字值的張量
grad 數字值的張量
momentum 數字值的張量

tf.ResourceApplyMomentum (TF::ResourceApplyMomentumOp)

根據動量方案更新 '*var'。

如果您想使用 Nesterov 動量,請設定 use_nesterov = True。

accum = accum * momentum + grad var -= lr * accum

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
use_nesterov::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
lr 數字值的張量
grad 數字值的張量
momentum 數字值的張量

tf.ResourceApplyPowerSign (TF::ResourceApplyPowerSignOp)

根據 AddSign 更新 '*var'。

mt <- beta1 * m{t-1} + (1 - beta1) * g update <- exp(logbase * sign_decay * sign(g) * sign(m_t)) * g variable <- variable - lr_t * update

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
m 資源值的張量
lr 數字值的張量
logbase 數字值的張量
sign_decay 數字值的張量
beta 數字值的張量
grad 數字值的張量

tf.ResourceApplyProximalAdagrad (TF::ResourceApplyProximalAdagradOp)

根據 FOBOS 和 Adagrad 學習率更新 '*var' 和 '*accum'。

accum += grad * grad prox_v = var - lr * grad * (1 / sqrt(accum)) var = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0}

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
lr 數字值的張量
l1 數字值的張量
l2 數字值的張量
grad 數字值的張量

tf.ResourceApplyProximalGradientDescent (TF::ResourceApplyProximalGradientDescentOp)

使用固定學習率將 '*var' 更新為 FOBOS 演算法。

prox_v = var - alpha * delta var = sign(prox_v)/(1+alpha*l2) * max{|prox_v|-alpha*l1,0}

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
alpha (Alpha) 數字值的張量
l1 數字值的張量
l2 數字值的張量
delta 數字值的張量

tf.ResourceApplyRMSProp (TF::ResourceApplyRMSPropOp)

根據 RMSProp 演算法更新 '*var'。

請注意,在此演算法的密集實作中,即使梯度為零,ms 和 mom 也會更新,但在這個稀疏實作中,ms 和 mom 在梯度為零的迭代期間不會更新。

mean_square = decay * mean_square + (1-decay) * gradient ** 2 Delta = learning_rate * gradient / sqrt(mean_square + epsilon)

ms <- rho * ms{t-1} + (1-rho) * grad * grad mom <- momentum * mom{t-1} + lr * grad / sqrt(ms + epsilon) var <- var - mom

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
ms (均方) 資源值的張量
mom (動量) 資源值的張量
lr 數字值的張量
rho 數字值的張量
momentum 數字值的張量
epsilon 數字值的張量
grad 數字值的張量

tf.ResourceGather (TF::ResourceGatherOp)

根據 indicesresource 指向的變數收集切片。

indices 必須是任何維度(通常為 0D 或 1D)的整數張量。產生形狀為 indices.shape + params.shape[1:] 的輸出張量,其中

    # Scalar indices
    output[:, ..., :] = params[indices, :, ... :]

    # Vector indices
    output[i, :, ..., :] = params[indices[i], :, ... :]

    # Higher rank indices
    output[i, ..., j, :, ... :] = params[indices[i, ..., j], :, ..., :]

屬性

屬性MLIR 類型描述
batch_dims::mlir::IntegerAttr64 位元無號整數屬性
validate_indices::mlir::BoolAttr布林屬性
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.ResourceGatherNd (TF::ResourceGatherNdOp)

在資源上執行 GatherNd。

此運算會讀取第一個引數參照的變數,然後對其執行 GatherNd 運算。

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.ResourceScatterAdd (TF::ResourceScatterAddOp)

將稀疏更新新增至 resource 參照的變數。

此運算會計算

# Scalar indices
ref[indices, ...] += updates[...]

# Vector indices (for each i)
ref[indices[i], ...] += updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] += updates[i, ..., j, ...]

重複的項目會正確處理:如果多個 indices 參照相同的位置,則會將其貢獻相加。

需要 updates.shape = indices.shape + ref.shape[1:]updates.shape = []

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) 數字值的張量

tf.ResourceScatterDiv (TF::ResourceScatterDivOp)

將稀疏更新除以 resource 參照的變數。

此運算會計算

# Scalar indices
ref[indices, ...] /= updates[...]

# Vector indices (for each i)
ref[indices[i], ...] /= updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] /= updates[i, ..., j, ...]

重複的項目會正確處理:如果多個 indices 參照相同的位置,則會將其貢獻相乘。

需要 updates.shape = indices.shape + ref.shape[1:]updates.shape = []

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) 數字值的張量

tf.ResourceScatterMax (TF::ResourceScatterMaxOp)

使用 max 運算將稀疏更新縮減至 resource 參照的變數。

此運算會計算

# Scalar indices
ref[indices, ...] = max(ref[indices, ...], updates[...])

# Vector indices (for each i)
ref[indices[i], ...] = max(ref[indices[i], ...], updates[i, ...])

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] = max(ref[indices[i, ..., j], ...], updates[i, ..., j, ...])

重複的項目會正確處理:如果多個 indices 參照相同的位置,則會合併其貢獻。

需要 updates.shape = indices.shape + ref.shape[1:]updates.shape = []

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) 數字值的張量

tf.ResourceScatterMin (TF::ResourceScatterMinOp)

使用 min 運算將稀疏更新縮減至 resource 參照的變數。

此運算會計算

# Scalar indices
ref[indices, ...] = min(ref[indices, ...], updates[...])

# Vector indices (for each i)
ref[indices[i], ...] = min(ref[indices[i], ...], updates[i, ...])

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] = min(ref[indices[i, ..., j], ...], updates[i, ..., j, ...])

重複的項目會正確處理:如果多個 indices 參照相同的位置,則會合併其貢獻。

需要 updates.shape = indices.shape + ref.shape[1:]updates.shape = []

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) 數字值的張量

tf.ResourceScatterMul (TF::ResourceScatterMulOp)

將稀疏更新乘入 resource 參照的變數。

此運算會計算

# Scalar indices
ref[indices, ...] *= updates[...]

# Vector indices (for each i)
ref[indices[i], ...] *= updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] *= updates[i, ..., j, ...]

重複的項目會正確處理:如果多個 indices 參照相同的位置,則會將其貢獻相乘。

需要 updates.shape = indices.shape + ref.shape[1:]updates.shape = []

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) 數字值的張量

tf.ResourceScatterNdAdd (TF::ResourceScatterNdAddOp)

將稀疏加法套用至變數中的個別值或切片。

ref 是等級為 PTensor,而 indices 是等級為 QTensor

indices 必須是整數張量,其中包含 ref 的索引。其形狀必須為 [d_0, ..., d_{Q-2}, K],其中 0 < K <= P

indices 的最內層維度(長度為 K)對應於沿著 ref 的第 K 個維度的元素(如果 K = P)或切片(如果 K < P)的索引。

updates 是等級為 Q-1+P-K 且形狀為 [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]Tensor

[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]

例如,假設我們想要將 4 個分散的元素新增至等級為 1 的張量,使其具有 8 個元素。在 Python 中,該加法看起來會像這樣

ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8], use_resource=True)
indices = tf.constant([[4], [3], [1], [7]])
updates = tf.constant([9, 10, 11, 12])
add = tf.scatter_nd_add(ref, indices, updates)
with tf.Session() as sess:
  print sess.run(add)

對 ref 產生的更新看起來會像這樣

[1, 13, 3, 14, 14, 6, 7, 20]

如需有關如何更新切片的詳細資訊,請參閱 tf.scatter_nd

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
ref 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

tf.ResourceScatterNdSub (TF::ResourceScatterNdSubOp)

將稀疏減法套用至變數中的個別值或切片。

ref 是等級為 PTensor,而 indices 是等級為 QTensor

indices 必須是整數張量,其中包含 ref 的索引。其形狀必須為 [d_0, ..., d_{Q-2}, K],其中 0 < K <= P

indices 的最內層維度(長度為 K)對應於沿著 ref 的第 K 個維度的元素(如果 K = P)或切片(如果 K < P)的索引。

updates 是等級為 Q-1+P-K 且形狀為 [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]Tensor

[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]

例如,假設我們想要從具有 8 個元素的等級為 1 的張量中減去 4 個分散的元素。在 Python 中,該減法看起來會像這樣

ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8], use_resource=True)
indices = tf.constant([[4], [3], [1], [7]])
updates = tf.constant([9, 10, 11, 12])
sub = tf.scatter_nd_sub(ref, indices, updates)
with tf.Session() as sess:
  print sess.run(sub)

對 ref 產生的更新看起來會像這樣

[1, -9, 3, -6, -4, 6, 7, -4]

如需有關如何更新切片的詳細資訊,請參閱 tf.scatter_nd

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
ref 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

tf.ResourceScatterNdUpdate (TF::ResourceScatterNdUpdateOp)

根據 indices 將稀疏 updates 套用至給定

變數內的個別值或切片。

ref 是等級為 PTensor,而 indices 是等級為 QTensor

indices 必須是整數張量,其中包含 ref 的索引。其形狀必須為 [d_0, ..., d_{Q-2}, K],其中 0 < K <= P

indices 的最內層維度(長度為 K)對應於沿著 ref 的第 K 個維度的元素(如果 K = P)或切片(如果 K < P)的索引。

updates 是等級為 Q-1+P-K 且形狀為 [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]Tensor

[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]].

例如,假設我們想要將 4 個分散的元素更新為等級為 1 的張量,使其具有 8 個元素。在 Python 中,該更新看起來會像這樣

    ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])
    indices = tf.constant([[4], [3], [1] ,[7]])
    updates = tf.constant([9, 10, 11, 12])
    update = tf.scatter_nd_update(ref, indices, updates)
    with tf.Session() as sess:
      print sess.run(update)

對 ref 產生的更新看起來會像這樣

[1, 11, 3, 10, 9, 6, 7, 12]

如需有關如何更新切片的詳細資訊,請參閱 tf.scatter_nd

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
ref 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

tf.ResourceScatterSub (TF::ResourceScatterSubOp)

resource 參照的變數中減去稀疏更新。

此運算會計算

# Scalar indices
ref[indices, ...] -= updates[...]

# Vector indices (for each i)
ref[indices[i], ...] -= updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] -= updates[i, ..., j, ...]

重複的項目會正確處理:如果多個 indices 參照相同的位置,則會將其貢獻相加。

需要 updates.shape = indices.shape + ref.shape[1:]updates.shape = []

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) 數字值的張量

tf.ResourceScatterUpdate (TF::ResourceScatterUpdateOp)

將稀疏更新指派給 resource 參照的變數。

此運算會計算

# Scalar indices
ref[indices, ...] = updates[...]

# Vector indices (for each i)
ref[indices[i], ...] = updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] = updates[i, ..., j, ...]

屬性

屬性MLIR 類型描述
Tindices::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

tf.ResourceSparseApplyAdagrad (TF::ResourceSparseApplyAdagradOp)

根據 Adagrad 方案更新 '*var' 和 '*accum' 中的相關項目。

也就是說,對於我們有 grad 的列,我們會依如下方式更新 var 和 accum: accum += grad * grad var -= lr * grad * (1 / sqrt(accum))

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
update_slots::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
lr 數字值的張量
grad 數字值的張量
indices 32/64 位元帶正負號的整數值的張量

tf.ResourceSparseApplyAdagradV2 (TF::ResourceSparseApplyAdagradV2Op)

根據 Adagrad 方案更新 '*var' 和 '*accum' 中的相關項目。

也就是說,對於我們有 grad 的列,我們會依如下方式更新 var 和 accum: accum += grad * grad var -= lr * grad * (1 / sqrt(accum))

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
update_slots::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
lr 數字值的張量
epsilon 數字值的張量
grad 數字值的張量
indices 32/64 位元帶正負號的整數值的張量

tf.ResourceSparseApplyFtrl (TF::ResourceSparseApplyFtrlOp)

根據 Ftrl 近端方案更新 '*var' 中的相關項目。

也就是說,對於我們有 grad 的列,我們會依如下方式更新 var、accum 和 linear: accum_new = accum + grad * grad linear += grad - (accum_new^(-lr_power) - accum^(-lr_power)) / lr * var quadratic = 1.0 / (accum_new^(lr_power) * lr) + 2 * l2 var = (sign(linear) * l1 - linear) / quadratic if |linear| > l1 else 0.0 accum = accum_new

屬性

屬性MLIR 類型描述
use_locking::mlir::BoolAttr布林屬性
multiply_linear_by_lr::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
var 資源值的張量
accum 資源值的張量
linear 資源值的張量
grad 數字值的張量
indices 32/64 位元帶正負號的整數值的張量
lr 數字值的張量
l1 數字值的張量
l2 數字值的張量
lr_power 數字值的張量

tf.ResourceStridedSliceAssign (TF::ResourceStridedSliceAssignOp)

value 指派給 ref 的切片左值參考。

value 的值會指派給變數 ref 中由切片參數選取的位置。切片參數 begin,end,strides 等的運作方式與StridedSlice` 完全相同。

請注意,此運算目前不支援廣播,因此 value 的形狀必須與 ref 切片產生的形狀完全相同。

屬性

屬性MLIR 類型描述
begin_mask::mlir::IntegerAttr64 位元無號整數屬性
end_mask::mlir::IntegerAttr64 位元無號整數屬性
ellipsis_mask::mlir::IntegerAttr64 位元無號整數屬性
new_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
shrink_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
索引::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
ref 資源值的張量
begin 32/64 位元帶正負號的整數值的張量
end 32/64 位元帶正負號的整數值的張量
strides 32/64 位元帶正負號的整數值的張量
value tf.dtype 值的張量

tf.Restore (TF::RestoreOp)

從檢查點檔案還原張量。

讀取儲存在一個或多個檔案中的張量。如果有多個檔案(例如,因為張量儲存為切片),則 file_pattern 可能只在檔名部分(而非目錄部分)包含萬用字元 (*?)。

如果 file_pattern 符合多個檔案,則可以使用 preferred_shard 來提示要求的張量可能在哪個檔案中找到。此運算會先開啟符合檔案清單中索引 preferred_shard 的檔案,並嘗試從該檔案還原張量。只有在第一個檔案中找不到某些張量或張量切片時,Op 才會開啟所有檔案。設定 preferred_shard 以符合傳遞為相符 Save Op 的 shard 輸入的值,可能會加快還原速度。此屬性只會影響效能,而不會影響正確性。預設值 -1 表示依序處理檔案。

另請參閱 RestoreSlice

屬性

屬性MLIR 類型描述
preferred_shard::mlir::IntegerAttr64 位元無號整數屬性
dt::mlir::Attribute衍生屬性

運算元

運算元 描述
file_pattern 字串值的張量
tensor_name 字串值的張量

結果

結果 描述
tensor tf.dtype 值的張量

tf.RestoreV2 (TF::RestoreV2Op)

從 V2 檢查點還原張量。

為了與 V1 格式向後相容,此 Op 目前也允許從 V1 檢查點還原

  • 此 Op 會先嘗試尋找 "prefix" 指向的 V2 索引檔案,如果找到,則繼續將其讀取為 V2 檢查點;
  • 否則會叫用 V1 讀取路徑。不建議依賴此行為,因為回復讀取 V1 的功能可能會被取代並最終移除。

預設情況下,會完整還原具名張量。如果呼叫者希望還原儲存張量的特定切片,則 "shape_and_slices" 應為非空字串,且格式正確。

呼叫者必須確保所有具名張量都確實儲存在檢查點中。

屬性

屬性MLIR 類型描述
dtypes (資料類型)::mlir::Attribute衍生屬性

運算元

運算元 描述
prefix 字串值的張量
tensor_names 字串值的張量
shape_and_slices 字串值的張量

結果

結果 描述
tensors tf.dtype 值的張量的可變參數

tf.RetrieveTPUEmbeddingAdadeltaParameters (TF::RetrieveTPUEmbeddingAdadeltaParametersOp)

擷取 Adadelta 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
updates (更新) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingAdadeltaParametersGradAccumDebug (TF::RetrieveTPUEmbeddingAdadeltaParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
updates (更新) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingAdagradParameters (TF::RetrieveTPUEmbeddingAdagradParametersOp)

擷取 Adagrad 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingAdagradParametersGradAccumDebug (TF::RetrieveTPUEmbeddingAdagradParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingADAMParameters (TF::RetrieveTPUEmbeddingADAMParametersOp)

擷取 ADAM 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
velocities (速度) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingADAMParametersGradAccumDebug (TF::RetrieveTPUEmbeddingADAMParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
velocities (速度) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingCenteredRMSPropParameters (TF::RetrieveTPUEmbeddingCenteredRMSPropParametersOp)

擷取中心 RMSProp 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
ms (均方) 32 位元浮點數值的張量
mom (動量) 32 位元浮點數值的張量
mg (動量梯度) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingFTRLParameters (TF::RetrieveTPUEmbeddingFTRLParametersOp)

擷取 FTRL 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
linears (線性項) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingFTRLParametersGradAccumDebug (TF::RetrieveTPUEmbeddingFTRLParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
linears (線性項) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingMDLAdagradLightParameters (TF::RetrieveTPUEmbeddingMDLAdagradLightParametersOp)

擷取 MDL Adagrad Light 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
weights 32 位元浮點數值的張量
benefits (效益) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingMomentumParameters (TF::RetrieveTPUEmbeddingMomentumParametersOp)

擷取動量嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingMomentumParametersGradAccumDebug (TF::RetrieveTPUEmbeddingMomentumParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingProximalAdagradParameters (TF::RetrieveTPUEmbeddingProximalAdagradParametersOp)

擷取近端 Adagrad 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingProximalAdagradParametersGradAccumDebug (TF::RetrieveTPUEmbeddingProximalAdagradParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
accumulators (累加器) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingProximalYogiParameters (TF::RetrieveTPUEmbeddingProximalYogiParametersOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
v 32 位元浮點數值的張量
m 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingProximalYogiParametersGradAccumDebug (TF::RetrieveTPUEmbeddingProximalYogiParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
v 32 位元浮點數值的張量
m 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingRMSPropParameters (TF::RetrieveTPUEmbeddingRMSPropParametersOp)

擷取 RMSProp 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
ms (均方) 32 位元浮點數值的張量
mom (動量) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingRMSPropParametersGradAccumDebug (TF::RetrieveTPUEmbeddingRMSPropParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
ms (均方) 32 位元浮點數值的張量
mom (動量) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingStochasticGradientDescentParameters (TF::RetrieveTPUEmbeddingStochasticGradientDescentParametersOp)

擷取 SGD 嵌入參數。

一個從嵌入擷取最佳化參數到主機記憶體的運算。必須先執行 ConfigureTPUEmbeddingHost 運算,以設定正確的嵌入表格組態。例如,此運算用於在儲存檢查點之前擷取更新的參數。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量

tf.RetrieveTPUEmbeddingStochasticGradientDescentParametersGradAccumDebug (TF::RetrieveTPUEmbeddingStochasticGradientDescentParametersGradAccumDebugOp)

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性
num_shards (分片數量)::mlir::IntegerAttr64 位元無號整數屬性
shard_id (分片 ID)::mlir::IntegerAttr64 位元無號整數屬性
config::mlir::StringAttr字串屬性

結果

結果 描述
parameters (參數) 32 位元浮點數值的張量
gradient_accumulators (梯度累加器) 32 位元浮點數值的張量

tf.Reverse (TF::ReverseOp)

反轉張量的特定維度。

給定一個 tensor 和一個 bool 張量 dims,表示 tensor 的維度,此運算會反轉 tensor 的每個維度 i,其中 dims[i]True

tensor 最多可以有 8 個維度。tensor 的維度數必須等於 dims 中的元素數。換句話說

rank(tensor) = size(dims)

例如

# tensor 't' is [[[[ 0,  1,  2,  3],
#                  [ 4,  5,  6,  7],
#                  [ 8,  9, 10, 11]],
#                 [[12, 13, 14, 15],
#                  [16, 17, 18, 19],
#                  [20, 21, 22, 23]]]]
# tensor 't' shape is [1, 2, 3, 4]

# 'dims' is [False, False, False, True]
reverse(t, dims) ==> [[[[ 3,  2,  1,  0],
                        [ 7,  6,  5,  4],
                        [ 11, 10, 9, 8]],
                       [[15, 14, 13, 12],
                        [19, 18, 17, 16],
                        [23, 22, 21, 20]]]]

# 'dims' is [False, True, False, False]
reverse(t, dims) ==> [[[[12, 13, 14, 15],
                        [16, 17, 18, 19],
                        [20, 21, 22, 23]
                       [[ 0,  1,  2,  3],
                        [ 4,  5,  6,  7],
                        [ 8,  9, 10, 11]]]]

# 'dims' is [False, False, True, False]
reverse(t, dims) ==> [[[[8, 9, 10, 11],
                        [4, 5, 6, 7],
                        [0, 1, 2, 3]]
                       [[20, 21, 22, 23],
                        [16, 17, 18, 19],
                        [12, 13, 14, 15]]]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或字串或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
dims 布林值的張量

結果

結果 描述
輸出 bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或字串或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

tf.ReverseSequence (TF::ReverseSequenceOp)

反轉可變長度切片。

此運算會先沿著維度 batch_dim 切割 input,然後針對每個切片 i,沿著維度 seq_dim 反轉前 seq_lengths[i] 個元素。

seq_lengths 的元素必須遵守 seq_lengths[i] <= input.dims[seq_dim],且 seq_lengths 必須是長度為 input.dims[batch_dim] 的向量。

沿著維度 batch_dim 的輸出切片 i 由輸入切片 i 給定,其中沿著維度 seq_dim 的前 seq_lengths[i] 個切片已反轉。

例如

# Given this:
batch_dim = 0
seq_dim = 1
input.dims = (4, 8, ...)
seq_lengths = [7, 2, 3, 5]

# then slices of input are reversed on seq_dim, but only up to seq_lengths:
output[0, 0:7, :, ...] = input[0, 7:0:-1, :, ...]
output[1, 0:2, :, ...] = input[1, 2:0:-1, :, ...]
output[2, 0:3, :, ...] = input[2, 3:0:-1, :, ...]
output[3, 0:5, :, ...] = input[3, 5:0:-1, :, ...]

# while entries past seq_lens are copied through:
output[0, 7:, :, ...] = input[0, 7:, :, ...]
output[1, 2:, :, ...] = input[1, 2:, :, ...]
output[2, 3:, :, ...] = input[2, 3:, :, ...]
output[3, 2:, :, ...] = input[3, 2:, :, ...]

相反地,如果

# Given this:
batch_dim = 2
seq_dim = 0
input.dims = (8, ?, 4, ...)
seq_lengths = [7, 2, 3, 5]

# then slices of input are reversed on seq_dim, but only up to seq_lengths:
output[0:7, :, 0, :, ...] = input[7:0:-1, :, 0, :, ...]
output[0:2, :, 1, :, ...] = input[2:0:-1, :, 1, :, ...]
output[0:3, :, 2, :, ...] = input[3:0:-1, :, 2, :, ...]
output[0:5, :, 3, :, ...] = input[5:0:-1, :, 3, :, ...]

# while entries past seq_lens are copied through:
output[7:, :, 0, :, ...] = input[7:, :, 0, :, ...]
output[2:, :, 1, :, ...] = input[2:, :, 1, :, ...]
output[3:, :, 2, :, ...] = input[3:, :, 2, :, ...]
output[2:, :, 3, :, ...] = input[2:, :, 3, :, ...]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
seq_dim::mlir::IntegerAttr64 位元無號整數屬性
batch_dim::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
Tlen::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
seq_lengths 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.ReverseV2 (TF::ReverseV2Op)

反轉張量的特定維度。

給定一個 tensor 和一個 int32 張量 axis,表示要反轉的 tensor 維度集。此運算會反轉每個維度 i,對於該維度,存在 j s.t. axis[j] == i

tensor 最多可以有 8 個維度。在 axis 中指定的維度數可以是 0 個或更多個項目。如果索引被多次指定,則會引發 InvalidArgument 錯誤。

例如

# tensor 't' is [[[[ 0,  1,  2,  3],
#                  [ 4,  5,  6,  7],
#                  [ 8,  9, 10, 11]],
#                 [[12, 13, 14, 15],
#                  [16, 17, 18, 19],
#                  [20, 21, 22, 23]]]]
# tensor 't' shape is [1, 2, 3, 4]

# 'dims' is [3] or 'dims' is [-1]
reverse(t, dims) ==> [[[[ 3,  2,  1,  0],
                        [ 7,  6,  5,  4],
                        [ 11, 10, 9, 8]],
                       [[15, 14, 13, 12],
                        [19, 18, 17, 16],
                        [23, 22, 21, 20]]]]

# 'dims' is '[1]' (or 'dims' is '[-3]')
reverse(t, dims) ==> [[[[12, 13, 14, 15],
                        [16, 17, 18, 19],
                        [20, 21, 22, 23]
                       [[ 0,  1,  2,  3],
                        [ 4,  5,  6,  7],
                        [ 8,  9, 10, 11]]]]

# 'dims' is '[2]' (or 'dims' is '[-2]')
reverse(t, dims) ==> [[[[8, 9, 10, 11],
                        [4, 5, 6, 7],
                        [0, 1, 2, 3]]
                       [[20, 21, 22, 23],
                        [16, 17, 18, 19],
                        [12, 13, 14, 15]]]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或字串或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或字串或 16 位元無符號整數或 32 位元無符號整數或 64 位元無符號整數或 8 位元無符號整數值的張量

tf.RFFT (TF::RFFTOp)

實值快速傅立葉轉換。

計算 input 最內層維度上實值訊號的 1 維離散傅立葉轉換。

由於實值訊號的 DFT 是 Hermitian 對稱的,因此 RFFT 只會傳回 FFT 的 fft_length / 2 + 1 個唯一分量:零頻率項,後接 fft_length / 2 個正頻率項。

沿著計算 RFFT 的軸,如果 fft_length 小於 input 的對應維度,則會裁剪維度。如果較大,則維度會以零填充。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Treal (T實數)::mlir::Attribute衍生屬性
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32/64 位元浮點數值的張量
fft_length (FFT 長度) 32 位元整數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.RFFT2D (TF::RFFT2DOp)

2D 實值快速傅立葉轉換。

計算 input 最內層 2 個維度上實值訊號的 2 維離散傅立葉轉換。

由於實值訊號的 DFT 是 Hermitian 對稱的,因此 RFFT2D 只會傳回 FFT 的 fft_length / 2 + 1 個唯一分量,用於 output 的最內層維度:零頻率項,後接 fft_length / 2 個正頻率項。

沿著計算 RFFT2D 的每個軸,如果 fft_length 小於 input 的對應維度,則會裁剪維度。如果較大,則維度會以零填充。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Treal (T實數)::mlir::Attribute衍生屬性
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32/64 位元浮點數值的張量
fft_length (FFT 長度) 32 位元整數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.RFFT3D (TF::RFFT3DOp)

3D 實值快速傅立葉轉換。

計算 input 最內層 3 個維度上實值訊號的 3 維離散傅立葉轉換。

由於實值訊號的 DFT 是 Hermitian 對稱的,因此 RFFT3D 只會傳回 FFT 的 fft_length / 2 + 1 個唯一分量,用於 output 的最內層維度:零頻率項,後接 fft_length / 2 個正頻率項。

沿著計算 RFFT3D 的每個軸,如果 fft_length 小於 input 的對應維度,則會裁剪維度。如果較大,則維度會以零填充。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Treal (T實數)::mlir::Attribute衍生屬性
Tcomplex::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32/64 位元浮點數值的張量
fft_length (FFT 長度) 32 位元整數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數值的張量

tf.RGBToHSV (TF::RGBToHSVOp)

將一或多個影像從 RGB 轉換為 HSV。

輸出與 images 張量形狀相同的張量,其中包含像素的 HSV 值。只有當 images 中的值在 [0,1] 中時,輸出才會有明確定義。

output[..., 0] 包含色相,output[..., 1] 包含飽和度,而 output[..., 2] 包含明度。所有 HSV 值都在 [0,1] 中。色相 0 對應於純紅色,色相 1/3 是純綠色,而 2/3 是純藍色。

使用範例

blue_image = tf.stack([ ... tf.zeros([5,5]), ... tf.zeros([5,5]), ... tf.ones([5,5])], ... axis=-1) blue_hsv_image = tf.image.rgb_to_hsv(blue_image) blue_hsv_image[0,0].numpy() array([0.6666667, 1. , 1. ], dtype=float32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
images 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.RightShift (TF::RightShiftOp)

逐元素計算 xy 的位元右移。

針對無符號整數類型執行邏輯移位,並針對帶符號整數類型執行算術移位。

如果 y 為負數,或大於或等於 x 的位元寬度,則結果由實作定義。

範例

import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
import numpy as np
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64]

for dtype in dtype_list:
  lhs = tf.constant([-1, -5, -3, -14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)

  right_shift_result = bitwise_ops.right_shift(lhs, rhs)

  print(right_shift_result)

# This will print:
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int8)
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int16)
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int32)
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int64)

lhs = np.array([-2, 64, 101, 32], dtype=np.int8)
rhs = np.array([-1, -5, -3, -14], dtype=np.int8)
bitwise_ops.right_shift(lhs, rhs)
# <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2,  64, 101,  32], dtype=int8)>

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 整數值的張量
y 整數值的張量

結果

結果 描述
z 整數值的張量

tf.Rint (TF::RintOp)

傳回逐元素最接近 x 的整數。

如果結果介於兩個可表示值的中間,則會選擇偶數可表示值。例如

rint(-1.5) ==> -2.0
rint(0.5000001) ==> 1.0
rint([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]) ==> [-2., -2., -0., 0., 2., 2., 2.]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量

結果

結果 描述
y 浮點數值的張量

tf.RiscAdd (TF::RiscAddOp)

逐元素傳回 x + y。

給定兩個輸入張量,tf.risc_add 運算會計算張量中每個元素的總和。

輸入和輸出範圍皆為 (-inf, inf)

Traits: AlwaysSpeculatableImplTrait, Commutative

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數值的張量
y 浮點數值的張量

結果

結果 描述
z 浮點數值的張量

tf.RiscDot (TF::RiscDotOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
transpose_a::mlir::BoolAttr布林屬性
transpose_b::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 浮點數值的張量
b 浮點數值的張量

結果

結果 描述
product 浮點數值的張量

tf.RngReadAndSkip (TF::RngReadAndSkipOp)

推進基於計數器的 RNG 的計數器。

rng_read_and_skip(n) 之後,RNG 的狀態將與 uniform([n])(或任何其他分佈)之後的狀態相同。新增至計數器的實際增量是未指定的實作選擇。

如果輸入演算法為 RNG_ALG_AUTO_SELECT,則狀態中的計數器大小必須為 int64[2],這是演算法中目前最大的計數器大小。在這種情況下,此運算會將計數器管理為 128 位元整數,配置為 [lower_64bits, higher_64bits]。如果演算法需要的計數器少於 128 位元,則應使用 int64[2] 的左側部分。如此一來,int64[2] 便與所有目前的 RNG 演算法(Philox、ThreeFry 和 xla::RandomAlgorithm::RNG_DEFAULT)相容。因此,下游 RNG 運算可以使用此計數器搭配任何 RNG 演算法。

運算元

運算元 描述
resource 資源值的張量
alg 32 位元整數值的張量
delta 64 位元無符號整數值的張量

結果

結果 描述
value 64 位元整數值的張量

tf.Roll (TF::RollOp)

沿著軸滾動張量的元素。

元素會沿著 axis 維度,依 shift 的偏移量正向移動(朝向較大的索引)。負 shift 值會使元素朝相反方向移動。滾動超過最後一個位置的元素將會環繞到第一個位置,反之亦然。可以指定沿著多個軸的多個位移。

例如

# 't' is [0, 1, 2, 3, 4]
roll(t, shift=2, axis=0) ==> [3, 4, 0, 1, 2]

# shifting along multiple dimensions
# 't' is [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
roll(t, shift=[1, -2], axis=[0, 1]) ==> [[7, 8, 9, 5, 6], [2, 3, 4, 0, 1]]

# shifting along the same axis multiple times
# 't' is [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
roll(t, shift=[2, -3], axis=[1, 1]) ==> [[1, 2, 3, 4, 0], [6, 7, 8, 9, 5]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Taxis::mlir::Attribute衍生屬性
Tshift::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
shift 32/64 位元帶正負號的整數值的張量
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Round (TF::RoundOp)

將張量的值四捨五入到最接近的整數,逐元素。

四捨五入到最接近的偶數。也稱為銀行家捨入法。如果您想根據目前的系統捨入模式進行捨入,請使用 std::cint。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

結果

結果 描述
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

tf.Rsqrt (TF::RsqrtOp)

逐元素計算 x 平方根的倒數。

亦即,\(y = 1 / \sqrt{x}\)。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.RsqrtGrad (TF::RsqrtGradOp)

計算 x 的 rsqrt 相對於其輸入的梯度。

具體來說,grad = dy * -0.5 * y^3,其中 y = rsqrt(x),而 dy 是對應的輸入梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
y 浮點數或複數值的張量
dy 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.Save (TF::SaveOp)

將輸入張量儲存到磁碟。

tensor_names 的大小必須與 data 中的張量數目相符。data[i] 會以名稱 tensor_names[i] 寫入 filename

另請參閱 SaveSlices

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
filename 字串值的張量
tensor_names 字串值的張量
data tf.dtype 值的張量的可變參數

tf.SaveSlices (TF::SaveSlicesOp)

將輸入張量切片儲存到磁碟。

這與 Save 類似,不同之處在於張量可以在儲存的檔案中列為較大張量的切片。shapes_and_slices 指定較大張量的形狀以及此張量涵蓋的切片。shapes_and_slices 必須與 tensor_names 的元素數目相同。

shapes_and_slices 輸入的元素必須是

  • 空字串,在這種情況下,對應的張量會正常儲存。
  • 格式為 dim0 dim1 ... dimN-1 slice-spec 的字串,其中 dimI 是較大張量的維度,而 slice-spec 指定要儲存的張量涵蓋的部分。

slice-spec 本身是以 : 分隔的清單:slice0:slice1:...:sliceN-1,其中每個 sliceI 都是

  • 字串 -,表示切片涵蓋此維度的所有索引
  • start,length,其中 startlength 是整數。在這種情況下,切片涵蓋從 start 開始的 length 個索引。

另請參閱 Save

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
filename 字串值的張量
tensor_names 字串值的張量
shapes_and_slices 字串值的張量
data tf.dtype 值的張量的可變參數

tf.SaveV2 (TF::SaveV2Op)

以 V2 檢查點格式儲存張量。

預設情況下,會完整儲存具名張量。如果呼叫者希望儲存完整張量的特定切片,則 "shape_and_slices" 應為非空字串,且格式正確。

屬性

屬性MLIR 類型描述
dtypes (資料類型)::mlir::Attribute衍生屬性

運算元

運算元 描述
prefix 字串值的張量
tensor_names 字串值的張量
shape_and_slices 字串值的張量
tensors tf.dtype 值的張量的可變參數

tf.ScatterNd (TF::ScatterNdOp)

根據 indicesupdates 分散到形狀為 shape 的張量中。

根據指定 indices 處的個別值分散稀疏 updates。此運算會傳回您指定的 shape 的輸出張量。此運算是 tf.gather_nd 運算子的反向運算子,後者會從給定張量中擷取值或切片。

此運算類似於 tf.tensor_scatter_nd_add,不同之處在於張量是零初始化的。呼叫 tf.scatter_nd(indices, updates, shape) 與呼叫 tf.tensor_scatter_nd_add(tf.zeros(shape, updates.dtype), indices, updates) 相同

如果 indices 包含重複項,則關聯的 updates 會累積(加總)到輸出張量中。

indices 是一個整數張量,其中包含輸出張量的索引。indices 的最後一個維度最多可以是 shape 的等級

indices.shape[-1] <= shape.rank

indices 的最後一個維度對應到元素的索引 (如果 indices.shape[-1] = shape.rank) 或切片 (如果 indices.shape[-1] < shape.rank),沿著 shape 的維度 indices.shape[-1]

updates 是一個形狀為以下的張量

indices.shape[:-1] + shape[indices.shape[-1]:]

scatter 運算的最簡單形式是通過索引在張量中插入個別元素。考慮一個範例,您想要在一個具有 8 個元素的一維張量中插入 4 個分散的元素。

在 Python 中,這個 scatter 運算看起來會像這樣

    indices = tf.constant([[4], [3], [1], [7]])
    updates = tf.constant([9, 10, 11, 12])
    shape = tf.constant([8])
    scatter = tf.scatter_nd(indices, updates, shape)
    print(scatter)

產生的張量會看起來像這樣

[0, 11, 0, 10, 9, 0, 0, 12]

您也可以一次插入較高階張量的整個切片。例如,您可以在一個秩為 3 的張量的第一個維度中插入兩個切片,並使用兩個新的值矩陣。

在 Python 中,這個 scatter 運算看起來會像這樣

    indices = tf.constant([[1], [3]])
    updates = tf.constant([[[5, 5, 5, 5], [6, 6, 6, 6],
                            [7, 7, 7, 7], [8, 8, 8, 8]],
                           [[5, 5, 5, 5], [6, 6, 6, 6],
                            [7, 7, 7, 7], [8, 8, 8, 8]]])
    shape = tf.constant([4, 4, 4])
    scatter = tf.scatter_nd(indices, updates, shape)
    print(scatter)

產生的張量會看起來像這樣

[[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
 [[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]],
 [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
 [[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7], [8, 8, 8, 8]]]

請注意,在 CPU 上,如果找到超出範圍的索引,則會傳回錯誤。在 GPU 上,如果找到超出範圍的索引,則會忽略該索引。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
indices 16 位元整數或 32 位元整數或 64 位元整數值的張量
updates (更新) tf.dtype 值的張量
shape 16 位元整數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.SegmentMax (TF::SegmentMaxOp)

計算張量分段的最大值。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \max_j(data_j)\),其中 max 是在所有 j 中取最大值,使得 segment_ids[j] == i

如果給定的分段 ID i 的最大值為空,則 output[i] = 0

例如

c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) tf.math.segment_max(c, tf.constant([0, 0, 1])).numpy() array([[4, 3, 3, 4], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
data 整數或浮點數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.SegmentMaxV2 (TF::SegmentMaxV2Op)

計算張量分段的最大值。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \max_j(data_j)\),其中 max 是在所有 j 中取最大值,使得 segment_ids[j] == i

如果給定的分段 ID i 的最大值為空,它會輸出特定數值類型的最小值,output[i] = numeric_limits<T>::lowest()

與 SegmentMax 唯一的區別是額外的輸入 num_segments。這有助於在編譯時評估輸出形狀。num_segments 應與 segment_ids 一致。例如,對於一維 segment_ids,Max(segment_ids) 應等於 num_segments - 1。對於不一致的 num_segments,運算仍然會執行。唯一的區別是,輸出會採用 num_segments 的大小,而與 segment_ids 和 data 的大小無關。對於 num_segments 小於預期的輸出大小,最後的元素會被忽略;對於 num_segments 大於預期的輸出大小,最後的元素會被賦予特定數值類型的最小值。

例如

@tf.function(jit_compile=True) ... def test(c): ... return tf.raw_ops.SegmentMaxV2(data=c, segment_ids=tf.constant([0, 0, 1]), num_segments=2) c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) test(c).numpy() array([[4, 3, 3, 4], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 整數或浮點數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.SegmentMean (TF::SegmentMeanOp)

計算張量分段的平均值。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \frac{\sum_j data_j}{N}\),其中 mean 是在所有 j 中取平均值,使得 segment_ids[j] == i,而 N 是求和的值的總數。

如果給定的分段 ID i 的平均值為空,則 output[i] = 0

例如

c = tf.constant([[1.0,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) tf.math.segment_mean(c, tf.constant([0, 0, 1])).numpy() array([[2.5, 2.5, 2.5, 2.5], [5., 6., 7., 8.]], dtype=float32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
data 數字值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.SegmentMin (TF::SegmentMinOp)

計算張量分段的最小值。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \min_j(data_j)\),其中 min 是在所有 j 中取最小值,使得 segment_ids[j] == i

如果給定的分段 ID i 的最小值為空,則 output[i] = 0

例如

c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) tf.math.segment_min(c, tf.constant([0, 0, 1])).numpy() array([[1, 2, 2, 1], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
data 整數或浮點數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.SegmentMinV2 (TF::SegmentMinV2Op)

計算張量分段的最小值。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \min_j(data_j)\),其中 min 是在所有 j 中取最小值,使得 segment_ids[j] == i

如果給定的分段 ID i 的最小值為空,它會輸出特定數值類型的最大值,output[i] = numeric_limits<T>::max()

與 SegmentMin 唯一的區別是額外的輸入 num_segments。這有助於在編譯時評估輸出形狀。num_segments 應與 segment_ids 一致。例如,對於一維 segment_ids,Max(segment_ids) 應等於 num_segments - 1。對於不一致的 num_segments,運算仍然會執行。唯一的區別是,輸出會採用 num_segments 的大小,而與 segment_ids 和 data 的大小無關。對於 num_segments 小於預期的輸出大小,最後的元素會被忽略;對於 num_segments 大於預期的輸出大小,最後的元素會被賦予特定數值類型的最大值。

例如

@tf.function(jit_compile=True) ... def test(c): ... return tf.raw_ops.SegmentMinV2(data=c, segment_ids=tf.constant([0, 0, 1]), num_segments=2) c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) test(c).numpy() array([[1, 2, 2, 1], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 整數或浮點數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.SegmentProd (TF::SegmentProdOp)

計算張量分段的乘積。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \prod_j data_j\),其中乘積是在所有 j 中取乘積,使得 segment_ids[j] == i

如果給定的分段 ID i 的乘積為空,則 output[i] = 1

例如

c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) tf.math.segment_prod(c, tf.constant([0, 0, 1])).numpy() array([[4, 6, 6, 4], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
data 數字值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.SegmentProdV2 (TF::SegmentProdV2Op)

計算張量分段的乘積。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \prod_j data_j\),其中乘積是在所有 j 中取乘積,使得 segment_ids[j] == i

如果給定的分段 ID i 的乘積為空,則 output[i] = 1

與 SegmentProd 唯一的區別是額外的輸入 num_segments。這有助於在編譯時評估輸出形狀。num_segments 應與 segment_ids 一致。例如,對於一維 segment_ids,Max(segment_ids) - 1 應等於 num_segments。對於不一致的 num_segments,運算仍然會執行。唯一的區別是,輸出會採用 num_segments 的大小,而與 segment_ids 和 data 的大小無關。對於 num_segments 小於預期的輸出大小,最後的元素會被忽略;對於 num_segments 大於預期的輸出大小,最後的元素會被賦予 1。

例如

@tf.function(jit_compile=True) ... def test(c): ... return tf.raw_ops.SegmentProdV2(data=c, segment_ids=tf.constant([0, 0, 1]), num_segments=2) c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) test(c).numpy() array([[4, 6, 6, 4], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 數字值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.SegmentSum (TF::SegmentSumOp)

計算張量分段的總和。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \sum_j data_j\),其中總和是在所有 j 中取總和,使得 segment_ids[j] == i

如果給定的分段 ID i 的總和為空,則 output[i] = 0

例如

c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]]) tf.math.segment_sum(c, tf.constant([0, 0, 1])).numpy() array([[5, 5, 5, 5], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
data 數字值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.SegmentSumV2 (TF::SegmentSumV2Op)

計算張量分段的總和。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output_i = \sum_j data_j\),其中總和是在所有 j 中取總和,使得 segment_ids[j] == i

如果給定的分段 ID i 的總和為空,則 output[i] = 0

請注意,此運算目前僅在 jit_compile=True 的情況下受支援。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 數字值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.Select (TF::SelectOp)

根據 conditionxy 中選取元素。

xy 張量都必須具有相同的形狀,且輸出也將具有該形狀。

如果 xy 是純量,則 condition 張量必須是純量。如果 xy 是向量或更高階,則 condition 必須是純量、大小與 x 的第一個維度相符的向量,或必須具有與 x 相同的形狀。

condition 張量充當遮罩,根據每個元素的值選擇輸出中的對應元素/列應取自 x (如果為 true) 還是 y (如果為 false)。

如果 condition 是一個向量,且 xy 是更高階的矩陣,則它會選擇要從 xy 複製的列 (外部維度)。如果 condition 具有與 xy 相同的形狀,則它會選擇要從 xy 複製的元素。

例如

# 'condition' tensor is [[True,  False]
#                        [False, True]]
# 't' is [[1, 2],
#         [3, 4]]
# 'e' is [[5, 6],
#         [7, 8]]
select(condition, t, e)  # => [[1, 6], [7, 4]]


# 'condition' tensor is [True, False]
# 't' is [[1, 2],
#         [3, 4]]
# 'e' is [[5, 6],
#         [7, 8]]
select(condition, t, e) ==> [[1, 2],
                             [7, 8]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
condition 布林值的張量
then_value tf.dtype 值的張量
else_value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.SelectV2 (TF::SelectV2Op)

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
condition 布林值的張量
then_value tf.dtype 值的張量
else_value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.SelfAdjointEigV2 (TF::SelfAdjointEigV2Op)

計算一個或多個自伴隨方陣的特徵分解。

計算 input 中每個內部矩陣的特徵值和 (可選) 特徵向量,使得 input[..., :, :] = v[..., :, :] * diag(e[..., :])。特徵值以非遞減順序排序。

# a is a tensor.
# e is a tensor of eigenvalues.
# v is a tensor of eigenvectors.
e, v = self_adjoint_eig(a)
e = self_adjoint_eig(a, compute_v=False)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
compute_v::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
e 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
v 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.Selu (TF::SeluOp)

計算縮放指數線性:scale * alpha * (exp(features) - 1)

如果 < 0,則為 scale * features,否則為 0。

應與 initializer = tf.variance_scaling_initializer(factor=1.0, mode='FAN_IN') 一起使用。為了正確的 dropout,請使用 tf.contrib.nn.alpha_dropout

請參閱 Self-Normalizing Neural Networks

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features 浮點數值的張量

結果

結果 描述
activations 浮點數值的張量

tf.SeluGrad (TF::SeluGradOp)

計算縮放指數線性 (Selu) 運算的梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 浮點數值的張量
outputs 浮點數值的張量

結果

結果 描述
backprops 浮點數值的張量

tf.Send (TF::SendOp)

_從 send_device 將具名張量傳送至 recv_device。

介面:TF_SendSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
send_device::mlir::StringAttr字串屬性
send_device_incarnation::mlir::IntegerAttr64 位元無號整數屬性
recv_device::mlir::StringAttr字串屬性
client_terminated::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量

tf.SendTPUEmbeddingGradients (TF::SendTPUEmbeddingGradientsOp)

執行嵌入表梯度更新。

Traits: AttrSizedOperandSegments

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性
N::mlir::Attribute衍生屬性
NN::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs 32 位元浮點數值的張量的可變參數
learning_rates 32 位元浮點數值的張量的可變參數

tf.SerializeIterator (TF::SerializeIteratorOp)

將代表迭代器的給定 resource_handle 轉換為變體張量。

屬性

屬性MLIR 類型描述
external_state_policy::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
resource_handle 資源值的張量

結果

結果 描述
serialized 變體值的張量

tf.SerializeSparse (TF::SerializeSparseOp)

SparseTensor 序列化為 [3] Tensor 物件。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
sparse_indices 64 位元整數值的張量
sparse_values tf.dtype 值的張量
sparse_shape 64 位元整數值的張量

結果

結果 描述
serialized_sparse 字串或變體值的張量

tf.SetStaticDimensionBounds (TF::SetStaticDimensionBoundsOp)

用於向編譯器和執行階段指示張量的靜態邊界的運算。

通過此運算傳遞的資訊可能會被編譯器和執行階段用於執行某些最佳化,例如更有效率的 DMA。通過此運算傳遞的邊界應僅被視為建議性質,並且根據實作方式,可能不會執行任何操作,而僅僅是恆等式

input:具有動態維度的張量。static_shape:張量的靜態形狀,對應於每個維度的最大邊界。output 是輸入張量,未對其進行任何變更。

範例用法

def tpu_call(args): def model_fn(args): # do something with dynamic tensor

@function.Defun(capture_resource_var_by_value=False) def tpu_subgraph(): return tf.tpu.rewrite(model_fn, args)

return tf.raw_ops.TPUPartitionedCall( args=tpu_subgraph.captured_inputs, Tout=[o.type for o in tpu_subgraph.definition.signature.output_arg], f=tpu_subgraph, device_ordinal=[0])

static_shape = tf.placeholder(tf.int32, shape=([3]), name='static_size')

w = tf.Variable(tf.constant([[1.0], [2.0], [3.0]]), name='w')

w_dyn = tf.SetDynamicDimensionBounds(w, static_size]) tpu_call([w_dyn])

運算元

運算元 描述
輸入 tf.dtype 值的張量
static_shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Shape (TF::ShapeOp)

傳回張量的形狀。

此運算會傳回一個一維整數張量,表示 input 的形狀。

例如

# 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]
shape(t) ==> [2, 2, 3]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.ShapeN (TF::ShapeNOp)

傳回張量的形狀。

此運算會傳回 N 個一維整數張量,表示 input[i]s 的形狀。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 32/64 位元有號整數值的張量變數

tf.ShardedFilename (TF::ShardedFilenameOp)

產生分片檔案名稱。檔案名稱的 printf 格式為

%s-%05d-of-%05d, basename, shard, num_shards。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
basename 字串值的張量
shard 32 位元整數值的張量
num_shards (分片數量) 32 位元整數值的張量

結果

結果 描述
filename 字串值的張量

tf.ShuffleAndRepeatDatasetV2 (TF::ShuffleAndRepeatDatasetV2Op)

屬性

屬性MLIR 類型描述
reshuffle_each_iteration::mlir::BoolAttr布林屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
buffer_size 64 位元整數值的張量
seed 64 位元整數值的張量
seed2 64 位元整數值的張量
次數 64 位元整數值的張量
seed_generator 資源值的張量

結果

結果 描述
handle 變體值的張量

tf.ShuffleDatasetV2 (TF::ShuffleDatasetV2Op)

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
buffer_size 64 位元整數值的張量
seed_generator 資源值的張量

結果

結果 描述
handle 變體值的張量

tf.ShuffleDatasetV3 (TF::ShuffleDatasetV3Op)

屬性

屬性MLIR 類型描述
reshuffle_each_iteration::mlir::BoolAttr布林屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
buffer_size 64 位元整數值的張量
seed 64 位元整數值的張量
seed2 64 位元整數值的張量
seed_generator 資源值的張量

結果

結果 描述
handle 變體值的張量

tf.ShutdownDistributedTPU (TF::ShutdownDistributedTPUOp)

關閉正在執行的分散式 TPU 系統。

如果沒有系統正在執行,則運算會傳回錯誤。

tf.ShutdownTPUSystem (TF::ShutdownTPUSystemOp)

一個關閉 TPU 系統的運算。

結果

結果 描述
success 布林值的張量

tf.Sigmoid (TF::SigmoidOp)

逐元素計算 x 的 sigmoid 函數。

具體而言,y = 1 / (1 + exp(-x))

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.SigmoidGrad (TF::SigmoidGradOp)

計算 x 的 sigmoid 函數相對於其輸入的梯度。

具體而言,grad = dy * y * (1 - y),其中 y = sigmoid(x),而 dy 是對應的輸入梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
y 浮點數或複數值的張量
dy 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.Sign (TF::SignOp)

傳回數字符號的逐元素指示。

y = sign(x) = -1 如果 x < 0;0 如果 x == 0;1 如果 x > 0

對於複數,y = sign(x) = x / |x| 如果 x != 0,否則 y = 0

範例用法

tf.math.sign([0., 2., -3.])

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

結果

結果 描述
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數值的張量

tf.Sin (TF::SinOp)

逐元素計算 x 的正弦值。

給定輸入張量,此函數計算張量中每個元素的正弦值。輸入範圍為 (-inf, inf),輸出範圍為 [-1,1]

  x = tf.constant([-float("inf"), -9, -0.5, 1, 1.2, 200, 10, float("inf")])
  tf.math.sin(x) ==> [nan -0.4121185 -0.47942555 0.84147096 0.9320391 -0.87329733 -0.54402107 nan]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Sinh (TF::SinhOp)

逐元素計算 x 的雙曲正弦值。

給定輸入張量,此函數計算張量中每個元素的雙曲正弦值。輸入範圍為 [-inf,inf],輸出範圍為 [-inf,inf]

  x = tf.constant([-float("inf"), -9, -0.5, 1, 1.2, 2, 10, float("inf")])
  tf.math.sinh(x) ==> [-inf -4.0515420e+03 -5.2109528e-01 1.1752012e+00 1.5094614e+00 3.6268604e+00 1.1013232e+04 inf]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Size (TF::SizeOp)

傳回張量的大小。

此運算會傳回一個整數,表示 input 中的元素數量。

例如

# 't' is [[[1, 1,, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]]
size(t) ==> 12

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.Slice (TF::SliceOp)

從 'input' 傳回切片。

輸出張量是一個維度由 'size' 描述的張量,其值從 'begin' 中的偏移量開始從 'input' 中提取。

需求:0 <= begin[i] <= begin[i] + size[i] <= Di,適用於 i in [0, n)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
索引::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
begin 32/64 位元帶正負號的整數值的張量
size 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Snapshot (TF::SnapshotOp)

傳回輸入張量的副本。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Softmax (TF::SoftmaxOp)

計算 softmax 啟動。

對於每個批次 i 和類別 j,我們有

$$softmax[i, j] = exp(logits[i, j]) / sum_j(exp(logits[i, j]))$$

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
logits 浮點數值的張量

結果

結果 描述
softmax 浮點數值的張量

tf.SoftmaxCrossEntropyWithLogits (TF::SoftmaxCrossEntropyWithLogitsOp)

計算 softmax 交叉熵成本和梯度以進行反向傳播。

輸入是 logits,而不是機率。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features 浮點數值的張量
labels 浮點數值的張量

結果

結果 描述
loss 浮點數值的張量
backprop 浮點數值的張量

tf.Softplus (TF::SoftplusOp)

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features 浮點數值的張量

結果

結果 描述
activations 浮點數值的張量

tf.SoftplusGrad (TF::SoftplusGradOp)

計算 softplus 運算的 softplus 梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 浮點數值的張量
features 浮點數值的張量

結果

結果 描述
backprops 浮點數值的張量

tf.Softsign (TF::SoftsignOp)

計算 softsign:features / (abs(features) + 1)

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
features 浮點數值的張量

結果

結果 描述
activations 浮點數值的張量

tf.SoftsignGrad (TF::SoftsignGradOp)

計算 softsign 運算的 softsign 梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 浮點數值的張量
features 浮點數值的張量

結果

結果 描述
backprops 浮點數值的張量

tf.SortListOfSparseCoreCooTensors (TF::SortListOfSparseCoreCooTensorsOp)

一個運算,用於按每個 COO 張量中的 SparseCore ID 對列表中的 COO 張量進行排序。此運算應與 ConvertToSparseCoreCsrWrappedCooTensorOp 一起使用。

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count_list (樣本計數列表)::mlir::ArrayAttr64 位元整數陣列屬性
col_offset_list (欄偏移列表)::mlir::ArrayAttr64 位元整數陣列屬性
num_replica::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_vocab_size::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
feature_width::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_sc_per_chip::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性
N::mlir::Attribute衍生屬性

運算元

運算元 描述
row_ids_list 32 位元整數值的張量的變數
col_ids_list 32 位元整數值的張量的變數
gains_list 32 位元浮點數值的張量的可變參數

結果

結果 描述
sorted_row_ids (已排序的列 ID) 32 位元整數值的張量
sorted_col_ids (已排序的欄 ID) 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
id_counts (ID 計數) 32 位元整數值的張量

tf.SpaceToBatch (TF::SpaceToBatchOp)

適用於 T 類型 4 維張量的 SpaceToBatch。

這是更通用的 SpaceToBatchND 的舊版。

將空間資料區塊零填充,然後重新排列 (置換) 成批次。更具體而言,此運算會輸出輸入張量的副本,其中 heightwidth 維度中的值會移至 batch 維度。在零填充之後,輸入的 heightwidth 都必須可被區塊大小整除。

attr block_size 必須大於 1。它表示區塊大小。

  • 高度和寬度維度中大小為 block_size x block_size 的非重疊區塊會重新排列到每個位置的批次維度中。
  • 輸出張量的批次為 batch * block_size * block_size
  • height_pad 和 width_pad 都必須可被 block_size 整除。

輸出的形狀將為

[batch*block_size*block_size, height_pad/block_size, width_pad/block_size,
 depth]

一些範例

(1) 對於以下形狀為 [1, 2, 2, 1] 且區塊大小為 2 的輸入

x = [[[[1], [2]], [[3], [4]]]]

輸出張量的形狀為 [4, 1, 1, 1],值為

[[[[1]]], [[[2]]], [[[3]]], [[[4]]]]

(2) 對於以下形狀為 [1, 2, 2, 3] 且區塊大小為 2 的輸入

x = [[[[1, 2, 3], [4, 5, 6]],
      [[7, 8, 9], [10, 11, 12]]]]

輸出張量的形狀為 [4, 1, 1, 3],值為

[[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]]

(3) 對於以下形狀為 [1, 4, 4, 1] 且區塊大小為 2 的輸入

x = [[[[1],   [2],  [3],  [4]],
      [[5],   [6],  [7],  [8]],
      [[9],  [10], [11],  [12]],
      [[13], [14], [15],  [16]]]]

輸出張量的形狀為 [4, 2, 2, 1],值為

x = [[[[1], [3]], [[9], [11]]],
     [[[2], [4]], [[10], [12]]],
     [[[5], [7]], [[13], [15]]],
     [[[6], [8]], [[14], [16]]]]

(4) 對於以下形狀為 [2, 2, 4, 1] 且區塊大小為 2 的輸入

x = [[[[1],   [2],  [3],  [4]],
      [[5],   [6],  [7],  [8]]],
     [[[9],  [10], [11],  [12]],
      [[13], [14], [15],  [16]]]]

輸出張量的形狀為 [8, 1, 2, 1],值為

x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]],
     [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]]

除其他外,此運算適用於將 atrous 卷積減少為常規卷積。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
block_size::mlir::IntegerAttr最小值為 2 的 64 位元無號整數屬性
T::mlir::Attribute衍生屬性
Tpaddings::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
paddings 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.SpaceToBatchND (TF::SpaceToBatchNDOp)

適用於 T 類型 N 維張量的 SpaceToBatch。

此運算將輸入的「空間」維度 [1, ..., M] 分割成形狀為 block_shape 的區塊網格,並將這些區塊與「批次」維度 (0) 交錯,使得在輸出中,空間維度 [1, ..., M] 對應於網格內的位置,而批次維度結合了空間區塊內的位置和原始批次位置。在分割成區塊之前,輸入的空間維度可以選擇性地根據 paddings 進行零填充。請參閱下文以取得精確的描述。

此運算等效於以下步驟

  1. 根據 paddings 對輸入的維度 [1, ..., M] 的開始和結束進行零填充,以產生形狀為 padded_shapepadded

  2. padded 重塑為形狀為 reshaped_padded

    [batch] + [padded_shape[1] / block_shape[0], block_shape[0], ..., padded_shape[M] / block_shape[M-1], block_shape[M-1]] + remaining_shape

  3. 置換 reshaped_padded 的維度以產生形狀為 permuted_reshaped_padded

    block_shape + [batch] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape

  4. 重塑 permuted_reshaped_padded 以將 block_shape 平坦化為批次維度,從而產生形狀為以下的輸出張量

    [batch * prod(block_shape)] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape

一些範例

(1) 對於以下形狀為 [1, 2, 2, 1]block_shape = [2, 2]paddings = [[0, 0], [0, 0]] 的輸入

x = [[[[1], [2]], [[3], [4]]]]

輸出張量的形狀為 [4, 1, 1, 1],值為

[[[[1]]], [[[2]]], [[[3]]], [[[4]]]]

(2) 對於以下形狀為 [1, 2, 2, 3]block_shape = [2, 2]paddings = [[0, 0], [0, 0]] 的輸入

x = [[[[1, 2, 3], [4, 5, 6]],
      [[7, 8, 9], [10, 11, 12]]]]

輸出張量的形狀為 [4, 1, 1, 3],值為

[[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]]

(3) 對於以下形狀為 [1, 4, 4, 1]block_shape = [2, 2]paddings = [[0, 0], [0, 0]] 的輸入

x = [[[[1],   [2],  [3],  [4]],
      [[5],   [6],  [7],  [8]],
      [[9],  [10], [11],  [12]],
      [[13], [14], [15],  [16]]]]

輸出張量的形狀為 [4, 2, 2, 1],值為

x = [[[[1], [3]], [[9], [11]]],
     [[[2], [4]], [[10], [12]]],
     [[[5], [7]], [[13], [15]]],
     [[[6], [8]], [[14], [16]]]]

(4) 對於以下形狀為 [2, 2, 4, 1]、block_shape = [2, 2] 和 paddings = [[0, 0], [2, 0]] 的輸入

x = [[[[1],   [2],  [3],  [4]],
      [[5],   [6],  [7],  [8]]],
     [[[9],  [10], [11],  [12]],
      [[13], [14], [15],  [16]]]]

輸出張量的形狀為 [8, 1, 3, 1],值為

x = [[[[0], [1], [3]]], [[[0], [9], [11]]],
     [[[0], [2], [4]]], [[[0], [10], [12]]],
     [[[0], [5], [7]]], [[[0], [13], [15]]],
     [[[0], [6], [8]]], [[[0], [14], [16]]]]

除其他外,此運算適用於將 atrous 卷積減少為常規卷積。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tblock_shape::mlir::Attribute衍生屬性
Tpaddings::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
block_shape 32/64 位元帶正負號的整數值的張量
paddings 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.SpaceToDepth (TF::SpaceToDepthOp)

適用於 T 類型張量的 SpaceToDepth。

將空間資料區塊重新排列成深度。更具體而言,此運算會輸出輸入張量的副本,其中 heightwidth 維度中的值會移至 depth 維度。attr block_size 表示輸入區塊大小。

  • 大小為 block_size x block_size 的非重疊區塊會重新排列到每個位置的深度中。
  • 輸出張量的深度為 block_size * block_size * input_depth
  • 輸入的每個區塊內的 Y、X 座標會成為輸出通道索引的高階組件。
  • 輸入張量的高度和寬度必須可被 block_size 整除。

data_format 屬性使用以下選項指定輸入和輸出張量的版面配置:"NHWC":[ batch, height, width, channels ] "NCHW":[ batch, channels, height, width ] "NCHW_VECT_C":qint8 [ batch, channels / 4, height, width, 4 ]

將運算視為轉換 6 維張量很有用。例如,對於 data_format = NHWC,輸入張量中的每個元素都可以通過 6 個座標指定,按記憶體佈局重要性降序排列為:n,oY,bY,oX,bX,iC (其中 n=批次索引,oX, oY 表示輸出影像內的 X 或 Y 座標,bX, bY 表示輸入區塊內的座標,iC 表示輸入通道)。輸出將轉置為以下佈局:n,oY,oX,bY,bX,iC

此運算適用於調整卷積之間的啟動大小 (但保留所有資料),例如,而不是池化。它也適用於訓練純粹的卷積模型。

例如,給定形狀為 [1, 2, 2, 1]、data_format = "NHWC" 和 block_size = 2 的輸入

x = [[[[1], [2]],
      [[3], [4]]]]

此運算將輸出形狀為 [1, 1, 1, 4] 的張量

[[[[1, 2, 3, 4]]]]

在此,輸入的批次為 1,且每個批次元素的形狀為 [2, 2, 1],對應的輸出將具有單個元素 (即寬度和高度均為 1),並且深度為 4 個通道 (1 * block_size * block_size)。輸出元素形狀為 [1, 1, 4]

對於具有較大深度的輸入張量,此處形狀為 [1, 2, 2, 3],例如

x = [[[[1, 2, 3], [4, 5, 6]],
      [[7, 8, 9], [10, 11, 12]]]]

對於區塊大小為 2 的此運算,將傳回以下形狀為 [1, 1, 1, 12] 的張量

[[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]

同樣地,對於以下形狀為 [1 4 4 1] 和區塊大小為 2 的輸入

x = [[[[1],   [2],  [5],  [6]],
      [[3],   [4],  [7],  [8]],
      [[9],  [10], [13],  [14]],
      [[11], [12], [15],  [16]]]]

運算符將傳回以下形狀為 [1 2 2 4] 的張量

x = [[[[1, 2, 3, 4],
       [5, 6, 7, 8]],
      [[9, 10, 11, 12],
       [13, 14, 15, 16]]]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
block_size::mlir::IntegerAttr最小值為 2 的 64 位元無號整數屬性
data_format::mlir::StringAttr值為 NHWC、NCHW 或 NCHW_VECT_C 的字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.SparseAdd (TF::SparseAddOp)

將兩個 SparseTensor 物件相加,以產生另一個 SparseTensor

假設輸入 SparseTensor 物件的索引以標準詞典順序排序。如果不是這種情況,請在此步驟之前執行 SparseReorder 以還原索引順序。

預設情況下,如果兩個值在某個索引處加總為零,則輸出 SparseTensor 仍將在其索引中包含該特定位置,並在對應的值槽中儲存零。為了覆蓋此行為,呼叫者可以指定 thresh,表示如果總和的量值嚴格小於 thresh,則其對應的值和索引將不會包含在內。特別是,thresh == 0 (預設值) 表示所有內容都將保留,並且僅當值為正數時才會發生實際的閾值處理。

在以下形狀中,nnz 是考慮 thresh 之後的計數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Treal (T實數)::mlir::Attribute衍生屬性

運算元

運算元 描述
a_indices 64 位元整數值的張量
a_values 數字值的張量
a_shape 64 位元整數值的張量
b_indices 64 位元整數值的張量
b_values 數字值的張量
b_shape 64 位元整數值的張量
thresh 整數或浮點數值的張量

結果

結果 描述
sum_indices 64 位元整數值的張量
sum_values 數字值的張量
sum_shape 64 位元整數值的張量

tf.SparseFillEmptyRows (TF::SparseFillEmptyRowsOp)

使用預設值填滿輸入 2 維 SparseTensor 中的空白列。

輸入 SparseTensor 通過輸入元組 (indicesvaluesdense_shape) 表示。輸出 SparseTensor 具有相同的 dense_shape,但具有索引 output_indices 和值 output_values

此運算會為每個沒有任何值的列插入單個條目。索引建立為 [row, 0, ..., 0],插入的值為 default_value

例如,假設 sp_input 的形狀為 [5, 6],且非空值為

[0, 1]: a
[0, 3]: b
[2, 0]: c
[3, 1]: d

列 1 和 4 為空,因此輸出將為形狀 [5, 6],值為

[0, 1]: a
[0, 3]: b
[1, 0]: default_value
[2, 0]: c
[3, 1]: d
[4, 0]: default_value

輸出 SparseTensor 將採用列優先順序,並且將具有與輸入相同的形狀。

此運算還會傳回一個形狀為 [dense_shape[0]] 的指示向量,使得

empty_row_indicator[i] = True iff row i was an empty row.

以及一個在反向傳播期間使用的形狀為 [indices.shape[0]] 的反向索引地圖向量,

reverse_index_map[j] = out_j s.t. indices[j, :] == output_indices[out_j, :]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
indices 64 位元整數值的張量
values tf.dtype 值的張量
dense_shape 64 位元整數值的張量
default_value tf.dtype 值的張量

結果

結果 描述
output_indices 64 位元整數值的張量
output_values tf.dtype 值的張量
empty_row_indicator 布林值的張量
reverse_index_map 64 位元整數值的張量

tf.SparseMatMul (TF::SparseMatMulOp)

將矩陣 "a" 乘以矩陣 "b"。

輸入必須為二維矩陣,且 "a" 的內部維度必須符合 "b" 的外部維度。"a" 和 "b" 都必須是 Tensor,而非 SparseTensor。此運算已針對 "a" 或 "b" 至少有一個是稀疏矩陣的情況進行最佳化,也就是說它們有很大比例的零值。在一個平台上,使用此運算與使用密集矩陣乘法的損益平衡點是稀疏矩陣中 30% 的零值。

當梯度來自 Relu 時,此運算的梯度計算才會利用輸入梯度中的稀疏性。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
transpose_a::mlir::BoolAttr布林屬性
transpose_b::mlir::BoolAttr布林屬性
a_is_sparse::mlir::BoolAttr布林屬性
b_is_sparse::mlir::BoolAttr布林屬性
Ta::mlir::Attribute衍生屬性
Tb::mlir::Attribute衍生屬性

運算元

運算元 描述
a bfloat16 或 32 位元浮點數值的張量
b bfloat16 或 32 位元浮點數值的張量

結果

結果 描述
product 32 位元浮點數值的張量

tf.SparseReduceSum (TF::SparseReduceSumOp)

計算 SparseTensor 維度上的元素總和。

此運算接受 SparseTensor,並且是 tf.reduce_sum() 的稀疏對應項。特別的是,此運算也會傳回密集 Tensor,而非稀疏 Tensor。

沿著 reduction_axes 中指定的維度縮減 sp_input。除非 keep_dims 為 true,否則張量的秩會針對 reduction_axes 中的每個項目減少 1。如果 keep_dims 為 true,則縮減後的維度會保留,長度為 1。

如果 reduction_axes 沒有項目,則會縮減所有維度,並傳回包含單一元素的張量。此外,軸可以是負數,這會根據 Python 中的索引規則進行解譯。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
input_indices 64 位元整數值的張量
input_values 數字值的張量
input_shape 64 位元整數值的張量
reduction_axes 32 位元整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.SparseReshape (TF::SparseReshapeOp)

重新塑形 SparseTensor,以表示新密集形狀中的值。

此運算的語意與所表示的密集張量上的重新塑形相同。input_indices 會根據要求的 new_shape 重新計算。

如果 new_shape 的一個元件是特殊值 -1,則會計算該維度的大小,以使總密集大小保持恆定。new_shape 最多可以有一個元件為 -1。new_shape 暗示的密集元素數量必須與 input_shape 最初暗示的密集元素數量相同。

重新塑形不會影響 SparseTensor 中值的順序。

如果輸入張量的秩為 R_in 且有 N 個非空值,且 new_shape 的長度為 R_out,則 input_indices 的形狀為 [N, R_in]input_shape 的長度為 R_inoutput_indices 的形狀為 [N, R_out],且 output_shape 的長度為 R_out

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
input_indices 64 位元整數值的張量
input_shape 64 位元整數值的張量
new_shape 64 位元整數值的張量

結果

結果 描述
output_indices 64 位元整數值的張量
output_shape 64 位元整數值的張量

tf.SparseSegmentMean (TF::SparseSegmentMeanOp)

計算張量的稀疏分段沿線的平均值。

請參閱 tf.sparse.segment_sum 以取得用法範例。

類似 SegmentMean,但 segment_ids 的秩可以小於 data 的第一個維度,從維度 0 中選取子集,由 indices 指定。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sparse_gradient::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
Tsegmentids::mlir::Attribute衍生屬性

運算元

運算元 描述
data 浮點數值的張量
indices 32/64 位元帶正負號的整數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.SparseSegmentMeanGrad (TF::SparseSegmentMeanGradOp)

計算 SparseSegmentMean 的梯度。

傳回形狀與 grad 相同的張量 "output",但維度 0 的值為 output_dim0 除外。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
Tsegmentids::mlir::Attribute衍生屬性

運算元

運算元 描述
grad 浮點數值的張量
indices 32/64 位元帶正負號的整數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
output_dim0 32 位元整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.SparseSegmentMeanWithNumSegments (TF::SparseSegmentMeanWithNumSegmentsOp)

計算張量的稀疏分段沿線的平均值。

類似 SparseSegmentMean,但允許 segment_ids 中有遺失的 ID。如果 ID 遺失,則該位置的 output 張量將會歸零。

請閱讀關於分段的章節以了解分段的說明。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sparse_gradient::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性
Tsegmentids::mlir::Attribute衍生屬性

運算元

運算元 描述
data 浮點數值的張量
indices 32/64 位元帶正負號的整數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.SparseSegmentSqrtN (TF::SparseSegmentSqrtNOp)

計算張量的稀疏分段沿線的總和,並除以 N 的平方根。

N 是要縮減的分段大小。

請參閱 tf.sparse.segment_sum 以取得用法範例。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sparse_gradient::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
Tsegmentids::mlir::Attribute衍生屬性

運算元

運算元 描述
data 浮點數值的張量
indices 32/64 位元帶正負號的整數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.SparseSegmentSqrtNGrad (TF::SparseSegmentSqrtNGradOp)

計算 SparseSegmentSqrtN 的梯度。

傳回形狀與 grad 相同的張量 "output",但維度 0 的值為 output_dim0 除外。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
Tsegmentids::mlir::Attribute衍生屬性

運算元

運算元 描述
grad 浮點數值的張量
indices 32/64 位元帶正負號的整數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
output_dim0 32 位元整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.SparseSegmentSqrtNWithNumSegments (TF::SparseSegmentSqrtNWithNumSegmentsOp)

計算張量的稀疏分段沿線的總和,並除以 N 的平方根。

N 是要縮減的分段大小。

類似 SparseSegmentSqrtN,但允許 segment_ids 中有遺失的 ID。如果 ID 遺失,則該位置的 output 張量將會歸零。

請閱讀關於分段的章節以了解分段的說明。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sparse_gradient::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性
Tsegmentids::mlir::Attribute衍生屬性

運算元

運算元 描述
data 浮點數值的張量
indices 32/64 位元帶正負號的整數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.SparseSegmentSum (TF::SparseSegmentSumOp)

計算張量的稀疏分段沿線的總和。

請閱讀關於分段的章節以了解分段的說明。

類似 SegmentSum,但 segment_ids 的秩可以小於 data 的第一個維度,從維度 0 中選取子集,由 indices 指定。

例如

c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])

# Select two rows, one segment.
tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 0]))
# => [[0 0 0 0]]

# Select two rows, two segment.
tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 1]))
# => [[ 1  2  3  4]
#     [-1 -2 -3 -4]]

# Select all rows, two segments.
tf.sparse_segment_sum(c, tf.constant([0, 1, 2]), tf.constant([0, 0, 1]))
# => [[0 0 0 0]
#     [5 6 7 8]]

# Which is equivalent to:
tf.segment_sum(c, tf.constant([0, 0, 1]))

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sparse_gradient::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性
Tsegmentids::mlir::Attribute衍生屬性

運算元

運算元 描述
data 整數或浮點數值的張量
indices 32/64 位元帶正負號的整數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.SparseSoftmaxCrossEntropyWithLogits (TF::SparseSoftmaxCrossEntropyWithLogitsOp)

計算 softmax 交叉熵成本和梯度以進行反向傳播。

SoftmaxCrossEntropyWithLogits 不同,此運算不接受標籤機率矩陣,而是針對特徵的每一列接受單一標籤。此標籤會被視為給定列的機率 1.0。

輸入是 logits,而不是機率。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tlabels::mlir::Attribute衍生屬性

運算元

運算元 描述
features 浮點數值的張量
labels 32/64 位元帶正負號的整數值的張量

結果

結果 描述
loss 浮點數值的張量
backprop 浮點數值的張量

tf.SparseTensorDenseMatMul (TF::SparseTensorDenseMatMulOp)

將 (秩為 2 的) SparseTensor "A" 乘以密集矩陣 "B"。

不會對 A 的索引執行有效性檢查。但是,建議使用下列輸入格式以獲得最佳行為

如果 adjoint_a == false:A 應以字典順序遞增排序。如果不確定,請使用 SparseReorder。如果 adjoint_a == true:A 應以維度 1 遞增的順序排序 (即「行優先」順序,而非「列優先」順序)。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
adjoint_a::mlir::BoolAttr布林屬性
adjoint_b::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
a_indices 32/64 位元帶正負號的整數值的張量
a_values tf.dtype 值的張量
a_shape 64 位元整數值的張量
b tf.dtype 值的張量

結果

結果 描述
product tf.dtype 值的張量

tf.SparseToDense (TF::SparseToDenseOp)

將稀疏表示法轉換為密集張量。

建構形狀為 output_shape 的陣列 dense,使得

# If sparse_indices is scalar
dense[i] = (i == sparse_indices ? sparse_values : default_value)

# If sparse_indices is a vector, then for each i
dense[sparse_indices[i]] = sparse_values[i]

# If sparse_indices is an n by d matrix, then for each i in [0, n)
dense[sparse_indices[i][0], ..., sparse_indices[i][d-1]] = sparse_values[i]

dense 中的所有其他值都設定為 default_value。如果 sparse_values 是純量,則所有稀疏索引都會設定為此單一值。

索引應以字典順序排序,且索引不得包含任何重複項。如果 validate_indices 為 true,則會在執行期間檢查這些屬性。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
validate_indices::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
sparse_indices 32/64 位元帶正負號的整數值的張量
output_shape 32/64 位元帶正負號的整數值的張量
sparse_values tf.dtype 值的張量
default_value tf.dtype 值的張量

結果

結果 描述
dense tf.dtype 值的張量

tf.Split (TF::SplitOp)

沿著一個維度將張量分割成 num_split 個張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
num_split::mlir::Attribute衍生屬性

運算元

運算元 描述
split_dim 32 位元整數值的張量
value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.SplitV (TF::SplitVOp)

沿著一個維度將張量分割成 num_split 個張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tlen::mlir::Attribute衍生屬性
num_split::mlir::Attribute衍生屬性

運算元

運算元 描述
value tf.dtype 值的張量
size_splits 32 位元整數、64 位元整數或 8 位元整數值的張量
split_dim 32 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.Sqrt (TF::SqrtOp)

逐元素計算 x 的平方根。

亦即,\(y = \sqrt{x} = x^{1/2}\)。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.SqrtGrad (TF::SqrtGradOp)

計算 x 的平方根相對於其輸入的梯度。

具體而言,grad = dy * 0.5 / y,其中 y = sqrt(x),且 dy 是對應的輸入梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
y 浮點數或複數值的張量
dy 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.Square (TF::SquareOp)

逐元素計算 x 的平方。

亦即,\(y = x * x = x^2\)。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.SquaredDifference (TF::SquaredDifferenceOp)

逐元素傳回 conj(x - y)(x - y)。

特性:AlwaysSpeculatableImplTraitCommutativeResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.Squeeze (TF::SqueezeOp)

從張量的形狀中移除大小為 1 的維度。

給定張量 input,此運算會傳回與所有大小為 1 的維度都已移除的相同類型的張量。如果您不想移除所有大小為 1 的維度,可以透過指定 axis 來移除特定大小為 1 的維度。

例如

# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t)) ==> [2, 3]

或者,移除特定大小為 1 的維度

# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
squeeze_dims::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.StackCloseV2 (TF::StackCloseV2Op)

從其資源容器中刪除堆疊。

運算元

運算元 描述
handle 資源值的張量

tf.StackPopV2 (TF::StackPopV2Op)

彈出堆疊頂端的元素。

屬性

屬性MLIR 類型描述
elem_type::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量

結果

結果 描述
elem tf.dtype 值的張量

tf.StackPushV2 (TF::StackPushV2Op)

將元素推入堆疊。

屬性

屬性MLIR 類型描述
swap_memory::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量
elem tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.StackV2 (TF::StackV2Op)

以先進後出順序產生元素的堆疊。

Traits: TF::UniqueResourceAllocation

Interfaces: TF_ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
elem_type::mlir::TypeAttr任何類型屬性
stack_name::mlir::StringAttr字串屬性

運算元

運算元 描述
max_size 32 位元整數值的張量

結果

結果 描述
handle 資源值的張量

tf.StatefulPartitionedCall (TF::StatefulPartitionedCallOp)

傳回 f(inputs),其中 f 的主體被放置和分割。

非同步執行函數,可能跨多個裝置但在單一進程內。核心放置和分割給定函數的底層圖,並將每個分割的子圖作為函數執行。

介面:CallOpInterfaceSymbolUserOpInterface

屬性

屬性MLIR 類型描述
f::mlir::FlatSymbolRefAttr扁平符號參考屬性
config::mlir::StringAttr字串屬性
config_proto::mlir::StringAttr字串屬性
executor_type::mlir::StringAttr字串屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.StatefulStandardNormalV2 (TF::StatefulStandardNormalV2Op)

從常態分佈輸出隨機值。

產生的值將具有平均值 0 和標準差 1。

屬性

屬性MLIR 類型描述
shape_dtype::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
algorithm 64 位元整數值的張量
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatefulTruncatedNormal (TF::StatefulTruncatedNormalOp)

從截斷常態分佈輸出隨機值。

產生的值遵循平均值為 0 且標準差為 1 的常態分佈,但幅度大於平均值 2 個標準差的值會被捨棄並重新選取。

屬性

屬性MLIR 類型描述
shape_dtype::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
algorithm 64 位元整數值的張量
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatefulUniform (TF::StatefulUniformOp)

從均勻分佈輸出隨機值。

產生的值遵循範圍 [0, 1) 中的均勻分佈。下限 0 包含在範圍中,而上限 1 排除在範圍之外。

屬性

屬性MLIR 類型描述
shape_dtype::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
algorithm 64 位元整數值的張量
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatefulUniformFullInt (TF::StatefulUniformFullIntOp)

從均勻分佈輸出隨機整數。

產生的值是涵蓋 dtype 整個範圍的均勻整數。

屬性

屬性MLIR 類型描述
shape_dtype::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
algorithm 64 位元整數值的張量
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

tf.StatefulUniformInt (TF::StatefulUniformIntOp)

從均勻分佈輸出隨機整數。

產生的值是範圍 [minval, maxval) 中的均勻整數。下限 minval 包含在範圍中,而上限 maxval 排除在範圍之外。

除非 maxval - minval 是 2 的精確冪,否則隨機整數會略有偏差。對於顯著小於輸出範圍(2^322^64)的 maxval - minval 值,偏差很小。

屬性

屬性MLIR 類型描述
shape_dtype::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
resource 資源值的張量
algorithm 64 位元整數值的張量
shape 32/64 位元帶正負號的整數值的張量
minval 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量
maxval 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

結果

結果 描述
輸出 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

tf.StatelessMultinomial (TF::StatelessMultinomialOp)

從多項式分佈中繪製樣本。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
output_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
logits 整數或浮點數值的張量
num_samples 32 位元整數值的張量
seed 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.StatelessParameterizedTruncatedNormal (TF::StatelessParameterizedTruncatedNormalOp)

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
S::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量
means 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
stddevs 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
minvals 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
maxvals 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.StatelessRandomBinomial (TF::StatelessRandomBinomialOp)

從二項式分佈輸出決定性虛擬隨機亂數。

從二項式分佈輸出隨機值。

輸出是 shapeseedcountsprobs 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
S::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量
counts 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量
probs 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.StatelessRandomGammaV2 (TF::StatelessRandomGammaV2Op)

從伽瑪分佈輸出決定性虛擬隨機亂數。

從伽瑪分佈輸出隨機值。

輸出是 shapeseedalpha 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量
alpha (Alpha) 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.StatelessRandomGetAlg (TF::StatelessRandomGetAlgOp)

根據裝置選取最佳的計數器式 RNG 演算法。

此運算會根據裝置選取最佳的計數器式 RNG 演算法。

結果

結果 描述
alg 32 位元整數值的張量

tf.StatelessRandomGetKeyCounter (TF::StatelessRandomGetKeyCounterOp)

使用根據裝置的最佳演算法,將種子打亂為金鑰和計數器。

此運算會將形狀為 [2] 的種子打亂為金鑰和計數器,計數器式 RNG 演算法都需要這兩者。打亂會使用根據裝置的最佳演算法。打亂是不透明的,但大致上符合不同種子會產生不同金鑰/計數器組 (這又會產生不同亂數) 的屬性。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tseed::mlir::Attribute衍生屬性

運算元

運算元 描述
seed 32/64 位元帶正負號的整數值的張量

結果

結果 描述
key 64 位元無符號整數值的張量
counter 64 位元無符號整數值的張量

tf.StatelessRandomGetKeyCounterAlg (TF::StatelessRandomGetKeyCounterAlgOp)

根據裝置選取最佳演算法,並將種子打亂為金鑰和計數器。

此運算會根據裝置選取最佳的計數器式 RNG 演算法,並將形狀為 [2] 的種子打亂為金鑰和計數器,計數器式演算法都需要這兩者。打亂是不透明的,但大致上符合不同種子會產生不同金鑰/計數器組 (這又會產生不同亂數) 的屬性。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tseed::mlir::Attribute衍生屬性

運算元

運算元 描述
seed 32/64 位元帶正負號的整數值的張量

結果

結果 描述
key 64 位元無符號整數值的張量
counter 64 位元無符號整數值的張量
alg 32 位元整數值的張量

tf.StatelessRandomNormal (TF::StatelessRandomNormalOp)

從常態分佈輸出決定性虛擬隨機值。

產生的值將具有平均值 0 和標準差 1。

輸出是 shapeseed 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatelessRandomNormalV2 (TF::StatelessRandomNormalV2Op)

從常態分佈輸出決定性虛擬隨機值。

產生的值將具有平均值 0 和標準差 1。

輸出是 shapekeycounteralg 的決定性函數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tshape::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
key 64 位元無符號整數值的張量
counter 64 位元無符號整數值的張量
alg 32 位元整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatelessRandomPoisson (TF::StatelessRandomPoissonOp)

從卜瓦松分佈輸出決定性虛擬隨機亂數。

從卜瓦松分佈輸出隨機值。

輸出是 shapeseedlam 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Rtype::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量
lam 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 32 位元整數或 64 位元整數值的張量

tf.StatelessRandomUniform (TF::StatelessRandomUniformOp)

從均勻分佈輸出決定性虛擬隨機值。

產生的值遵循範圍 [0, 1) 中的均勻分佈。下限 0 包含在範圍中,而上限 1 排除在範圍之外。

輸出是 shapeseed 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatelessRandomUniformFullInt (TF::StatelessRandomUniformFullIntOp)

從均勻分佈輸出決定性虛擬隨機整數。

產生的值是涵蓋 dtype 整個範圍的均勻整數。

輸出是 shapeseed 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

結果

結果 描述
輸出 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

tf.StatelessRandomUniformFullIntV2 (TF::StatelessRandomUniformFullIntV2Op)

從均勻分佈輸出決定性虛擬隨機整數。

產生的值是涵蓋 dtype 整個範圍的均勻整數。

輸出是 shapekeycounteralg 的決定性函數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tshape::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
key 64 位元無符號整數值的張量
counter 64 位元無符號整數值的張量
alg 32 位元整數值的張量

結果

結果 描述
輸出 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

tf.StatelessRandomUniformInt (TF::StatelessRandomUniformIntOp)

從均勻分佈輸出決定性虛擬隨機整數。

產生的值遵循範圍 [minval, maxval) 中的均勻分佈。

輸出是 shapeseedminvalmaxval 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量
minval 32/64 位元帶正負號的整數值的張量
maxval 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.StatelessRandomUniformIntV2 (TF::StatelessRandomUniformIntV2Op)

從均勻分佈輸出決定性虛擬隨機整數。

產生的值遵循範圍 [minval, maxval) 中的均勻分佈。

輸出是 shapekeycounteralgminvalmaxval 的決定性函數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tshape::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
key 64 位元無符號整數值的張量
counter 64 位元無符號整數值的張量
alg 32 位元整數值的張量
minval 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量
maxval 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

結果

結果 描述
輸出 32 位元整數、64 位元整數、32 位元不帶正負號的整數或 64 位元不帶正負號的整數值的張量

tf.StatelessRandomUniformV2 (TF::StatelessRandomUniformV2Op)

從均勻分佈輸出決定性虛擬隨機值。

產生的值遵循範圍 [0, 1) 中的均勻分佈。下限 0 包含在範圍中,而上限 1 排除在範圍之外。

輸出是 shapekeycounteralg 的決定性函數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tshape::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
key 64 位元無符號整數值的張量
counter 64 位元無符號整數值的張量
alg 32 位元整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatelessTruncatedNormal (TF::StatelessTruncatedNormalOp)

從截斷常態分佈輸出決定性虛擬隨機值。

產生的值遵循平均值為 0 且標準差為 1 的常態分佈,但幅度大於平均值 2 個標準差的值會被捨棄並重新選取。

輸出是 shapeseed 的決定性函數。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tseed::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
seed 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StatelessTruncatedNormalV2 (TF::StatelessTruncatedNormalV2Op)

從截斷常態分佈輸出決定性虛擬隨機值。

產生的值遵循平均值為 0 且標準差為 1 的常態分佈,但幅度大於平均值 2 個標準差的值會被捨棄並重新選取。

輸出是 shapekeycounteralg 的決定性函數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tshape::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
key 64 位元無符號整數值的張量
counter 64 位元無符號整數值的張量
alg 32 位元整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.StaticRegexFullMatch (TF::StaticRegexFullMatchOp)

檢查輸入是否符合 regex 模式。

輸入是任何形狀的字串張量。模式是要與輸入張量的每個元素比對的正規表示式。輸出張量的布林值 (True 或 False) 指出輸入是否符合提供的 regex 模式。

模式遵循 re2 語法 (https://github.com/google/re2/wiki/Syntax)

Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
pattern::mlir::StringAttr字串屬性

運算元

運算元 描述
輸入 字串值的張量

結果

結果 描述
輸出 布林值的張量

tf.StopGradient (TF::StopGradientOp)

停止梯度計算。

在圖形中執行時,此運算會按原樣輸出其輸入張量。

在建構運算以計算梯度時,此運算會防止將其輸入的貢獻納入考量。一般而言,梯度產生器會將運算新增至圖形,以透過遞迴找出促成其計算的輸入來計算指定 'loss' 的導數。如果您在此圖形中插入此運算,則其輸入會從梯度產生器中遮罩。在計算梯度時不會將它們納入考量。

每當您想要使用 TensorFlow 計算值,但需要假裝該值是常數時,這會很有用。例如,向量 x 的 softmax 函數可以寫成


  def softmax(x):
    numerator = tf.exp(x)
    denominator = tf.reduce_sum(numerator)
    return numerator / denominator

但是,如果 x 中的值很大,這很容易發生溢位。更穩定的替代方法是從每個值中減去 x 的最大值。


  def stable_softmax(x):
    z = x - tf.reduce_max(x)
    numerator = tf.exp(z)
    denominator = tf.reduce_sum(numerator)
    return numerator / denominator

但是,當我們透過 softmax 反向傳播到 x 時,我們不希望透過 tf.reduce_max(x) (如果最大值不是唯一的,則梯度可能會流向錯誤的輸入) 計算進行反向傳播,並將其視為常數。因此,我們應該將其寫成


  def stable_softmax(x):
    z = x - tf.stop_gradient(tf.reduce_max(x))
    numerator = tf.exp(z)
    denominator = tf.reduce_sum(numerator)
    return numerator / denominator

其他一些範例包括

  • EM 演算法,其中 M 步驟 不應涉及透過 E 步驟 輸出的反向傳播。
  • 波茲曼機器的對比散度訓練,其中在微分能量函數時,訓練不得透過從模型產生範例的圖形進行反向傳播。
  • 對抗式訓練,其中不應透過對抗式範例產生程序進行反向傳播。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.StoreMinibatchStatisticsInFdo (TF::StoreMinibatchStatisticsInFdoOp)

將 ID 數目和唯一 ID 儲存在 FDO 表格中。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sample_count::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_replica::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
feature_width::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
num_sc_per_chip::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性
mini_batch_splits (小批次分割)::mlir::StringAttr字串屬性

運算元

運算元 描述
program_key (程式金鑰) 字串值的張量
max_ids (最大 ID 數) 32 位元整數值的張量
max_uniques (最大不重複 ID 數) 32 位元整數值的張量

tf.StridedSlice (TF::StridedSliceOp)

input 傳回步幅式切片。

請注意,大多數 Python 使用者會想要使用 Python Tensor.__getitem__Variable.__getitem__,而不是直接使用此運算。

此運算的目標是產生一個新的張量,其中包含來自 ninput 張量的元素子集。子集是使用編碼到此函數引數中的 m 個稀疏範圍規格序列選取的。請注意,在某些情況下,m 可能等於 n,但這並非必要條件。每個範圍規格項目可以是下列其中一項

  • 省略符號 (...)。省略符號用於暗示零個或多個維度的全維度選取,並使用 ellipsis_mask 產生。例如,foo[...] 是識別切片。

  • 新的軸。這用於插入新的形狀 = 1 維度,並使用 new_axis_mask 產生。例如,foo[:, ...] (其中 foo 的形狀為 (3, 4)) 會產生 (1, 3, 4) 張量。

  • 範圍 begin:end:stride。這用於指定要從給定維度中選取多少。stride 可以是任何非零整數。begin 是一個整數,表示要選取的第一個值的索引,而 end 表示要選取的最後一個值的索引。每個維度中選取的值的數目為 end - begin (如果 stride > 0) 和 begin - end (如果 stride < 0)。beginend 可以是負數,其中 -1 是最後一個元素,-2 是倒數第二個。begin_mask 控制是否將明確給定的 begin 替換為隱含的有效值,如果 stride > 0 則為 0,如果 stride < 0 則為 -1end_mask 是類似的,但會產生建立最大開放間隔所需的數字。例如,給定形狀為 (3,) 的張量 foo[:],有效的 beginend03。請勿假設這相當於 foo[0:-1],後者的有效 beginend02。另一個範例是 foo[-2::-1],它會反轉張量的第一個維度,同時捨棄最後兩個 (在原始順序元素中)。例如,foo = [1,2,3,4]; foo[-2::-1][4,3]

  • 單一索引。這用於僅保留具有給定索引的元素。例如 (foo[2, :] 在形狀為 (5,6) 的張量上) 會產生形狀為 (6,) 的張量。這編碼在 beginend 以及 shrink_axis_mask 中。

每個概念範圍規格都編碼在運算的引數中。透過考量一個非平凡的範例,可以最好地理解此編碼。特別是,foo[1, 2:4, None, ..., :-3:-1, :] 將編碼為

begin = [1, 2, x, x, 0, x] # x denotes don't care (usually 0)
end = [2, 4, x, x, -3, x]
strides = [1, 1, x, x, -1, 1]
begin_mask = 1<<4 | 1<<5 = 48
end_mask = 1<<5 = 32
ellipsis_mask = 1<<3 = 8
new_axis_mask = 1<<2 = 4
shrink_axis_mask = 1<<0 = 1

在此情況下,如果 foo.shape 為 (5, 5, 5, 5, 5, 5),則切片的最終形狀會變成 (2, 1, 5, 5, 2, 5)。讓我們逐步瀏覽每個引數規格。

  1. 範例切片中的第一個引數會變成 begin = 1end = begin + 1 = 2。為了消除與原始規格 2:4 的歧義,我們也在 shrink_axis_mask 中設定適當的位元。

  2. 2:4 會將 2、4、1 貢獻給 begin、end 和 stride。所有遮罩都貢獻零位元。

  3. None 是 tf.newaxis 的同義詞。這表示在最終形狀中插入大小為 1 維度。虛擬值會貢獻給 begin、end 和 stride,同時設定 new_axis_mask 位元。

  4. ... 從所需數目的維度中擷取完整範圍,以完整指定輸入形狀的每個維度的切片。

  5. :-3:-1 顯示負索引的用法。與具有形狀 s 的維度相關聯的負索引 i 會轉換為正索引 s + i。因此,-1 會變成 s-1 (即最後一個元素)。此轉換會在內部完成,因此 begin、end 和 strides 會接收 x、-3 和 -1。設定適當的 begin_mask 位元以指出開始範圍是完整範圍 (忽略 x)。

  6. : 指出已選取對應維度的整個內容。這相當於 ::0::1。begin、end 和 strides 分別接收 0、0 和 1。也會設定 begin_maskend_mask 中的適當位元。

需求0 != strides[i] for i in [0, m) ellipsis_mask 必須是 2 的冪次 (只有一個省略符號)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
begin_mask::mlir::IntegerAttr64 位元無號整數屬性
end_mask::mlir::IntegerAttr64 位元無號整數屬性
ellipsis_mask::mlir::IntegerAttr64 位元無號整數屬性
new_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
shrink_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
索引::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
begin 16 位元整數或 32 位元整數或 64 位元整數值的張量
end 16 位元整數或 32 位元整數或 64 位元整數值的張量
strides 16 位元整數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.StridedSliceGrad (TF::StridedSliceGradOp)

傳回 StridedSlice 的梯度。

由於 StridedSlice 會從大小為 shapeinput 中切出片段,因此其梯度會具有相同的形狀 (此處以 shape 傳遞)。梯度在切片未選取的任何元素中都會為零。

引數與 StridedSliceGrad 相同,但 dy 是要傳播的輸入梯度,而 shapeStridedSliceinput 的形狀除外。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
begin_mask::mlir::IntegerAttr64 位元無號整數屬性
end_mask::mlir::IntegerAttr64 位元無號整數屬性
ellipsis_mask::mlir::IntegerAttr64 位元無號整數屬性
new_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
shrink_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
索引::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量
begin 32/64 位元帶正負號的整數值的張量
end 32/64 位元帶正負號的整數值的張量
strides 32/64 位元帶正負號的整數值的張量
dy tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.StringFormat (TF::StringFormatOp)

使用張量清單格式化字串範本。

使用張量清單格式化字串範本,並美觀地列印張量摘要。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
strtemplate::mlir::StringAttr字串屬性
placeholder::mlir::StringAttr字串屬性
summarize::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 字串值的張量

tf.StringJoin (TF::StringJoinOp)

將給定字串張量清單中的字串聯結成一個張量;

使用給定的分隔符號 (預設為空分隔符號)。

範例

s = ["hello", "world", "tensorflow"] tf.strings.join(s, " ")

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
separator::mlir::StringAttr字串屬性
N::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs 字串值的張量的可變參數

結果

結果 描述
輸出 字串值的張量

tf.StringStrip (TF::StringStripOp)

從張量中移除開頭和結尾的空格符。

範例

tf.strings.strip(["\nTensorFlow", " The python library "]).numpy() array([b'TensorFlow', b'The python library'], dtype=object)

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
輸入 字串值的張量

結果

結果 描述
輸出 字串值的張量

tf.StringToHashBucketFast (TF::StringToHashBucketFastOp)

將輸入張量中的每個字串轉換為其雜湊值 (以儲存桶數目取模)。

雜湊函數在程序內對字串的內容是決定性的,且永遠不會變更。但是,它不適用於密碼編譯。當 CPU 時間稀少且輸入受信任或不重要時,可以使用此函數。存在對手建構所有雜湊到相同儲存桶的輸入的風險。為了防止此問題,請使用具有 tf.string_to_hash_bucket_strong 的強式雜湊函數。

範例

tf.strings.to_hash_bucket_fast(["Hello", "TensorFlow", "2.x"], 3).numpy() array([0, 2, 2])

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_buckets::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1

運算元

運算元 描述
輸入 字串值的張量

結果

結果 描述
輸出 64 位元整數值的張量

tf.Sub (TF::SubOp)

逐元素傳回 x - y。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_CwiseBinaryTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.Sum (TF::SumOp)

計算張量維度上的元素總和。

沿著 axis 中指定的維度縮減 input。除非 keep_dims 為 true,否則張量的等級會針對 axis 中的每個項目減少 1。如果 keep_dims 為 true,則縮減的維度會保留長度 1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
keep_dims::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tidx::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 數字值的張量
reduction_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.SummaryWriter (TF::SummaryWriterOp)

傳回用於存取摘要寫入器的控制代碼。

摘要寫入器是一個圖形內資源,運算可以使用它將摘要寫入事件檔案。

writer:摘要寫入器資源。純量控制代碼。

介面:ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
shared_name::mlir::StringAttr字串屬性
container::mlir::StringAttr字串屬性

結果

結果 描述
writer 資源值的張量

tf.Svd (TF::SvdOp)

計算一個或多個矩陣的奇異值分解。

計算 input 中每個內部矩陣的 SVD,使得 input[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * transpose(v[..., :, :])

# a is a tensor containing a batch of matrices.
# s is a tensor of singular values for each matrix.
# u is the tensor containing the left singular vectors for each matrix.
# v is the tensor containing the right singular vectors for each matrix.
s, u, v = svd(a)
s, _, _ = svd(a, compute_uv=False)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
compute_uv::mlir::BoolAttr布林屬性
full_matrices::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
s 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
u 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量
v 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數值的張量

tf.SymbolicGradient (TF::SymbolicGradientOp)

透過反向傳播計算函數 f 的梯度函數。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.TakeDataset (TF::TakeDatasetOp)

建立一個資料集,其中包含來自 input_datasetcount 個元素。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性

運算元

運算元 描述
input_dataset 變體值的張量
次數 64 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.TakeWhileDataset (TF::TakeWhileDatasetOp)

建立一個在 predicate` 為 false 時停止迭代的資料集。

predicate 函數必須傳回純量布林值,並接受下列引數

  • input_dataset 元素每個元件的一個張量。
  • other_arguments 中每個值的一個張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
predicate::mlir::SymbolRefAttr符號參考屬性
output_types::mlir::ArrayAttr至少有 1 個元素的類型陣列屬性
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
metadata::mlir::StringAttr字串屬性
Targuments::mlir::Attribute衍生屬性

運算元

運算元 描述
input_dataset 變體值的張量
other_arguments tf.dtype 值的張量的可變參數

結果

結果 描述
handle 變體值的張量

tf.Tan (TF::TanOp)

逐元素計算 x 的正切。

給定輸入張量,此函數會計算張量中每個元素的正切。輸入範圍為 (-inf, inf),輸出範圍為 (-inf, inf)。如果輸入超出邊界,則會傳回 nan

  x = tf.constant([-float("inf"), -9, -0.5, 1, 1.2, 200, 10000, float("inf")])
  tf.math.tan(x) ==> [nan 0.45231566 -0.5463025 1.5574077 2.572152 -1.7925274 0.32097113 nan]

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.Tanh (TF::TanhOp)

逐元素計算 x 的雙曲正切。

給定輸入張量,此函數會計算張量中每個元素的雙曲正切。輸入範圍為 [-inf, inf],輸出範圍為 [-1,1]

x = tf.constant([-float("inf"), -5, -0.5, 1, 1.2, 2, 3, float("inf")]) tf.math.tanh(x)

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF::SameOperandsAndResultTypeResolveRefTF_LayoutAgnostic

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量

結果

結果 描述
y 浮點數或複數值的張量

tf.TanhGrad (TF::TanhGradOp)

計算 x 的雙曲正切相對於其輸入的梯度。

具體而言,grad = dy * (1 - y*y),其中 y = tanh(x),且 dy 是對應的輸入梯度。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
y 浮點數或複數值的張量
dy 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.TensorArrayCloseV3 (TF::TensorArrayCloseV3Op)

從其資源容器中刪除 TensorArray。

這讓使用者能夠在步驟/執行期間關閉並釋放資源。

運算元

運算元 描述
handle 資源值的張量

tf.TensorArrayConcatV3 (TF::TensorArrayConcatV3Op)

將 TensorArray 中的元素串連到值 value 中。

接受形狀為 T 的元素

  (n0 x d0 x d1 x ...), (n1 x d0 x d1 x ...), ..., (n(T-1) x d0 x d1 x ...)

並將它們串連成形狀為下列的張量

  (n0 + n1 + ... + n(T-1) x d0 x d1 x ...)

所有元素必須具有相同的形狀 (除了第一個維度以外)。

屬性

屬性MLIR 類型描述
element_shape_except0 (除了第 0 維度以外的元素形狀)::mlir::AttributeTensorFlow 形狀屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
value tf.dtype 值的張量
lengths (長度) 64 位元整數值的張量

tf.TensorArrayGatherV3 (TF::TensorArrayGatherV3Op)

從 TensorArray 中收集特定元素到輸出 value

indices 選取的所有元素必須具有相同的形狀。

屬性

屬性MLIR 類型描述
element_shape::mlir::AttributeTensorFlow 形狀屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量
indices 32 位元整數值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
value tf.dtype 值的張量

tf.TensorArrayGradV3 (TF::TensorArrayGradV3Op)

建立一個 TensorArray,用於儲存給定控制代碼中值的梯度。

如果給定的 TensorArray 梯度已存在,則傳回對它的參照。

透過停用原始 TensorArray 的動態大小旗標來鎖定其大小。

關於輸入 flow_in 的注意事項

控制代碼 flow_in 強制梯度查找的執行只能在某些其他操作發生之後發生。例如,當前向 TensorArray 的大小是動態調整時,寫入此 TensorArray 可能會調整物件的大小。梯度 TensorArray 的大小是根據此操作執行時前向 TensorArray 的大小靜態調整的。此外,前向 TensorArray 的大小會由此呼叫凍結。因此,flow 用於確保產生梯度 TensorArray 的呼叫僅在所有寫入執行後才會發生。

在動態調整大小的 TensorArray 的情況下,梯度計算應僅在透過 flow 本身鏈結以僅在所有寫入執行後發生的讀取操作上執行。這樣,當呼叫此操作時,前向 TensorArray 的最終大小是已知的。

關於 source 屬性的注意事項

TensorArray 梯度呼叫使用累加器 TensorArray 物件。如果計算多個梯度並在同一個會話中執行,則多個梯度節點可能會意外地流經同一個累加器 TensorArray。這會重複計算,通常會破壞 TensorArray 梯度流。

解決方案是識別此特定 TensorArray 梯度正在哪個梯度呼叫中被呼叫。這是透過從輸入梯度張量的名稱中識別唯一字串 (例如 "gradients"、"gradients_1"、...) 來執行的。此字串在建立此處的 TensorArray 梯度物件時用作字尾 (屬性 source)。

屬性 source 在執行建立/查找時會新增為前向 TensorArray 名稱的字尾,以便每個單獨的梯度計算都獲得其自己的 TensorArray 累加器。

屬性

屬性MLIR 類型描述
source (來源)::mlir::StringAttr字串屬性

運算元

運算元 描述
handle 資源值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
grad_handle (梯度控制代碼) 資源值的張量
flow_out (流出) 32 位元浮點數值的張量

tf.TensorArrayReadV3 (TF::TensorArrayReadV3Op)

從 TensorArray 中讀取一個元素到輸出 value

屬性

屬性MLIR 類型描述
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量
index 32 位元整數值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
value tf.dtype 值的張量

tf.TensorArrayScatterV3 (TF::TensorArrayScatterV3Op)

將來自輸入值的資料分散到特定的 TensorArray 元素中。

indices 必須是向量,其長度必須與 value 的第一個維度相符。

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量
indices 32 位元整數值的張量
value tf.dtype 值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
flow_out (流出) 32 位元浮點數值的張量

tf.TensorArraySizeV3 (TF::TensorArraySizeV3Op)

取得 TensorArray 的目前大小。

運算元

運算元 描述
handle 資源值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
size 32 位元整數值的張量

tf.TensorArraySplitV3 (TF::TensorArraySplitV3Op)

將來自輸入值的資料分割成 TensorArray 元素。

假設 lengths 採用值

  (n0, n1, ..., n(T-1))

value 具有形狀

  (n0 + n1 + ... + n(T-1) x d0 x d1 x ...),

這會將值分割成具有 T 個張量的 TensorArray。

TensorArray 索引 t 將是具有起始位置的值的子張量

  (n0 + n1 + ... + n(t-1), 0, 0, ...)

且具有大小

  nt x d0 x d1 x ...

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量
value tf.dtype 值的張量
lengths (長度) 64 位元整數值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
flow_out (流出) 32 位元浮點數值的張量

tf.TensorArrayV3 (TF::TensorArrayV3Op)

給定大小的張量陣列。

透過 Write 寫入資料,並透過 Read 或 Pack 讀取資料。

屬性

屬性MLIR 類型描述
dtype::mlir::TypeAttr任何類型屬性
element_shape::mlir::AttributeTensorFlow 形狀屬性
dynamic_size (動態大小)::mlir::BoolAttr布林屬性
clear_after_read (讀取後清除)::mlir::BoolAttr布林屬性
identical_element_shapes (相同的元素形狀)::mlir::BoolAttr布林屬性
tensor_array_name (張量陣列名稱)::mlir::StringAttr字串屬性

運算元

運算元 描述
size 32 位元整數值的張量

結果

結果 描述
handle 資源值的張量
flow (流) 32 位元浮點數值的張量

tf.TensorArrayWriteV3 (TF::TensorArrayWriteV3Op)

_將元素推送到 tensor_array 上。_

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
handle 資源值的張量
index 32 位元整數值的張量
value tf.dtype 值的張量
flow_in (流入) 32 位元浮點數值的張量

結果

結果 描述
flow_out (流出) 32 位元浮點數值的張量

tf.TensorListConcatV2 (TF::TensorListConcatV2Op)

沿著第 0 維度串連列表中的所有張量。

要求除了第一個維度以外,所有張量都具有相同的形狀。

input_handle: 輸入列表。 element_shape: 列表中未初始化元素的形狀。如果第一個維度不是 -1,則假定所有列表元素都具有相同的前導維度。 leading_dims: 未初始化列表元素的前導維度列表。如果 input_handle.element_shape 或 element_shape 輸入引數的前導維度尚未設定,則使用此引數。 tensor: 串連的結果。 lengths: 輸出張量,其中包含列表中張量的第 0 維度的大小,用於計算梯度。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
shape_type::mlir::Attribute衍生屬性
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
element_shape 32/64 位元帶正負號的整數值的張量
leading_dims (前導維度) 64 位元整數值的張量

結果

結果 描述
tensor tf.dtype 值的張量
lengths (長度) 64 位元整數值的張量

tf.TensorListElementShape (TF::TensorListElementShapeOp)

給定列表的元素的形狀,以張量的形式表示。

input_handle: 列表 element_shape: 列表元素的形狀

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
shape_type::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量

結果

結果 描述
element_shape 32/64 位元帶正負號的整數值的張量

tf.TensorListFromTensor (TF::TensorListFromTensorOp)

建立一個 TensorList,當堆疊時,其值為 tensor

結果列表中的每個張量都對應於輸入張量的一列。

tensor: 輸入張量。 output_handle: 列表。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
element_dtype::mlir::Attribute衍生屬性
shape_type::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量
element_shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
output_handle (輸出控制代碼) 變體值的張量

tf.TensorListGather (TF::TensorListGatherOp)

透過索引到 TensorList 中來建立張量。

產生的張量中的每一列都對應於由給定索引指定的 TensorList 中的元素 (請參閱 tf.gather)。

input_handle: 輸入張量列表。 indices: 用於索引到列表中的索引。 values: 張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
indices 32 位元整數值的張量
element_shape 32 位元整數值的張量

結果

結果 描述
values tf.dtype 值的張量

tf.TensorListGetItem (TF::TensorListGetItemOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
index 32 位元整數值的張量
element_shape 32 位元整數值的張量

結果

結果 描述
item (項目) tf.dtype 值的張量

tf.TensorListLength (TF::TensorListLengthOp)

傳回輸入張量列表中的張量數目。

input_handle: 輸入列表 length: 列表中的張量數目

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量

結果

結果 描述
length (長度) 32 位元整數值的張量

tf.TensorListPopBack (TF::TensorListPopBackOp)

傳回輸入列表的最後一個元素,以及包含除該元素之外所有元素的列表。

如果列表為空,則會失敗。

input_handle: 輸入列表 tensor: 撤回的列表最後一個元素 element_dtype: 列表中元素的類型 element_shape: 輸出張量的形狀

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
element_shape 32 位元整數值的張量

結果

結果 描述
output_handle (輸出控制代碼) 變體值的張量
tensor tf.dtype 值的張量

tf.TensorListPushBack (TF::TensorListPushBackOp)

傳回一個列表,該列表將傳入的 Tensor 作為最後一個元素,並將給定列表 input_handle 的其他元素包含在內。

tensor: 要放在列表上的張量。 input_handle: 舊列表。 output_handle: 一個列表,其中包含舊列表的元素,後跟張量。 element_dtype: 列表中元素的類型。 element_shape: 與列表中元素的形狀相容的形狀。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
tensor tf.dtype 值的張量

結果

結果 描述
output_handle (輸出控制代碼) 變體值的張量

tf.TensorListReserve (TF::TensorListReserveOp)

具有空元素的給定大小的列表。

element_shape: 列表未來元素的形狀 num_elements: 要保留的元素數目 handle: 輸出列表 element_dtype: 列表中所需元素的類型。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
shape_type::mlir::Attribute衍生屬性
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
element_shape 32/64 位元帶正負號的整數值的張量
num_elements (元素數目) 32 位元整數值的張量

結果

結果 描述
handle 變體值的張量

tf.TensorListResize (TF::TensorListResizeOp)

調整列表大小。

input_handle: 輸入列表 size: 輸出列表的大小

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
size 32 位元整數值的張量

結果

結果 描述
output_handle (輸出控制代碼) 變體值的張量

tf.TensorListScatterIntoExistingList (TF::TensorListScatterIntoExistingListOp)

將張量分散到輸入列表中的索引處。

TensorList 的每個成員都對應於輸入張量的一列,由給定索引指定 (請參閱 tf.gather)。

input_handle: 要分散到的列表。 tensor: 輸入張量。 indices: 用於索引到列表中的索引。 output_handle: TensorList。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
tensor tf.dtype 值的張量
indices 32 位元整數值的張量

結果

結果 描述
output_handle (輸出控制代碼) 變體值的張量

tf.TensorListSetItem (TF::TensorListSetItemOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
resize_if_index_out_of_bounds (如果索引超出範圍則調整大小)::mlir::BoolAttr布林屬性
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
index 32 位元整數值的張量
item (項目) tf.dtype 值的張量

結果

結果 描述
output_handle (輸出控制代碼) 變體值的張量

tf.TensorListStack (TF::TensorListStackOp)

堆疊列表中的所有張量。

要求所有張量都具有相同的形狀。

input_handle: 輸入列表 tensor: 收集的結果 num_elements: 選用。如果不是 -1,則為列表中的元素數目。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
num_elements (元素數目)::mlir::IntegerAttr64 位元無號整數屬性
element_dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
input_handle (輸入控制代碼) 變體值的張量
element_shape 32 位元整數值的張量

結果

結果 描述
tensor tf.dtype 值的張量

tf.TensorScatterAdd (TF::TensorScatterAddOp)

根據 indices 將稀疏 updates 新增至現有張量。

此操作透過將稀疏 updates 新增至傳入的 tensor 來建立新的張量。此操作與 tf.compat.v1.scatter_nd_add 非常相似,不同之處在於更新是新增到現有張量 (而不是變數) 上。如果無法重複使用現有張量的記憶體,則會建立並更新副本。

indices 是一個整數張量,其中包含索引到形狀為 tensor.shape 的新張量中的索引。 indices 的最後一個維度最多可以是 tensor.shape 的秩

indices.shape[-1] <= tensor.shape.rank

indices 的最後一個維度對應於沿著 tensor.shape 的維度 indices.shape[-1] 的元素 (如果 indices.shape[-1] = tensor.shape.rank) 或切片 (如果 indices.shape[-1] < tensor.shape.rank) 的索引。 updates 是具有形狀的張量

indices.shape[:-1] + tensor.shape[indices.shape[-1]:]

tensor_scatter_nd_add 的最簡單形式是透過索引將個別元素新增至張量。例如,假設我們要將 4 個元素新增到具有 8 個元素的秩 1 張量中。

在 Python 中,此分散相加運算看起來會像這樣

indices = tf.constant([[4], [3], [1], [7]]) updates = tf.constant([9, 10, 11, 12]) tensor = tf.ones([8], dtype=tf.int32) updated = tf.tensor_scatter_nd_add(tensor, indices, updates) updated

我們也可以一次插入較高秩張量的整個切片。例如,如果我們想要在秩 3 張量的第一個維度中插入兩個切片,並使用兩個新值矩陣。

在 Python 中,此分散相加運算看起來會像這樣

indices = tf.constant([[0], [2]]) updates = tf.constant([[[5, 5, 5, 5], [6, 6, 6, 6], ... [7, 7, 7, 7], [8, 8, 8, 8]], ... [[5, 5, 5, 5], [6, 6, 6, 6], ... [7, 7, 7, 7], [8, 8, 8, 8]]]) tensor = tf.ones([4, 4, 4],dtype=tf.int32) updated = tf.tensor_scatter_nd_add(tensor, indices, updates) updated

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TensorScatterMax (TF::TensorScatterMaxOp)

套用稀疏更新到張量,取元素方式的最大值。

傳回從 tensor 複製的新張量,其值是張量與根據索引的更新之間的元素方式最大值。

tensor = [0, 0, 0, 0, 0, 0, 0, 0] indices = [[1], [4], [5]] updates = [1, -1, 1] tf.tensor_scatter_nd_max(tensor, indices, updates).numpy() array([0, 1, 0, 0, 0, 1, 0, 0], dtype=int32)

如需更多詳細資訊,請參閱 tf.tensor_scatter_nd_update

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TensorScatterMin (TF::TensorScatterMinOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TensorScatterSub (TF::TensorScatterSubOp)

根據 indices 從現有張量中減去稀疏 updates

此操作透過從傳入的 tensor 中減去稀疏 updates 來建立新的張量。此操作與 tf.scatter_nd_sub 非常相似,不同之處在於更新是從現有張量 (而不是變數) 中減去的。如果無法重複使用現有張量的記憶體,則會建立並更新副本。

indices 是一個整數張量,其中包含索引到形狀為 shape 的新張量中的索引。 indices 的最後一個維度最多可以是 shape 的秩

indices.shape[-1] <= shape.rank

indices 的最後一個維度對應於沿著 shape 的維度 indices.shape[-1] 的元素 (如果 indices.shape[-1] = shape.rank) 或切片 (如果 indices.shape[-1] < shape.rank) 的索引。 updates 是具有形狀的張量

indices.shape[:-1] + shape[indices.shape[-1]:]

tensor_scatter_sub 的最簡單形式是透過索引從張量中減去個別元素。例如,假設我們要將 4 個分散的元素插入到具有 8 個元素的秩 1 張量中。

在 Python 中,此分散相減運算看起來會像這樣

    indices = tf.constant([[4], [3], [1], [7]])
    updates = tf.constant([9, 10, 11, 12])
    tensor = tf.ones([8], dtype=tf.int32)
    updated = tf.tensor_scatter_nd_sub(tensor, indices, updates)
    print(updated)

產生的張量會看起來像這樣

[1, -10, 1, -9, -8, 1, 1, -11]

我們也可以一次插入較高秩張量的整個切片。例如,如果我們想要在秩 3 張量的第一個維度中插入兩個切片,並使用兩個新值矩陣。

在 Python 中,此分散相加運算看起來會像這樣

    indices = tf.constant([[0], [2]])
    updates = tf.constant([[[5, 5, 5, 5], [6, 6, 6, 6],
                            [7, 7, 7, 7], [8, 8, 8, 8]],
                           [[5, 5, 5, 5], [6, 6, 6, 6],
                            [7, 7, 7, 7], [8, 8, 8, 8]]])
    tensor = tf.ones([4, 4, 4],dtype=tf.int32)
    updated = tf.tensor_scatter_nd_sub(tensor, indices, updates)
    print(updated)

產生的張量會看起來像這樣

[[[-4, -4, -4, -4], [-5, -5, -5, -5], [-6, -6, -6, -6], [-7, -7, -7, -7]],
 [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],
 [[-4, -4, -4, -4], [-5, -5, -5, -5], [-6, -6, -6, -6], [-7, -7, -7, -7]],
 [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]]

請注意,在 CPU 上,如果找到超出範圍的索引,則會傳回錯誤。在 GPU 上,如果找到超出範圍的索引,則會忽略該索引。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量
indices 32/64 位元帶正負號的整數值的張量
updates (更新) tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TensorScatterUpdate (TF::TensorScatterUpdateOp)

根據 indicesupdates 分散到現有張量中。

此操作透過將稀疏 updates 套用至傳入的 tensor 來建立新的張量。此操作與 tf.scatter_nd 非常相似,不同之處在於更新是分散到現有張量 (而不是零張量) 上。如果無法重複使用現有張量的記憶體,則會建立並更新副本。

如果 indices 包含重複項,則我們會選取索引的最後一個更新。

如果在 CPU 上找到超出範圍的索引,則會傳回錯誤。

  • 如果找到超出範圍的索引,則會忽略該索引。
  • 套用更新的順序是不確定的,因此如果 indices 包含重複項,則輸出將是不確定的。

indices 是一個整數張量,其中包含索引到形狀為 shape 的新張量中的索引。

  • indices 必須至少有 2 個軸:(num_updates, index_depth)
  • indices 的最後一個軸是要索引到 tensor 中的深度,因此此索引深度必須小於 tensor 的秩:indices.shape[-1] <= tensor.ndim

如果 indices.shape[-1] = tensor.rank,則此 Op 會索引並更新純量元素。如果 indices.shape[-1] < tensor.rank,則它會索引並更新輸入 tensor 的切片。

每個 update 的秩為 tensor.rank - indices.shape[-1]updates 的整體形狀為

indices.shape[:-1] + tensor.shape[indices.shape[-1]:]

如需使用範例,請參閱 python tf.tensor_scatter_nd_update 函數

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量
indices 16 位元整數或 32 位元整數或 64 位元整數或 16 位元無號整數值的張量
updates (更新) tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TensorSliceDataset (TF::TensorSliceDatasetOp)

建立一個資料集,該資料集會發出 components 的每個 dim-0 切片一次。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_shapes::mlir::ArrayAttr至少有 1 個元素的 tensorflow 形狀屬性陣列
is_files (是檔案)::mlir::BoolAttr布林屬性
metadata::mlir::StringAttr字串屬性
replicate_on_split::mlir::BoolAttr布林屬性
Toutput_types::mlir::Attribute衍生屬性

運算元

運算元 描述
components (組件) tf.dtype 值的張量的可變參數

結果

結果 描述
handle 變體值的張量

tf.TensorStridedSliceUpdate (TF::TensorStridedSliceUpdateOp)

value 指派給 input 的切片左值參照。

value 的值會指派給張量 input 中由切片參數選取的位置。切片參數 begin end strides 等的工作方式與 StridedSlice 完全相同。

注意:此運算目前不支援廣播,因此 value 的形狀必須與 input 的切片產生的形狀完全相同。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
begin_mask::mlir::IntegerAttr64 位元無號整數屬性
end_mask::mlir::IntegerAttr64 位元無號整數屬性
ellipsis_mask::mlir::IntegerAttr64 位元無號整數屬性
new_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
shrink_axis_mask::mlir::IntegerAttr64 位元無號整數屬性
索引::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
begin 32/64 位元帶正負號的整數值的張量
end 32/64 位元帶正負號的整數值的張量
strides 32/64 位元帶正負號的整數值的張量
value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Tile (TF::TileOp)

透過平鋪給定的張量來建構張量。

此操作透過複製 input multiples 次來建立新的張量。輸出張量的第 i 個維度具有 input.dims(i) * multiples[i] 個元素,並且 input 的值沿著第 'i' 個維度複製 multiples[i] 次。例如,將 [a b c d] 平鋪 [2] 次會產生 [a b c d a b c d]

a = tf.constant([[1,2,3],[4,5,6]], tf.int32) b = tf.constant([1,2], tf.int32) tf.tile(a, b)c = tf.constant([2,1], tf.int32) tf.tile(a, c)d = tf.constant([2,2], tf.int32) tf.tile(a, d)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tmultiples::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
multiples (倍數) 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.Timestamp (TF::TimestampOp)

提供自 epoch 以來的時間 (以秒為單位)。

將時間戳記傳回為自 Unix epoch 以來的秒數的 float64

常見用法包括

  • 記錄
  • 提供隨機數種子
  • 偵錯圖表執行
  • 產生時間資訊,主要是透過比較時間戳記

結果

結果 描述
ts 64 位元浮點數值的張量

tf.ToBool (TF::ToBoolOp)

將張量轉換為純量述詞。

使用下列規則將張量轉換為純量述詞

  • 對於 0 維張量,真值性是透過與「零」值比較來判定的。對於數值類型,它是顯而易見的零。對於字串,它是空字串。

  • 對於 >0 維張量,真值性是透過查看元素數目來判定的。如果具有零個元素,則結果為 false。否則,結果為 true。

這與 If 和 While 在判定張量是否計為分支條件的 true/false 時的行為相符。

Traits: AlwaysSpeculatableImplTrait

介面:ConditionallySpeculatableInferTypeOpInterfaceNoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 1 位元無號整數值的張量

tf.TopKUnique (TF::TopKUniqueOp)

傳回陣列中已排序的 TopK 個唯一值。

執行時間與 K 和輸入大小的乘積成正比。對於足夠大的 K 值,排序整個陣列更有效率。中位數的中位數演算法可能更快,但在 XLA 中難以有效率地實作。如果唯一數字 (非 NAN) 少於 K 個,則結果會以負無限大填補。永遠不會傳回 NAN。次正規數字會刷新為零。如果元素出現在多個索引處,則會傳回最高索引。如果 TopK 元素由於填補值而永遠不會出現在輸入中,則索引會以負一填補。如果填補值出現在輸入中且需要填補,則會傳回填補值的最高索引。語意與 kth_order_statistic 不同。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
k::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
輸入 32 位元浮點數值的張量

結果

結果 描述
topk 32 位元浮點數值的張量
topk_indices 32 位元整數值的張量

tf.TopKV2 (TF::TopKV2Op)

尋找最後一個維度的 k 個最大元素的值和索引。

如果輸入是向量 (秩 1),則尋找向量中 k 個最大條目,並將其值和索引輸出為向量。因此,values[j]input 中第 j 個最大條目,且其索引為 indices[j]

對於矩陣 (resp. 較高秩輸入),計算每列 (resp. 沿著最後一個維度的向量) 中的前 k 個條目。因此,

values.shape = indices.shape = input.shape[:-1] + [k]

如果兩個元素相等,則較低索引的元素會先出現。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sorted (已排序)::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tk::mlir::Attribute衍生屬性
index_type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 整數或浮點數值的張量
k 16 位元整數或 32 位元整數或 64 位元整數值的張量

結果

結果 描述
values 整數或浮點數值的張量
indices 16 位元整數或 32 位元整數或 64 位元整數值的張量

tf.TopKWithUnique (TF::TopKWithUniqueOp)

傳回陣列中已排序的 TopK 個值。

這是 MakeUnique 和 TopKUnique 的組合。傳回的 top-K 的較低位元將被 iota 取代,因此它將接近原始值,但並不完全相同。執行時間與 K 和輸入大小的乘積成正比。永遠不會傳回 NAN。次正規數字會刷新為零。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
k::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
輸入 32 位元浮點數值的張量

結果

結果 描述
topk 32 位元浮點數值的張量
topk_indices 32 位元整數值的張量

tf.TPUAnnotateTensorsWithDynamicShape (TF::TPUAnnotateTensorsWithDynamicShapeOp)

預留位置運算,它會取得 TPUCopyWithDynamicShapeOp 的輸出,並將它們傳遞至後續的 tpu 運算。

此運算用作動態形狀張量的註解,將在橋接重寫期間移除。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensors tf.dtype 值的張量的可變參數

結果

結果 描述
tpu_tensors tf.dtype 值的張量的可變參數

tf.TPUCompilationResult (TF::TPUCompilationResultOp)

傳回 TPU 編譯的結果。

此操作會將 TPU 編譯的結果傳回為序列化的 CompilationResultProto,如果編譯期間發生錯誤,則其中會包含狀態和錯誤訊息。

Interfaces: TF_MustExecute (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

結果

結果 描述
輸出 字串值的張量

tf.TPUCompileMlirAndExecute (TF::TPUCompileMlirAndExecuteOp)

在 MLIR 中編譯計算到 TPU 程式中,並將其載入並在 TPU 裝置上執行的運算。

供 TPU 編譯器內部使用。

'static_shapes' 是指定 dynamic_operands 中指定張量的最大維度大小的張量。 'args' 是 TPU 計算的輸入。 'operands_with_static_shape' 是具有指定最大靜態形狀的運算元索引。 'mlir_module' 是序列化的 MLIR 模組,其中包含具有目標計算的 main 函數。 'metadata' 是序列化的 TPUCompileMetadataProto,描述計算輸入的形狀和類型,以及到 TPU pod 拓撲的對應。 'producer_name' 是描述框架名稱的字串,該框架新增了對在 TPU 上執行模型此部分的支持。

Traits: AttrSizedOperandSegments

屬性

屬性MLIR 類型描述
operands_with_static_shape (具有靜態形狀的運算元)::mlir::ArrayAttr32 位元整數陣列屬性
mlir_module::mlir::StringAttr字串屬性
metadata::mlir::StringAttr字串屬性
producer_name (生產者名稱)::mlir::StringAttr字串屬性
Targs::mlir::Attribute衍生屬性
Tresults::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數
static_shapes (靜態形狀) 64 位元整數值的張量的可變參數

結果

結果 描述
rendezvous_key_base (rendezvous 金鑰基礎) tf.dtype 值的張量
results tf.dtype 值的張量的可變參數

tf.TPUCompileSucceededAssert (TF::TPUCompileSucceededAssertOp)

斷言編譯成功。

此運算不會產生任何輸出,並在失敗期間關閉裝置,以確保所有擱置的裝置互動都失敗。

'compilation_status' 是序列化的 CompilationResultProto。

Interfaces: TF_MustExecute (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

運算元

運算元 描述
compilation_status 字串值的張量

tf.TPUCopyWithDynamicShape (TF::TPUCopyWithDynamicShapeOp)

將主機張量複製到具有有界動態形狀支援的裝置的運算。

此運算將 CPU 上的填補張量複製到 TPU,而不含填補資料。 tensors 是具有填補資料的 CPU 張量列表。 unpadded_sizes 是形狀張量列表,描述每個 CPU 張量的每個維度的未填補大小。 unpadded_sizes 的大小應與 tensors 相同。它們都在主機上。 tpu_tensors 是不含填補資料的 tpu 裝置張量列表。 tpu_tensors 也具有與 tensors 相同的大小,且 tpu_tensors 的形狀由 unpadded_sizes 決定。

Traits: AlwaysSpeculatableImplTrait, AttrSizedOperandSegments

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensors tf.dtype 值的張量的可變參數
unpadded_sizes (未填補大小) 32 位元整數值的張量的變數

結果

結果 描述
tpu_tensors tf.dtype 值的張量的可變參數

tf.TPUCopyWithLayout (TF::TPUCopyWithLayoutOp)

將主機張量複製到具有指定版面配置的裝置的運算。

僅供內部使用。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
layout (版面配置) 64 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TPUEmbeddingActivations (TF::TPUEmbeddingActivationsOp)

啟用 TPU Embeddings 差異化的運算。

此運算只會傳回其第一個輸入,假設該輸入已從 TPUEmbeddingDequeueActivations 傳回的張量中切片出來。此運算的出現,以及其第一個引數是可訓練變數,可透過 TPU Embedding Python 程式庫啟用包含嵌入的圖表的自動差異化。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
table_id (表格 ID)::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
lookup_id (查找 ID)::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性

運算元

運算元 描述
embedding_variable (嵌入變數) 32 位元浮點數值的張量
sliced_activations (切片啟動) 32 位元浮點數值的張量

結果

結果 描述
輸出 32 位元浮點數值的張量

tf.TPUExecute (TF::TPUExecuteOp)

在 TPU 裝置上載入並執行 TPU 程式的運算。

供分散式 TPU 編譯器的內部使用。

Interfaces: MemoryEffectOpInterface

屬性

屬性MLIR 類型描述
Targs::mlir::Attribute衍生屬性
Tresults::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數
key 字串值的張量

結果

結果 描述
results tf.dtype 值的張量的可變參數

tf.TPUExecuteAndUpdateVariables (TF::TPUExecuteAndUpdateVariablesOp)

執行具有選用就地變數更新的程式的運算。

它 (選用) 讀取裝置變數、在 TPU 裝置上載入並執行 TPU 程式,然後 (選用) 使用程式輸出就地更新變數,如屬性 device_var_reads_indices (直接讀取變數的程式輸入索引) 和 device_var_updates_indices (用於更新變數的程式輸出索引,-1 表示無更新/唯讀) 中所指定。這些變數將會消耗這些程式輸出,而不會出現在運算輸出中。供分散式 TPU 編譯器內部使用。

Interfaces: MemoryEffectOpInterface

屬性

屬性MLIR 類型描述
device_var_reads_indices (裝置變數讀取索引)::mlir::ArrayAttr64 位元整數陣列屬性
device_var_updates_indices (裝置變數更新索引)::mlir::ArrayAttr64 位元整數陣列屬性
Targs::mlir::Attribute衍生屬性
Tresults::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數
key 字串值的張量

結果

結果 描述
results tf.dtype 值的張量的可變參數

tf.TPUGetLayoutOp (TF::TPUGetLayoutOp)

擷取由 TPUCompile 判定的輸入或輸出的版面配置的運算。

僅供內部使用。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
index::mlir::IntegerAttr64 位元無號整數屬性
is_output (是輸出)::mlir::BoolAttr布林屬性

運算元

運算元 描述
cache_key (快取金鑰) 字串值的張量

結果

結果 描述
layout (版面配置) 64 位元整數值的張量

tf.TPUOrdinalSelector (TF::TPUOrdinalSelectorOp)

TPU 核心選取器運算。

此運算產生一組 TPU 核心 (用於熱身) 或單一 TPU 核心 (用於常規推論),以在其上執行 TPU 程式。輸出由 TPUPartitionedCall 使用。

結果

結果 描述
device_ordinals (裝置序數) 32 位元整數值的張量

tf.TPUPartitionedCall (TF::TPUPartitionedCallOp)

呼叫放置在指定 TPU 裝置上的函數。

介面:CallOpInterfaceSymbolUserOpInterface

屬性

屬性MLIR 類型描述
f::mlir::SymbolRefAttr符號參考屬性
autotuner_thresh (自動調諧器閾值)::mlir::IntegerAttr64 位元無號整數屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數
device_ordinal 32 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.TPUPartitionedInput (TF::TPUPartitionedInputOp)

將分割輸入列表分組在一起的運算。此運算

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
partition_dim (分割維度)::mlir::IntegerAttr64 位元無號整數屬性
_XlaSharding::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性
N::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TPUPartitionedInputV2 (TF::TPUPartitionedInputV2Op)

將分割輸入列表分組在一起的運算。支援 ND 分片。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
partition_dims (分割維度)::mlir::ArrayAttr64 位元整數陣列屬性
is_packed (已封裝)::mlir::BoolAttr布林屬性
_XlaSharding::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性
N::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TPUPartitionedOutput (TF::TPUPartitionedOutputOp)

將要由 XLA 分片的張量解多工處理為分割列表的運算

XLA 計算之外的輸出。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
partition_dim (分割維度)::mlir::IntegerAttr64 位元無號整數屬性
_XlaSharding::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性
num_splits (分割數目)::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.TPUPartitionedOutputV2 (TF::TPUPartitionedOutputV2Op)

將要由 XLA 分片的張量解多工處理為分割列表的運算

XLA 計算之外的輸出。支援 ND 分片。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
partition_dims (分割維度)::mlir::ArrayAttr64 位元整數陣列屬性
_XlaSharding::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性
num_splits (分割數目)::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.TPUReplicatedInput (TF::TPUReplicatedInputOp)

將 N 個輸入連線到 N 向複製的 TPU 計算。

此操作保留對 tpu.replicate() 計算子圖的複製輸入。每個複製的輸入都與輸出具有相同的形狀和類型。

例如

%a = "tf.opA"()
%b = "tf.opB"()
%replicated_input = "tf.TPUReplicatedInput"(%a, %b)
%computation = "tf.Computation"(%replicated_input)

上述計算具有兩個複本的複製輸入。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
is_mirrored_variable (是鏡像變數)::mlir::BoolAttr布林屬性
index::mlir::IntegerAttr64 位元無號整數屬性
is_packed (已封裝)::mlir::BoolAttr布林屬性
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量

tf.TPUReplicatedOutput (TF::TPUReplicatedOutputOp)

從 N 向複製的 TPU 計算連線 N 個輸出。

此操作保留來自 tpu.replicate() 計算子圖的複製輸出。每個複製的輸出都與輸入具有相同的形狀和類型。

例如

%computation = "tf.Computation"()
%replicated_output:2 = "tf.TPUReplicatedOutput"(%computation)

上述計算具有兩個複本的複製輸出。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
num_replicas (複本數目)::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf.TPUReplicateMetadata (TF::TPUReplicateMetadataOp)

指示應如何複製 TPU 計算的元資料。

此操作保留 tpu.replicate() 計算子圖的運算的通用元資料。

屬性

屬性MLIR 類型描述
num_replicas (複本數目)::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
num_cores_per_replica (每個複本的核心數目)::mlir::IntegerAttr64 位元無號整數屬性
topology::mlir::StringAttr字串屬性
use_tpu (使用 TPU)::mlir::BoolAttr布林屬性
device_assignment (裝置指派)::mlir::ArrayAttr64 位元整數陣列屬性
computation_shape (計算形狀)::mlir::ArrayAttr64 位元整數陣列屬性
host_compute_core (主機計算核心)::mlir::ArrayAttr字串陣列屬性
padding_map (填補地圖)::mlir::ArrayAttr字串陣列屬性
step_marker_location (步驟標記位置)::mlir::StringAttr字串屬性
allow_soft_placement (允許軟體放置)::mlir::BoolAttr布林屬性
use_spmd_for_xla_partitioning (將 spmd 用於 xla 分割)::mlir::BoolAttr布林屬性
tpu_compile_options_proto (tpu 編譯選項原型)::mlir::StringAttr字串屬性

tf.TPUReshardVariables (TF::TPUReshardVariablesOp)

將裝置上 TPU 變數重新分片到指定狀態的運算。

將裝置上 TPU 變數重新分片到指定狀態的運算。僅供內部使用。

分片狀態表示為產生分片/取消分片程式以及主程式的編譯金鑰。 new_format_key 指定所需的狀態,而 format_state_var 是變數的目前狀態。

屬性

屬性MLIR 類型描述
N::mlir::Attribute衍生屬性

運算元

運算元 描述
vars (變數) 資源值的張量的可變參數
new_format_key (新格式金鑰) 字串值的張量
format_state_var (格式狀態變數) 資源值的張量

tf.TPURoundRobin (TF::TPURoundRobinOp)

TPU 核心上的循環配置負載平衡。

在 TPU 核心之間循環配置負載平衡的負載平衡運算。

此運算在 [0, NumTPUCoresVisiblePerHost] 中的整數之間循環配置。它適用於與 TensorFlow 運算介接,這些運算將 TPU 核心作為輸入,以在其上執行計算,例如 TPUPartitionedCall

device_ordinal: [0, NumTPUCoresVisiblePerHost] 中的整數。

結果

結果 描述
device_ordinal 32 位元整數值的張量

tf.Transpose (TF::TransposeOp)

根據排列來洗牌 x 的維度。

輸出 yx 具有相同的秩。 xy 的形狀滿足:y.shape[i] == x.shape[perm[i]] for i in [0, 1, ..., rank(x) - 1]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tperm::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
perm 32/64 位元帶正負號的整數值的張量

結果

結果 描述
y tf.dtype 值的張量

tf.TridiagonalMatMul (TF::TridiagonalMatMulOp)

計算與三對角矩陣的乘積。

計算兩個矩陣的乘積,其中左矩陣是三對角矩陣。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
superdiag (上對角線) 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量
maindiag (主對角線) 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量
subdiag (下對角線) 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量
rhs 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量

tf.TridiagonalSolve (TF::TridiagonalSolveOp)

求解三對角方程組。

求解三對角方程組。支援批次維度和每個左側的多個右側。在 CPU 上,解決方案是透過高斯消去法計算的,帶或不帶部分選主元,具體取決於 partial_pivoting 屬性。在 GPU 上,使用 Nvidia 的 cuSPARSE 程式庫:https://docs.nvidia.com/cuda/cusparse/index.html#gtsv XLA 後端尚不支援部分選主元。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
partial_pivoting (部分選主元)::mlir::BoolAttr布林屬性
perturb_singular (擾亂奇異值)::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
diagonals (對角線) 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量
rhs 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量

結果

結果 描述
輸出 128 位元複數或 64 位元複數或 32 位元浮點數或 64 位元浮點數值的張量

tf.TruncateDiv (TF::TruncateDivOp)

傳回 x / y 的元素方式除法,朝零捨入。

截斷表示負數會將小數數量朝零捨入。即 -7 / 5 = -1。這與 C 語意相符,但與 Python 語意不同。請參閱 FloorDiv 以取得與 Python 語意相符的除法函數。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
y bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
z bfloat16 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.TruncatedNormal (TF::TruncatedNormalOp)

從截斷常態分佈輸出隨機值。

產生的值遵循平均值為 0 且標準差為 1 的常態分佈,但幅度大於平均值 2 個標準差的值會被捨棄並重新選取。

Traits: TF_CannotDuplicate

屬性

屬性MLIR 類型描述
seed::mlir::IntegerAttr64 位元無號整數屬性
seed2::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.TruncateMod (TF::TruncateModOp)

回傳元素級除法餘數。這模擬 C 語義,因為

此處的結果與截斷除法一致。例如,truncate(x / y) * y + truncate_mod(x, y) = x

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或 32/64 位元帶號整數值的張量
y 浮點數或 32/64 位元帶號整數值的張量

結果

結果 描述
z 浮點數或 32/64 位元帶號整數值的張量

tf.UncompressElement (TF::UncompressElementOp)

解壓縮壓縮的資料集元素。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
output_shapes::mlir::Attribute衍生屬性
output_types::mlir::Attribute衍生屬性

運算元

運算元 描述
compressed (已壓縮) 變體值的張量

結果

結果 描述
components (組件) tf.dtype 值的張量的可變參數

tf.UniformDequantize (TF::UniformDequantizeOp)

對量化張量 input 執行反量化。

給定使用 scaleszero_points 量化的量化 input,使用公式執行反量化:dequantized_data = (quantized_data - zero_point) * scale。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
quantization_axis (量化軸)::mlir::IntegerAttr64 位元無號整數屬性
quantization_min_val (量化最小值)::mlir::IntegerAttr64 位元無號整數屬性
quantization_max_val (量化最大值)::mlir::IntegerAttr64 位元無號整數屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32 位元量化整數或 8 位元量化整數值的張量
scales (比例) 32 位元浮點數值的張量
zero_points (零點) 32 位元整數值的張量

結果

結果 描述
輸出 32 位元浮點數值的張量

tf.UniformQuantize (TF::UniformQuantizeOp)

對張量 input 執行量化。

給定 inputscaleszero_points,使用公式執行量化:quantized_data = floor(input_data * (1.0f / scale) + 0.5f) + zero_point

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
quantization_axis (量化軸)::mlir::IntegerAttr64 位元無號整數屬性
quantization_min_val (量化最小值)::mlir::IntegerAttr64 位元無號整數屬性
quantization_max_val (量化最大值)::mlir::IntegerAttr64 位元無號整數屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32 位元浮點數值的張量
scales (比例) 32 位元浮點數值的張量
zero_points (零點) 32 位元整數值的張量

結果

結果 描述
輸出 32 位元量化整數或 8 位元量化整數值的張量

tf.UniformQuantizedAdd (TF::UniformQuantizedAddOp)

對量化張量 lhs 和量化張量 rhs 執行量化相加,以產生量化 output

給定量化 lhs 和量化 rhs,對 lhsrhs 執行量化相加,以產生量化 output

UniformQuantizedAdd 遵循 Numpy 廣播規則。元素方式比較兩個輸入陣列形狀。從尾隨維度開始,兩個維度必須相等,或者其中一個維度需要為 1。

lhsrhs 必須是量化張量,其中資料值是使用公式量化的

quantized_data = clip(original_data / scale + zero_point, quantization_min_val, quantization_max_val)

output 也是量化的,使用相同的公式。

如果 lhsoutput 都是逐軸量化,則量化軸必須匹配。此外,如果 rhsoutput 都是逐軸量化,則量化軸也必須匹配。匹配 意味著在相加時軸必須匹配,考量到廣播。亦即,對於運算元 lhsrhs 而言,如果 operand.quantization_axis >= 0 且 output.quantization_axis >= 0,則 operand.dims - operand.quantization_axis 必須等於 output.dims - output.quantization_axis

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
lhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
lhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
lhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 32 位元量化整數值的張量
rhs 32 位元量化整數值的張量
lhs_scales 32 位元浮點數值的張量
lhs_zero_points 32 位元整數值的張量
rhs_scales 32 位元浮點數值的張量
rhs_zero_points 32 位元整數值的張量
output_scales 32 位元浮點數值的張量
output_zero_points 32 位元整數值的張量

結果

結果 描述
輸出 32 位元量化整數值的張量

tf.UniformQuantizedClipByValue (TF::UniformQuantizedClipByValueOp)

對量化張量 operand 執行值限幅。

給定使用 scaleszero_points 量化的量化 operand,使用 minmax 值執行值限幅。如果 quantization_axis 為 -1(逐張量量化),則使用純量 min、max 對整個運算元進行限幅。否則(逐通道量化),限幅也會逐通道完成。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
quantization_axis (量化軸)::mlir::IntegerAttr64 位元無號整數屬性
quantization_min_val (量化最小值)::mlir::IntegerAttr64 位元無號整數屬性
quantization_max_val (量化最大值)::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
operand 32 位元量化整數值的張量
min 32 位元量化整數值的張量
max 32 位元量化整數值的張量
scales (比例) 32 位元浮點數值的張量
zero_points (零點) 32 位元整數值的張量

結果

結果 描述
輸出 32 位元量化整數值的張量

tf.UniformQuantizedConvolution (TF::UniformQuantizedConvolutionOp)

對量化張量 lhs 和量化張量 rhs 執行量化卷積,以產生量化 output

給定量化 lhs 和量化 rhs,對 lhsrhs 執行量化點積,以產生量化 output

lhsrhs 必須是秩相同的張量,並滿足以下形狀條件。

  • lhs_feature % feature_group_count == 0
  • lhs_feature % rhs_input_feature == 0
  • lhs_feature / feature_group_count == rhs_input_feature
  • rhs_output_feature % feature_group_count == 0
  • lhs_batch % batch_group_count == 0
  • rhs_output_feature % batch_group_count == 0

lhsrhs 必須是量化張量,其中資料值是使用公式量化的

quantized_data = clip(original_data / scale + zero_point, quantization_min_val, quantization_max_val)

output 也是量化的,使用相同的公式。如果 rhs 是逐張量量化,則 output 也必須是逐張量量化。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
window_strides::mlir::ArrayAttr64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性
explicit_padding::mlir::ArrayAttr64 位元整數陣列屬性
lhs_dilation::mlir::ArrayAttr64 位元整數陣列屬性
rhs_dilation::mlir::ArrayAttr64 位元整數陣列屬性
batch_group_count::mlir::IntegerAttr64 位元無號整數屬性
feature_group_count::mlir::IntegerAttr64 位元無號整數屬性
dimension_numbers::mlir::StringAttr字串屬性
lhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
lhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
lhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 8 位元量化整數值的張量
rhs 8 位元量化整數值的張量
lhs_scales 32 位元浮點數值的張量
lhs_zero_points 32 位元整數值的張量
rhs_scales 32 位元浮點數值的張量
rhs_zero_points 32 位元整數值的張量
output_scales 32 位元浮點數值的張量
output_zero_points 32 位元整數值的張量

結果

結果 描述
輸出 32 位元量化整數值的張量

tf.UniformQuantizedConvolutionHybrid (TF::UniformQuantizedConvolutionHybridOp)

對浮點張量 lhs 和量化張量 rhs 執行混合精度量化卷積。

給定浮點 lhs 和量化 rhs,在內部對 lhs 執行量化,然後對量化 lhsrhs 執行量化卷積。

lhs 上的內部量化是對 Trhs 的量化,動態範圍,逐批次(沿軸 dimension_numbers.input_batch_dimension 逐軸),非對稱,且非窄範圍(範圍是 [Trhs_MIN, Trhs_MAX])。

lhsrhs 必須是秩相同的張量,並滿足以下形狀條件。

  • lhs_feature % feature_group_count == 0
  • lhs_feature % rhs_input_feature == 0
  • lhs_feature / feature_group_count == rhs_input_feature
  • rhs_output_feature % feature_group_count == 0
  • lhs_batch % batch_group_count == 0
  • rhs_output_feature % batch_group_count == 0

rhs 必須是量化張量,其中其資料值是使用以下公式量化的:quantized_data = clip(original_data / scale + zero_point, quantization_min_val, quantization_max_val)。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
window_strides::mlir::ArrayAttr64 位元整數陣列屬性
padding::mlir::StringAttr字串屬性
explicit_padding::mlir::ArrayAttr64 位元整數陣列屬性
lhs_dilation::mlir::ArrayAttr64 位元整數陣列屬性
rhs_dilation::mlir::ArrayAttr64 位元整數陣列屬性
batch_group_count::mlir::IntegerAttr64 位元無號整數屬性
feature_group_count::mlir::IntegerAttr64 位元無號整數屬性
dimension_numbers::mlir::StringAttr字串屬性
rhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
Tlhs::mlir::Attribute衍生屬性
Trhs::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 32 位元浮點數值的張量
rhs 8 位元量化整數值的張量
rhs_scales 32 位元浮點數值的張量
rhs_zero_points 32 位元整數值的張量

結果

結果 描述
輸出 32 位元浮點數值的張量

tf.UniformQuantizedDot (TF::UniformQuantizedDotOp)

對量化張量 lhs 和量化張量 rhs 執行量化點積,以產生量化 output

給定量化 lhs 和量化 rhs,對 lhsrhs 執行量化點積,以產生量化 outputlhsrhs 必須是 2D 張量,且 lhs.dim_size(1) 必須與 rhs.dim_size(0) 匹配。lhsrhs 必須是量化張量,其中資料值是使用以下公式量化的:quantized_data = clip(original_data / scale + zero_point, quantization_min_val, quantization_max_val)。output 也是量化的,使用相同的公式。如果 rhs 是逐張量量化,則 output 也必須是逐張量量化。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
lhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
lhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
lhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 8 位元量化整數值的張量
rhs 8 位元量化整數值的張量
lhs_scales 32 位元浮點數值的張量
lhs_zero_points 32 位元整數值的張量
rhs_scales 32 位元浮點數值的張量
rhs_zero_points 32 位元整數值的張量
output_scales 32 位元浮點數值的張量
output_zero_points 32 位元整數值的張量

結果

結果 描述
輸出 32 位元量化整數值的張量

tf.UniformQuantizedDotHybrid (TF::UniformQuantizedDotHybridOp)

對浮點張量 lhs 和量化張量 rhs 執行混合精度量化點積。

給定浮點 lhs 和量化 rhs,在內部對 lhs 執行量化,然後對量化 lhs 和 rhs 執行量化點積。在 lhs 上的內部量化是對 qint8 的量化,動態範圍,逐批次(沿軸 0 逐軸),非對稱,且非窄範圍(範圍是 [-128, 127])。lhsrhs 必須是 2D 張量,且 lhs.dim_size(1) 必須與 rhs.dim_size(0) 匹配。rhs 必須是量化張量,其中其資料值是使用以下公式量化的:quantized_data = clip(original_data / scale + zero_point, quantization_min_val, quantization_max_val)。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
rhs_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
rhs_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
Tlhs::mlir::Attribute衍生屬性
Trhs::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 32 位元浮點數值的張量
rhs 8 位元量化整數值的張量
rhs_scales 32 位元浮點數值的張量
rhs_zero_points 32 位元整數值的張量

結果

結果 描述
輸出 32 位元浮點數值的張量

tf.UniformRequantize (TF::UniformRequantizeOp)

給定量化張量 input,使用新的量化參數重新量化。

給定使用 {input_scales, input_zero_points, input_quantization_axis, input_quantization_min_val, input_quantization_max_val} 量化的量化張量 input,將其重新量化為使用 {output_scales, output_zero_points, output_quantization_axis, output_quantization_min_val, output_quantization_max_val} 量化的張量。重新量化是透過使用以下公式完成的:output_quantized_data = clip( (input_quantized_data - input_zero_point) * (input_scale / output_scale) + output_zero_point, output_quantization_min_val, output_quantization_max_val)

支援的逐張量和逐軸量化案例如下:

  • 逐張量 -> 逐張量
  • 逐張量 -> 逐軸
  • 逐軸 -> 逐軸,其中 input_quantization_axis 等於 output_quantization_axis。亦即,input_quantization_axis 和 output_quantization_axis 中至少有一個必須是 -1,或者兩者必須相等。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
input_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
input_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
input_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_axis::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_min_val::mlir::IntegerAttr64 位元無號整數屬性
output_quantization_max_val::mlir::IntegerAttr64 位元無號整數屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 32 位元量化整數或 8 位元量化整數值的張量
input_scales 32 位元浮點數值的張量
input_zero_points 32 位元整數值的張量
output_scales 32 位元浮點數值的張量
output_zero_points 32 位元整數值的張量

結果

結果 描述
輸出 32 位元量化整數或 8 位元量化整數值的張量

tf.Unique (TF::UniqueOp)

在 1-D 張量中尋找唯一元素。

此運算會傳回一個張量 y,其中包含 x 的所有唯一元素,並以它們在 x 中出現的相同順序排序;x 不需要排序。此運算也會傳回一個與 x 大小相同的張量 idx,其中包含 x 的每個值在唯一輸出 y 中的索引。換句話說

y[idx[i]] = x[i] 對於 i 在 [0, 1,...,rank(x) - 1] 中

範例

# tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx = unique(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]
# tensor 'x' is [4, 5, 1, 2, 3, 3, 4, 5]
y, idx = unique(x)
y ==> [4, 5, 1, 2, 3]
idx ==> [0, 1, 2, 3, 4, 4, 0, 1]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
out_idx (輸出索引)::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量

結果

結果 描述
y tf.dtype 值的張量
idx (索引) 32/64 位元帶正負號的整數值的張量

tf.UniqueV2 (TF::UniqueV2Op)

沿張量的軸尋找唯一元素。

此運算會傳回一個張量 y,其中包含沿張量的 axis 的唯一元素。傳回的唯一元素會以它們沿 x 中的 axis 出現的相同順序排序。此運算也會傳回一個張量 idx,其大小與 x 中沿 axis 維度的元素數量相同。它包含唯一輸出 y 中的索引。換句話說,對於具有 `axis = None 的 1-D 張量 x

y[idx[i]] = x[i] 對於 i 在 [0, 1,...,rank(x) - 1] 中

例如

# tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx = unique(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]

對於具有 axis = 02-D 張量 x

# tensor 'x' is [[1, 0, 0],
#                [1, 0, 0],
#                [2, 0, 0]]
y, idx = unique(x, axis=0)
y ==> [[1, 0, 0],
       [2, 0, 0]]
idx ==> [0, 0, 1]

對於具有 axis = 12-D 張量 x

# tensor 'x' is [[1, 0, 0],
#                [1, 0, 0],
#                [2, 0, 0]]
y, idx = unique(x, axis=1)
y ==> [[1, 0],
       [1, 0],
       [2, 0]]
idx ==> [0, 1, 1]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Taxis::mlir::Attribute衍生屬性
out_idx (輸出索引)::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量
axis 32/64 位元帶正負號的整數值的張量

結果

結果 描述
y tf.dtype 值的張量
idx (索引) 32/64 位元帶正負號的整數值的張量

tf.Unpack (TF::UnpackOp)

將秩-R 張量的給定維度解包為 num 個秩-(R-1) 張量。

透過沿 axis 維度切分 value,從 value 解包 num 個張量。例如,給定形狀為 (A, B, C, D) 的張量;

如果 axis == 0,則 output 中的第 i 個張量是切片 value[i, :, :, :],且 output 中的每個張量都將具有形狀 (B, C, D)。(請注意,與 split 不同,沿其解包的維度已消失)。

如果 axis == 1,則 output 中的第 i 個張量是切片 value[:, i, :, :],且 output 中的每個張量都將具有形狀 (A, C, D)。等等。

這是 pack 的相反操作。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
axis::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性
num (數量)::mlir::Attribute衍生屬性

運算元

運算元 描述
value tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.UnsortedSegmentMax (TF::UnsortedSegmentMaxOp)

計算張量分段的最大值。

請閱讀關於分段的章節以了解分段的說明。

此運算子類似於 tf.math.unsorted_segment_sum,但它不是計算段的總和,而是計算最大值,使得

\(output_i = \max_{j...} data[j...]\) 其中 max 是在元組 j... 上的最大值,使得 segment_ids[j...] == i

如果給定的分段 ID i 的最大值為空,它會輸出特定數值類型的最小值,output[i] = numeric_limits<T>::lowest()

如果給定的段 ID i 為負數,則會捨棄對應的值,且不會包含在結果中。

例如

c = tf.constant([[1,2,3,4], [5,6,7,8], [4,3,2,1]]) tf.math.unsorted_segment_max(c, tf.constant([0, 1, 0]), num_segments=2).numpy() array([[4, 3, 3, 4], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 整數或浮點數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.UnsortedSegmentMin (TF::UnsortedSegmentMinOp)

計算張量分段的最小值。

請閱讀關於分段的章節以了解分段的說明。

此運算子類似於 tf.math.unsorted_segment_sum,但它不是計算段的總和,而是計算最小值,使得

\(output_i = \min_{j...} data_[j...]\) 其中 min 是在元組 j... 上的最小值,使得 segment_ids[j...] == i

如果給定的分段 ID i 的最小值為空,它會輸出特定數值類型的最大值,output[i] = numeric_limits<T>::max()

例如

c = tf.constant([[1,2,3,4], [5,6,7,8], [4,3,2,1]]) tf.math.unsorted_segment_min(c, tf.constant([0, 1, 0]), num_segments=2).numpy() array([[1, 2, 2, 1], [5, 6, 7, 8]], dtype=int32)

如果給定的段 ID i 為負數,則會捨棄對應的值,且不會包含在結果中。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 整數或浮點數值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 整數或浮點數值的張量

tf.UnsortedSegmentProd (TF::UnsortedSegmentProdOp)

計算張量分段的乘積。

請閱讀關於分段的章節以了解分段的說明。

此運算子類似於 tf.math.unsorted_segment_sum,但它不是計算段的總和,而是計算屬於某個段的所有項目的乘積,使得

\(output_i = \prod_{j...} data[j...]\) 其中乘積是在元組 j... 上的乘積,使得 segment_ids[j...] == i

例如

c = tf.constant([[1,2,3,4], [5,6,7,8], [4,3,2,1]]) tf.math.unsorted_segment_prod(c, tf.constant([0, 1, 0]), num_segments=2).numpy() array([[4, 6, 6, 4], [5, 6, 7, 8]], dtype=int32)

如果給定的段 ID i 沒有任何項目,則會輸出 1。

如果給定的段 ID i 為負數,則會捨棄對應的值,且不會包含在結果中。注意:在 CPU 上,始終會驗證 segment_ids 中的值是否小於 num_segments,且對於超出範圍的索引會擲回錯誤。在 GPU 上,對於超出範圍的索引,這不會擲回錯誤。在 Gpu 上,超出範圍的索引會導致安全但不明確的行為,其中可能包括忽略超出範圍的索引,或在 num_segments 為 0 時輸出在形狀的第一個維度中儲存 0 的張量。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 數字值的張量
segment_ids 32/64 位元帶正負號的整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.UnsortedSegmentSum (TF::UnsortedSegmentSumOp)

計算張量分段的總和。

請閱讀關於分段的章節以了解分段的說明。

計算一個張量,使得 \(output[i] = \sum_{j...} data[j...]\) 其中總和是在元組 j... 上的總和,使得 segment_ids[j...] == i。與 SegmentSum 不同,segment_ids 不需要排序,也不需要涵蓋有效值完整範圍中的所有值。

如果給定的段 ID i 的總和為空,則 output[i] = 0。如果給定的段 ID i 為負數,則會捨棄該值,且不會將其加到段的總和中。

num_segments 應等於不同的段 ID 的數量。

c = [[1,2,3,4], [5,6,7,8], [4,3,2,1]] tf.math.unsorted_segment_sum(c, [0, 1, 0], num_segments=2).numpy() array([[5, 5, 5, 5], [5, 6, 7, 8]], dtype=int32)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
Tnumsegments::mlir::Attribute衍生屬性

運算元

運算元 描述
data 數字值的張量
segment_ids 16 位元整數或 32 位元整數或 64 位元整數值的張量
num_segments 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.UpperBound (TF::UpperBoundOp)

_沿著每一列套用 upper_bound(sorted_search_values, values)。_

在 (sorted_inputs, values) 中具有相同索引的每一組列都會被獨立處理。產生的列等同於呼叫 np.searchsorted(sorted_inputs, values, side='right')

結果不是整個 Tensor 的全域索引,而只是最後一個維度中的索引。

二維範例:sorted_sequence = [[0, 3, 9, 9, 10], [1, 2, 3, 4, 5]] values = [[2, 4, 9], [0, 2, 6]]

result = UpperBound(sorted_sequence, values)

result == [[1, 2, 4], [0, 2, 5]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
sorted_inputs tf.dtype 值的張量
values tf.dtype 值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.VarHandleOp (TF::VarHandleOp)

從變數資源的名稱建立其控制代碼。

container:此變數放置在其中的容器。shared_name:此變數被引用的名稱。dtype 和 shape:代表變數中保存的資料類型和形狀的屬性。

範例:resource_variable_ops.var_handle_op( dtype=dtypes.int32, shape=[8, 16], container="foo", shared_name="bar") 傳回容器 "foo" 中名稱為 "bar" 的變數的控制代碼,且該變數保存形狀為 [8, 16] 和 dtype int32 的張量。

介面:ResourceHandleAllocatorInterface

屬性

屬性MLIR 類型描述
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
dtype::mlir::Attribute衍生屬性
shape::mlir::Attribute衍生屬性

結果

結果 描述
resource 資源值的張量

tf.Variable (TF::VariableOp)

請改用 VariableV2。

屬性

屬性MLIR 類型描述
shape::mlir::AttributeTensorFlow 形狀屬性
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
dtype::mlir::Attribute衍生屬性

結果

結果 描述
ref tf.dtype 值的張量

tf.VariableShape (TF::VariableShapeOp)

傳回 resource 指向的變數的形狀。

此運算會傳回一個一維整數張量,表示 input 的形狀。

例如

# 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]
shape(t) ==> [2, 2, 3]

屬性

屬性MLIR 類型描述
out_type::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 資源值的張量

結果

結果 描述
輸出 32/64 位元帶正負號的整數值的張量

tf.VariableV2 (TF::VariableV2Op)

以跨步驟持續存在的張量形式保存狀態。

輸出張量狀態的參照,以便可以讀取或修改它。TODO(zhifengc/mrry):新增指向更詳細說明文件(關於在 tensorflow 中共享狀態)的指標。

屬性

屬性MLIR 類型描述
shape::mlir::AttributeTensorFlow 形狀屬性
container::mlir::StringAttr字串屬性
shared_name::mlir::StringAttr字串屬性
dtype::mlir::Attribute衍生屬性

結果

結果 描述
ref tf.dtype 值的張量

tf.VarIsInitializedOp (TF::VarIsInitializedOp)

檢查基於資源控制代碼的變數是否已初始化。

運算元

運算元 描述
resource 資源值的張量

結果

結果 描述
is_initialized 布林值的張量

tf.Where (TF::WhereOp)

傳回張量中非零值/true 值的位置。

此運算會傳回 condition 中 true 元素的座標。座標會以 2-D 張量傳回,其中第一個維度(列)代表 true 元素的數量,第二個維度(行)代表 true 元素的座標。請記住,輸出張量的形狀可能會根據 condition 中 true 值的數量而有所不同。索引會以列優先順序輸出。

例如

# 'input' tensor is [[True, False]
#                    [True, False]]
# 'input' has two true values, so output has two coordinates.
# 'input' has rank of 2, so coordinates have two indices.
where(input) ==> [[0, 0],
                  [1, 0]]

# `condition` tensor is [[[True, False]
#                     [True, False]]
#                    [[False, True]
#                     [False, True]]
#                    [[False, False]
#                     [False, True]]]
# 'input' has 5 true values, so output has 5 coordinates.
# 'input' has rank of 3, so coordinates have three indices.
where(input) ==> [[0, 0, 0],
                  [0, 1, 0],
                  [1, 0, 1],
                  [1, 1, 1],
                  [2, 1, 1]]

# `condition` tensor is [[[1.5,  0.0]
#                     [-0.5, 0.0]]
#                    [[0.0,  0.25]
#                     [0.0,  0.75]]
#                    [[0.0,  0.0]
#                     [0.0,  0.01]]]
# 'input' has 5 nonzero values, so output has 5 coordinates.
# 'input' has rank of 3, so coordinates have three indices.
where(input) ==> [[0, 0, 0],
                  [0, 1, 0],
                  [1, 0, 1],
                  [1, 1, 1],
                  [2, 1, 1]]

# `condition` tensor is [[[1.5 + 0.0j, 0.0  + 0.0j]
#                     [0.0 + 0.5j, 0.0  + 0.0j]]
#                    [[0.0 + 0.0j, 0.25 + 1.5j]
#                     [0.0 + 0.0j, 0.75 + 0.0j]]
#                    [[0.0 + 0.0j, 0.0  + 0.0j]
#                     [0.0 + 0.0j, 0.01 + 0.0j]]]
# 'input' has 5 nonzero magnitude values, so output has 5 coordinates.
# 'input' has rank of 3, so coordinates have three indices.
where(input) ==> [[0, 0, 0],
                  [0, 1, 0],
                  [1, 0, 1],
                  [1, 1, 1],
                  [2, 1, 1]]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
index 64 位元整數值的張量

tf.While (TF::WhileOp)

Output = input; While (Cond(output)) { output = Body(output) }

output = input; While (Cond(output)) { output = Body(output) }

input:類型為 T 的輸入張量清單。output:類型為 T 的輸出張量清單。cond:一個函數,它接受 'input' 並傳回一個張量。如果張量是非布林值的純量,則根據以下規則將純量轉換為布林值:如果純量是數值,則非零表示 True,零表示 False;如果純量是字串,則非空表示 True,空表示 False。如果張量不是純量,則非空表示 True,否則表示 False。body:一個函數,它接受張量清單並傳回另一個張量清單。這兩個清單都具有 T 指定的相同類型。

介面:SymbolUserOpInterface

屬性

屬性MLIR 類型描述
cond (條件)::mlir::FlatSymbolRefAttr扁平符號參考屬性
body::mlir::FlatSymbolRefAttr扁平符號參考屬性
parallel_iterations::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
is_stateless::mlir::BoolAttr布林屬性
shape_invariant::mlir::UnitAttrunit 屬性
T::mlir::Attribute衍生屬性
output_shapes::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.WhileRegion (TF::WhileRegionOp)

While 運算

tf.WhileRegion 運算使用 2 個區域和一組迭代變數來表示 while 迴圈。此 Op 維護的迭代變數具有與輸入相同的類型。此 Op 執行由以下虛擬碼描述的 while 迴圈

   func WhileRegionOp(inputs) {
     iteration_vars = inputs;
     while (cond(iteration_vars)) {
         iteration_vars = body(iteration_vars);
     }
     return iteration_vars;
   }

cond 是條件區域,body 是主體區域。這兩個區域都接受迭代變數的目前值作為輸入。

條件區域產生一個張量如果為 false,則會結束迴圈。它也可以選擇性地額外產生迭代變數,這些變數必須保持不變。

主體區域始終必須產生(可能已更新的)迭代變數。

迭代變數會初始化為 Op 輸入,且 tf.WhileRegion 運算的結果是迭代變數的最終值。

這表示 tf.WhileRegion 的運算元和結果類型應相同。請注意,條件和主體區域可以隱含地直接捕獲迴圈不變值。在標準形式中,通過迴圈主體未修改的迭代變數會轉換為對迴圈外部值的隱含捕獲參照。

特性:SingleBlockImplicitTerminator<YieldOp>SingleBlock

介面:LoopLikeOpInterfaceRegionBranchOpInterface

屬性

屬性MLIR 類型描述
parallel_iterations::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
is_stateless::mlir::BoolAttr布林屬性
shape_invariant::mlir::UnitAttrunit 屬性

運算元

運算元 描述
輸入 任何類型值的張量的可變參數

結果

結果 描述
輸出 任何類型值的張量的可變參數

tf.WriteAudioSummary (TF::WriteAudioSummaryOp)

寫入具有音訊的 Summary 協議緩衝區。

摘要最多具有 max_outputs 個摘要值,其中包含音訊。音訊是從 tensor 建構的,tensor 必須是 3-D 形狀為 [batch_size, frames, channels] 或 2-D 形狀為 [batch_size, frames]。這些值假設在 [-1.0, 1.0] 範圍內,取樣率為 sample_rate

tag 引數是 string 類型的純量 Tensor。它用於建構摘要值的 tag

  • 如果 max_outputs 為 1,則摘要值標籤為 'tag/audio'。
  • 如果 max_outputs 大於 1,則摘要值標籤會循序產生為 'tag/audio/0'、'tag/audio/1' 等。

writer:摘要寫入器的控制代碼。step:要寫入摘要的步驟。tag:純量。用於建構摘要值的 tag 屬性。tensor:2-D 形狀為 [batch_size, frames]。sample_rate:訊號的取樣率,單位為赫茲。max_outputs:要為其產生音訊的最大批次元素數。

屬性

屬性MLIR 類型描述
max_outputs::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1

運算元

運算元 描述
writer 資源值的張量
step 64 位元整數值的張量
tag 字串值的張量
tensor 32 位元浮點數值的張量
sample_rate 32 位元浮點數值的張量

tf.WriteGraphSummary (TF::WriteGraphSummaryOp)

GraphDef 協議緩衝區寫入 SummaryWriter

writer:SummaryWriter 的控制代碼。step:要寫入摘要的步驟。tensor:序列化 tf.GraphDef proto 的純量字串。

運算元

運算元 描述
writer 資源值的張量
step 64 位元整數值的張量
tensor 字串值的張量

tf.WriteHistogramSummary (TF::WriteHistogramSummaryOp)

寫入直方圖摘要。

產生的 Summary 具有一個摘要值,其中包含 values 的直方圖。

如果任何值不是有限值,則此運算會報告 InvalidArgument 錯誤。

writer:摘要寫入器的控制代碼。step:要寫入摘要的步驟。tag:純量。用於 Summary.Value 的標籤。values:任何形狀。用於建構直方圖的值。

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
writer 資源值的張量
step 64 位元整數值的張量
tag 字串值的張量
values 整數或浮點數值的張量

tf.WriteImageSummary (TF::WriteImageSummaryOp)

寫入具有影像的 Summary 協議緩衝區。

摘要最多具有 max_images 個摘要值,其中包含影像。影像是從 tensor 建構的,tensor 必須是 4-D 形狀為 [batch_size, height, width, channels],且其中 channels 可以是

  • 1:tensor 解釋為灰階。
  • 3:tensor 解釋為 RGB。
  • 4:tensor 解釋為 RGBA。

影像具有與輸入張量相同的通道數。對於浮點輸入,值會一次正規化一個影像,以適合 [0, 255] 範圍。uint8 值保持不變。此運算使用兩種不同的正規化演算法

  • 如果輸入值均為正數,則會重新縮放它們,使最大值為 255。

  • 如果任何輸入值為負數,則會移動這些值,使輸入值 0.0 位於 127。然後會重新縮放它們,使最小值為 0,或最大值為 255。

tag 引數是 string 類型的純量 Tensor。它用於建構摘要值的 tag

  • 如果 max_images 為 1,則摘要值標籤為 'tag/image'。
  • 如果 max_images 大於 1,則摘要值標籤會循序產生為 'tag/image/0'、'tag/image/1' 等。

bad_color 引數是用於在產生的影像中針對非有限輸入值使用的顏色。它是長度為 channelsunit8 1-D 張量。每個元素都必須在 [0, 255] 範圍內(它代表輸出影像中像素的值)。輸入張量中的非有限值會在此輸出影像中由這個張量取代。預設值為紅色。

writer:摘要寫入器的控制代碼。step:要寫入摘要的步驟。tag:純量。用於建構摘要值的 tag 屬性。tensor:4-D 形狀為 [batch_size, height, width, channels],其中 channels 為 1、3 或 4。max_images:要為其產生影像的最大批次元素數。bad_color:用於具有非有限值的像素的顏色。

屬性

屬性MLIR 類型描述
max_images::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
T::mlir::Attribute衍生屬性

運算元

運算元 描述
writer 資源值的張量
step 64 位元整數值的張量
tag 字串值的張量
tensor 16 位元浮點或 32 位元浮點或 8 位元不帶正負號整數值的張量
bad_color 8 位元無號整數值的張量

tf.WriteRawProtoSummary (TF::WriteRawProtoSummaryOp)

寫入具有序列化字串 Summary 協議緩衝區的 Summary 協議緩衝區。

writer:摘要寫入器的控制代碼。step:要寫入摘要的步驟。tensor:保存要寫入的一個或多個序列化 Summary protobuf 的張量。

運算元

運算元 描述
writer 資源值的張量
step 64 位元整數值的張量
tensor 字串值的張量

tf.WriteScalarSummary (TF::WriteScalarSummaryOp)

寫入具有純量值的 Summary 協議緩衝區。

輸入 tagvalue 必須具有純量。

writer:摘要寫入器的控制代碼。step:要寫入摘要的步驟。tag:摘要的標籤。value:摘要的值。

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
writer 資源值的張量
step 64 位元整數值的張量
tag 字串值的張量
value 整數或浮點數值的張量

tf.WriteSummary (TF::WriteSummaryOp)

輸出具有張量的 Summary 協議緩衝區。

writer:摘要寫入器的控制代碼。step:要寫入摘要的步驟。tensor:要序列化的張量。tag:摘要的標籤。summary_metadata:序列化的 SummaryMetadata 協議緩衝區,其中包含此摘要的外掛程式相關元數據。

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
writer 資源值的張量
step 64 位元整數值的張量
tensor tf.dtype 值的張量
tag 字串值的張量
summary_metadata 字串值的張量

tf.WriteTrainingPredictions (TF::WriteTrainingPredictionsOp)

使用先前初始化的全域 TrainingPredictionWriter,將給定的預測寫入 RecordIO 檔案。

預測會轉換為 PredictionData proto,然後再寫入檔案。

Interfaces: MemoryEffectOpInterface

屬性

屬性MLIR 類型描述
prediction_names::mlir::ArrayAttr字串陣列屬性
training::mlir::BoolAttr布林屬性
file_path::mlir::StringAttr字串屬性
num_predictions::mlir::Attribute衍生屬性

運算元

運算元 描述
keys (鍵) 字串值的張量
predictions_list 32 位元浮點數值的張量的可變參數
step 64 位元整數值的張量
timestamp_usec 64 位元整數值的張量

tf.Xdivy (TF::XdivyOp)

如果 x == 0,則傳回 0,否則傳回 x / y,逐元素。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量
y 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.XlaAllReduce (TF::XlaAllReduceOp)

包裝 XLA AllReduce 運算子

文件位於 https://tensorflow.dev.org.tw/xla/operation_semantics#allreduce

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
reduce_op::mlir::StringAttr字串屬性,其值為 Min、Max、Mul、Add 或 Mean
mode::mlir::StringAttr字串屬性,其值為 CrossReplica 或 CrossReplicaAndPartition
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點或 32 位元浮點或 32 位元整數或 32 位元不帶正負號整數值的張量
group_assignment 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點或 32 位元浮點或 32 位元整數或 32 位元不帶正負號整數值的張量

tf.XlaBroadcastHelper (TF::XlaBroadcastHelperOp)

用於執行 XLA 樣式廣播的輔助運算子

透過將大小為 1 的維度新增至 lhsrhs 中秩較低的那個,使用 XLA 的二元運算子廣播規則,將 lhsrhs 廣播到相同的秩。

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF_NoConstantFold

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 數字值的張量
rhs 數字值的張量
broadcast_dims 32/64 位元帶正負號的整數值的張量

結果

結果 描述
lhs_output 數字值的張量
rhs_output 數字值的張量

tf.XlaCallModule (TF::XlaCallModuleOp)

叫用 StableHLO 模組。

此運算子與 JAX 原生序列化一起在具有穩定性保證的 TensorFlow 環境中使用。

介面:MemoryEffectOpInterfaceSymbolUserOpInterface

屬性

屬性MLIR 類型描述
version::mlir::IntegerAttr64 位元無號整數屬性
module::mlir::StringAttr字串屬性
Sout::mlir::ArrayAttrtensorflow 形狀屬性陣列
dim_args_spec::mlir::ArrayAttr字串陣列屬性
platforms::mlir::ArrayAttr字串陣列屬性
function_list::mlir::ArrayAttrtensorflow 符號參照陣列屬性
has_token_input_output::mlir::BoolAttr布林屬性
disabled_checks::mlir::ArrayAttr字串陣列屬性
Tin::mlir::Attribute衍生屬性
Tout::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.XlaClusterOutput (TF::XlaClusterOutputOp)

將 XLA 計算的輸出連接到其他消費者圖形節點的運算子。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
outputs tf.dtype 值的張量

tf.XlaConv (TF::XlaConvOp)

包裝 XLA ConvGeneralDilated 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#conv_convolution .

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimension_numbers::mlir::StringAttr字串屬性
precision_config::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 數字值的張量
rhs 數字值的張量
window_strides 32/64 位元帶正負號的整數值的張量
padding 32/64 位元帶正負號的整數值的張量
lhs_dilation 32/64 位元帶正負號的整數值的張量
rhs_dilation 32/64 位元帶正負號的整數值的張量
feature_group_count 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.XlaConvV2 (TF::XlaConvV2Op)

包裝 XLA ConvGeneralDilated 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#conv_convolution .

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimension_numbers::mlir::StringAttr字串屬性
precision_config::mlir::StringAttr字串屬性
batch_group_count::mlir::IntegerAttr64 位元無號整數屬性
LhsT::mlir::Attribute衍生屬性
RhsT::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性
preferred_element_type::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 數字值的張量
rhs 數字值的張量
window_strides 32/64 位元帶正負號的整數值的張量
padding 32/64 位元帶正負號的整數值的張量
lhs_dilation 32/64 位元帶正負號的整數值的張量
rhs_dilation 32/64 位元帶正負號的整數值的張量
feature_group_count 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 數字值的張量

tf.XlaCustomCallV2 (TF::XlaCustomCallV2Op)

發出具有多個輸出的 HLO CustomCall 運算。

XlaCustomCall 相反,此運算支援多個輸出。

請參閱 https://tensorflow.dev.org.tw/xla/operation_semantics#customcall,CustomCall 規格,以及 https://tensorflow.dev.org.tw/mlir/hlo_ops#mhlocustom_call_mlirmhlocustomcallopmhlo.custom_call 規格

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
call_target_name::mlir::StringAttr字串屬性
backend_config::mlir::StringAttr字串屬性
has_side_effect::mlir::BoolAttr布林屬性
result_shapes::mlir::ArrayAttrtensorflow 形狀屬性陣列
operand_dtypes::mlir::Attribute衍生屬性
result_dtypes::mlir::Attribute衍生屬性

運算元

運算元 描述
operands tf.dtype 值的張量的可變參數

結果

結果 描述
results tf.dtype 值的張量的可變參數

tf.XlaDot (TF::XlaDotOp)

包裝 XLA DotGeneral 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#dotgeneral .

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimension_numbers::mlir::StringAttr字串屬性
precision_config::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 數字值的張量
rhs 數字值的張量

結果

結果 描述
輸出 數字值的張量

tf.XlaDotV2 (TF::XlaDotV2Op)

包裝 XLA DotGeneral 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#dotgeneral .

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimension_numbers::mlir::StringAttr字串屬性
precision_config::mlir::StringAttr字串屬性
LhsT::mlir::Attribute衍生屬性
RhsT::mlir::Attribute衍生屬性
preferred_element_type::mlir::Attribute衍生屬性

運算元

運算元 描述
lhs 數字值的張量
rhs 數字值的張量

結果

結果 描述
輸出 數字值的張量

tf.XlaDynamicSlice (TF::XlaDynamicSliceOp)

包裝 XLA DynamicSlice 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#dynamicslice .

DynamicSlice 從輸入陣列中以動態 start_indices 擷取子陣列。每個維度中切片的大小在 size_indices 中傳遞,size_indices 指定每個維度中獨佔切片間隔的終點 -- [start, start + size)。start_indices 的形狀必須具有秩 1,且維度大小等於運算元的秩。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
start_indices 32/64 位元帶正負號的整數值的張量
size_indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaDynamicUpdateSlice (TF::XlaDynamicUpdateSliceOp)

包裝 XLA DynamicUpdateSlice 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#dynamicupdateslice .

XlaDynamicUpdateSlice 產生一個結果,它是 input 運算元的值,並在 indices 覆寫切片更新。update 的形狀決定了結果的子陣列的形狀,該子陣列會被更新。indices 的形狀必須為秩 == 1,且維度大小等於 input 的秩。

超出範圍的切片索引的處理方式是實作定義的。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
update tf.dtype 值的張量
indices 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaEinsum (TF::XlaEinsumOp)

一個支援具有 2 個輸入和 1 個輸出的基本 einsum 運算的運算子。

此運算子具有更好的 TPU 效能,因為它沒有像 tf.einsum 那樣明確地 reshape 和 transpose 運算。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
equation::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a bfloat16 或 64 位元複數或 32 位元浮點值的張量
b bfloat16 或 64 位元複數或 32 位元浮點值的張量

結果

結果 描述
product bfloat16 或 64 位元複數或 32 位元浮點值的張量

tf.XlaGather (TF::XlaGatherOp)

包裝 XLA Gather 運算子,文件位於

https://tensorflow.dev.org.tw/xla/operation_semantics#gather

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimension_numbers::mlir::StringAttr字串屬性
indices_are_sorted::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
operand bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
start_indices 32/64 位元帶正負號的整數值的張量
slice_sizes 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.XlaHostCompute (TF::XlaHostComputeOp)

代表 XLA 程式中主機端運算的虛擬運算。

Interfaces: TF_RecvSideEffect (MemoryEffectOpInterface), TF_SendSideEffect (MemoryEffectOpInterface), TF_XlaHostComputeSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::XlaHostCompute}

屬性

屬性MLIR 類型描述
ancestors::mlir::ArrayAttr字串陣列屬性
shapes (形狀)::mlir::ArrayAttrtensorflow 形狀屬性陣列
shape_inference_graph::mlir::SymbolRefAttr符號參考屬性
key::mlir::StringAttr字串屬性
send_key::mlir::StringAttr字串屬性
recv_key::mlir::StringAttr字串屬性
cost_estimate_ns::mlir::IntegerAttr64 位元無號整數屬性
tpu_core::mlir::IntegerAttr64 位元無號整數屬性
Tinputs::mlir::Attribute衍生屬性
Toutputs::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf.XlaKeyValueSort (TF::XlaKeyValueSortOp)

包裝 XLA Sort 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#sort .

排序張量。目前僅支援升序排序。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
K::mlir::Attribute衍生屬性
V::mlir::Attribute衍生屬性

運算元

運算元 描述
keys (鍵) 整數或浮點數值的張量
values tf.dtype 值的張量

結果

結果 描述
sorted_keys 整數或浮點數值的張量
sorted_values tf.dtype 值的張量

tf.XlaLaunch (TF::XlaLaunchOp)

XLA Launch Op。僅供 XLA JIT 使用。

Traits: AttrSizedOperandSegments

介面:GetResourceInstanceInterfaceMemoryEffectOpInterface

屬性

屬性MLIR 類型描述
function::mlir::SymbolRefAttr符號參考屬性
Nresources::mlir::Attribute衍生屬性
Targs::mlir::Attribute衍生屬性
Tconstants::mlir::Attribute衍生屬性
Tresults::mlir::Attribute衍生屬性

運算元

運算元 描述
constants tf.dtype 值的張量的可變參數
args tf.dtype 值的張量的可變參數
resources 資源值的張量的可變參數

結果

結果 描述
results tf.dtype 值的張量的可變參數

tf.XlaLaunchV2 (TF::XlaLaunchV2Op)

XLA Launch Op。僅供 XLA JIT 使用。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
constants::mlir::ArrayAttr64 位元整數陣列屬性
resources::mlir::ArrayAttr64 位元整數陣列屬性
function::mlir::SymbolRefAttr符號參考屬性
Targs::mlir::Attribute衍生屬性
Tresults::mlir::Attribute衍生屬性

運算元

運算元 描述
args tf.dtype 值的張量的可變參數

結果

結果 描述
results tf.dtype 值的張量的可變參數

tf.XlaOptimizationBarrier (TF::XlaOptimizationBarrierOp)

包裝 XLA OptimizationBarrier 運算子。

文件位於 https://tensorflow.dev.org.tw/xla/operation_semantics#optimizationbarrier

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量的可變參數

結果

結果 描述
輸出 tf.dtype 值的張量的可變參數

tf.XlaPad (TF::XlaPadOp)

包裝 XLA Pad 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#pad .

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
padding_value tf.dtype 值的張量
padding_low 32/64 位元帶正負號的整數值的張量
padding_high 32/64 位元帶正負號的整數值的張量
padding_interior 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaRecv (TF::XlaRecvOp)

從另一個 XLA 計算接收具名張量。包裝 XLA Recv

運算子,文件位於 https://tensorflow.dev.org.tw/performance/xla/operation_semantics#recv

介面:TF_RecvSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
shape::mlir::AttributeTensorFlow 形狀屬性
dtype::mlir::Attribute衍生屬性

結果

結果 描述
tensor tf.dtype 值的張量

tf.XlaRecvFromHost (TF::XlaRecvFromHostOp)

從主機接收張量的運算。

output:將從主機接收的張量。Toutput:輸出的元素類型。shape:輸出的形狀。key:用於比對主機傳輸的此區域的唯一識別碼。

介面:TF_RecvSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Recv}

屬性

屬性MLIR 類型描述
shape::mlir::AttributeTensorFlow 形狀屬性
key::mlir::StringAttr字串屬性
Toutput::mlir::Attribute衍生屬性

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaRecvTPUEmbeddingActivations (TF::XlaRecvTPUEmbeddingActivationsOp)

在 TPU 上接收嵌入激活的運算。

TPU 系統執行嵌入查閱和彙總。這些彙總的結果對於 TensorFlow Graph 而言是可見的,作為 XlaRecvTPUEmbeddingActivations 運算的輸出。此運算傳回一個清單,其中包含模型中指定的每個表格的一個啟動張量。

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性
num_tables::mlir::Attribute衍生屬性

運算元

運算元 描述
deduplication_data 變體值的張量

結果

結果 描述
outputs 32 位元浮點數值的張量的可變參數

tf.XlaRecvTPUEmbeddingDeduplicationData (TF::XlaRecvTPUEmbeddingDeduplicationDataOp)

從嵌入核心接收重複資料刪除資料(索引和權重)。

重複資料刪除資料是 type=DT_VARIANT 的張量。張量本身是一個 XLA 巢狀元組,包含 N 個元素(其中 N 是每個 TPU 晶片嵌入核心與張量核心數量的比率)。巢狀元組的每個元素都是 rank 1 張量的元組。每個張量都包含 TensorCore 上嵌入查閱的索引 (DT_UINT32) 或要套用至嵌入查閱運算輸出的權重 (DT_FLOAT)。

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性

結果

結果 描述
輸出 變體值的張量

tf.XlaReduce (TF::XlaReduceOp)

包裝 XLA Reduce 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#reduce .

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimensions_to_reduce::mlir::ArrayAttr64 位元整數陣列屬性
reducer::mlir::SymbolRefAttr符號參考屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
init_value bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
輸出 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.XlaReducePrecision (TF::XlaReducePrecisionOp)

包裝 XLA ReducePrecision 運算子

文件位於 https://tensorflow.dev.org.tw/xla/operation_semantics#reduceprecision

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
exponent_bits::mlir::IntegerAttr64 位元無號整數屬性
mantissa_bits::mlir::IntegerAttr64 位元無號整數屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
operand 浮點數值的張量

結果

結果 描述
輸出 浮點數值的張量

tf.XlaReduceScatter (TF::XlaReduceScatterOp)

包裝 XLA ReduceScatter 運算子

文件位於 https://tensorflow.dev.org.tw/xla/operation_semantics#reducescatter

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
reduce_op::mlir::StringAttr字串屬性,其值為 Min、Max、Mul、Add 或 Mean
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 16 位元浮點或 32 位元浮點或 32 位元整數或 32 位元不帶正負號整數值的張量
group_assignment 32 位元整數值的張量
scatter_dimension 32 位元整數值的張量

結果

結果 描述
輸出 bfloat16 或 16 位元浮點或 32 位元浮點或 32 位元整數或 32 位元不帶正負號整數值的張量

tf.XlaReduceWindow (TF::XlaReduceWindowOp)

包裝 XLA ReduceWindow 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#reducewindow .

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
computation::mlir::SymbolRefAttr符號參考屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
init_value bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
window_dimensions 32/64 位元帶正負號的整數值的張量
window_strides 32/64 位元帶正負號的整數值的張量
base_dilations 32/64 位元帶正負號的整數值的張量
window_dilations 32/64 位元帶正負號的整數值的張量
padding 32/64 位元帶正負號的整數值的張量

結果

結果 描述
輸出 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.XlaRemoveDynamicDimensionSize (TF::XlaRemoveDynamicDimensionSizeOp)

XlaSetDynamicDimensionSize 的反向操作。

將 XLA 邊界動態維度轉換為靜態維度。維度 dim_index 的大小邊界會變成靜態維度大小。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
dim_index 32 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaReplicaId (TF::XlaReplicaIdOp)

副本 ID。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

結果

結果 描述
id 32 位元整數值的張量

tf.XlaRngBitGenerator (TF::XlaRngBitGeneratorOp)

無狀態 PRNG 位元產生器。

包裝 XLA RngBitGenerator 運算子,文件位於 https://tensorflow.dev.org.tw/performance/xla/operation_semantics#rngbitgenerator

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
Tshape::mlir::Attribute衍生屬性
dtype::mlir::Attribute衍生屬性

運算元

運算元 描述
algorithm 32 位元整數值的張量
initial_state 64 位元無符號整數值的張量
shape 32/64 位元帶正負號的整數值的張量

結果

結果 描述
output_key 64 位元無符號整數值的張量
輸出 32 位元整數或 64 位元整數或 8 位元整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.XlaScatter (TF::XlaScatterOp)

包裝 XLA Scatter 運算子,文件位於

https://tensorflow.dev.org.tw/xla/operation_semantics#scatter

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
update_computation::mlir::SymbolRefAttr符號參考屬性
dimension_numbers::mlir::StringAttr字串屬性
indices_are_sorted::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
operand bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量
scatter_indices 32/64 位元帶正負號的整數值的張量
updates (更新) bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

結果

結果 描述
輸出 bfloat16 或布林值或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的張量

tf.XlaSelectAndScatter (TF::XlaSelectAndScatterOp)

包裝 XLA SelectAndScatter 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#selectandscatter .

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
select::mlir::SymbolRefAttr符號參考屬性
scatter::mlir::SymbolRefAttr符號參考屬性
T::mlir::Attribute衍生屬性
Tindices::mlir::Attribute衍生屬性

運算元

運算元 描述
operand 數字值的張量
window_dimensions 32/64 位元帶正負號的整數值的張量
window_strides 32/64 位元帶正負號的整數值的張量
padding 32/64 位元帶正負號的整數值的張量
source (來源) 數字值的張量
init_value 數字值的張量

結果

結果 描述
輸出 數字值的張量

tf.XlaSelfAdjointEig (TF::XlaSelfAdjointEigOp)

計算一批自伴隨矩陣的特徵分解

(注意:僅支援實數輸入)。

計算張量中最內層 N 乘 N 矩陣的特徵值和特徵向量,使得 tensor[...,:,:] * v[..., :,i] = e[..., i] * v[...,:,i],適用於 i=0...N-1。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
lower::mlir::BoolAttr布林屬性
max_iter::mlir::IntegerAttr64 位元無號整數屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 數字值的張量

結果

結果 描述
w 數字值的張量
v 數字值的張量

tf.XlaSend (TF::XlaSendOp)

將具名張量傳送到另一個 XLA 計算。包裝 XLA Send 運算子

文件位於 https://tensorflow.dev.org.tw/performance/xla/operation_semantics#send

介面:TF_SendSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}

屬性

屬性MLIR 類型描述
tensor_name::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
tensor tf.dtype 值的張量

tf.XlaSendToHost (TF::XlaSendToHostOp)

將張量傳送到主機的運算。

input:將傳送到主機的張量。Tinput:輸入的元素類型。key:用於比對主機傳輸的此區域的唯一識別碼。

介面:TF_SendSideEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::Send}

屬性

屬性MLIR 類型描述
key::mlir::StringAttr字串屬性
Tinput::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

tf.XlaSendTPUEmbeddingGradients (TF::XlaSendTPUEmbeddingGradientsOp)

執行嵌入表梯度更新的運算。

gradients 引數是一個 TensorList,其長度和形狀與 XlaRecvTPUEmbeddingActivations 的傳回值相同,但包含模型損失相對於嵌入啟動的梯度。嵌入表會透過在提供給 tpu.initialize_system 的 TPUEmbeddingConfiguration proto 中指定的最佳化工具,從這些梯度進行更新。

Traits: AttrSizedOperandSegments

介面: TF_MustExecute (MemoryEffectOpInterface), TF_TPUEmbeddingReadEffect (MemoryEffectOpInterface)

效果: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::TF::ResourceEffects::TPUEmbedding}, MemoryEffects::Effect{MemoryEffects::Write on ::mlir::TF::ResourceEffects::MustExecute}

屬性

屬性MLIR 類型描述
config::mlir::StringAttr字串屬性
NumLearningRateTags::mlir::Attribute衍生屬性
NumTables::mlir::Attribute衍生屬性

運算元

運算元 描述
gradients 32 位元浮點數值的張量的可變參數
learning_rates 32 位元浮點數值的張量的可變參數
deduplication_data 變體值的張量

tf.XlaSetBound (TF::XlaSetBoundOp)

為給定的輸入值設定邊界,作為 Xla 編譯器的提示,

傳回相同的值。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
輸入 32 位元整數值的張量
bound 32 位元整數值的張量

結果

結果 描述
輸出 32 位元整數值的張量

tf.XlaSetDynamicDimensionSize (TF::XlaSetDynamicDimensionSizeOp)

將靜態維度轉換為 XLA 邊界動態維度。

目前的靜態維度大小將變成邊界,而第二個運算元將變成維度的動態大小。

特性:AlwaysSpeculatableImplTraitInferTensorTypeTF_NoConstantFold

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量
dim_index 32 位元整數值的張量
size 32 位元整數值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaSharding (TF::XlaShardingOp)

根據給定的分shard屬性對輸入進行分shard的運算。

Traits: AlwaysSpeculatableImplTrait, TF_NoConstantFold

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
sharding::mlir::StringAttr字串屬性
_XlaSharding::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaSort (TF::XlaSortOp)

包裝 XLA Sort 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#sort .

排序張量。目前僅支援升序排序。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaSparseCoreAdagrad (TF::XlaSparseCoreAdagradOp)

Aaa

屬性

屬性MLIR 類型描述
feature_width::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
indices 32 位元整數值的張量
gradient 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量

tf.XlaSparseCoreAdagradMomentum (TF::XlaSparseCoreAdagradMomentumOp)

Aaa

屬性

屬性MLIR 類型描述
feature_width::mlir::IntegerAttr64 位元無號整數屬性
use_nesterov::mlir::BoolAttr布林屬性
beta_2::mlir::FloatAttr32 位元浮點屬性
exponent::mlir::FloatAttr32 位元浮點屬性

運算元

運算元 描述
indices 32 位元整數值的張量
gradient 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
beta_1 32 位元浮點數值的張量
epsilon 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
momentum 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量
updated_momentum 32 位元浮點數值的張量

tf.XlaSparseCoreAdam (TF::XlaSparseCoreAdamOp)

Aaa

屬性

屬性MLIR 類型描述
feature_width::mlir::IntegerAttr64 位元無號整數屬性
use_sum_inside_sqrt::mlir::BoolAttr布林屬性

運算元

運算元 描述
embedding_table 32 位元浮點數值的張量
indices 32 位元整數值的張量
gradient 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
momentum 32 位元浮點數值的張量
velocity 32 位元浮點數值的張量
beta_1 32 位元浮點數值的張量
beta_2 32 位元浮點數值的張量
epsilon 32 位元浮點數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_velocity 32 位元浮點數值的張量
updated_momentum 32 位元浮點數值的張量

tf.XlaSparseCoreFtrl (TF::XlaSparseCoreFtrlOp)

Aaa

屬性

屬性MLIR 類型描述
feature_width::mlir::IntegerAttr64 位元無號整數屬性
multiply_linear_by_learning_rate::mlir::BoolAttr布林屬性
l1_regularization_strength::mlir::FloatAttr32 位元浮點屬性

運算元

運算元 描述
embedding_table 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
linear 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
indices 32 位元整數值的張量
gradient 32 位元浮點數值的張量
beta 32 位元浮點數值的張量
learning_rate_power 32 位元浮點數值的張量
l2_regularization_strength 32 位元浮點數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量
updated_linear 32 位元浮點數值的張量

tf.XlaSparseCoreSgd (TF::XlaSparseCoreSgdOp)

Aaa

屬性

屬性MLIR 類型描述
feature_width::mlir::IntegerAttr64 位元無號整數屬性

運算元

運算元 描述
indices 32 位元整數值的張量
gradient 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithAdagradAndCsrInput (TF::XlaSparseDenseMatmulGradWithAdagradAndCsrInputOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithAdagradAndStaticBufferSize (TF::XlaSparseDenseMatmulGradWithAdagradAndStaticBufferSizeOp)

一個 XLA 運算,用於執行密集-稀疏矩陣乘法的 Adagrad 優化器更新。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithAdagradMomentumAndCsrInput (TF::XlaSparseDenseMatmulGradWithAdagradMomentumAndCsrInputOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
use_nesterov::mlir::BoolAttr布林屬性
exponent::mlir::FloatAttr32 位元浮點屬性
beta1::mlir::FloatAttr32 位元浮點屬性
beta2::mlir::FloatAttr32 位元浮點屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量
updated_momenta 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithAdagradMomentumAndStaticBufferSize (TF::XlaSparseDenseMatmulGradWithAdagradMomentumAndStaticBufferSizeOp)

一個 XLA 運算,用於執行密集-稀疏矩陣乘法的 Adagrad 動量最佳化工具更新。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
use_nesterov::mlir::BoolAttr布林屬性
exponent::mlir::FloatAttr32 位元浮點屬性
beta1::mlir::FloatAttr32 位元浮點屬性
beta2::mlir::FloatAttr32 位元浮點屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量
updated_momenta 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithAdamAndCsrInput (TF::XlaSparseDenseMatmulGradWithAdamAndCsrInputOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
use_sum_inside_sqrt::mlir::BoolAttr布林屬性
beta1::mlir::FloatAttr32 位元浮點屬性
beta2::mlir::FloatAttr32 位元浮點屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
velocity 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_momenta 32 位元浮點數值的張量
updated_velocity 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithAdamAndStaticBufferSize (TF::XlaSparseDenseMatmulGradWithAdamAndStaticBufferSizeOp)

一個 XLA 運算,用於執行密集-稀疏矩陣乘法的 Adam 優化器更新。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
use_sum_inside_sqrt::mlir::BoolAttr布林屬性
beta1::mlir::FloatAttr32 位元浮點屬性
beta2::mlir::FloatAttr32 位元浮點屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
momenta (動量) 32 位元浮點數值的張量
velocity 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_momenta 32 位元浮點數值的張量
updated_velocity 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithFtrlAndCsrInput (TF::XlaSparseDenseMatmulGradWithFtrlAndCsrInputOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
multiply_linear_by_learning_rate::mlir::BoolAttr布林屬性
beta::mlir::FloatAttr32 位元浮點屬性
learning_rate_power::mlir::FloatAttr32 位元浮點屬性
l1_regularization_strength::mlir::FloatAttr32 位元浮點屬性
l2_regularization_strength::mlir::FloatAttr32 位元浮點屬性
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
linear 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量
updated_linear 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithFtrlAndStaticBufferSize (TF::XlaSparseDenseMatmulGradWithFtrlAndStaticBufferSizeOp)

一個 XLA 運算,用於執行密集-稀疏矩陣乘法的 Ftrl 優化器更新。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
multiply_linear_by_learning_rate::mlir::BoolAttr布林屬性
beta::mlir::FloatAttr32 位元浮點屬性
learning_rate_power::mlir::FloatAttr32 位元浮點屬性
l1_regularization_strength::mlir::FloatAttr32 位元浮點屬性
l2_regularization_strength::mlir::FloatAttr32 位元浮點屬性
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
accumulator 32 位元浮點數值的張量
linear 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量
updated_accumulator 32 位元浮點數值的張量
updated_linear 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithSgdAndCsrInput (TF::XlaSparseDenseMatmulGradWithSgdAndCsrInputOp)

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulGradWithSgdAndStaticBufferSize (TF::XlaSparseDenseMatmulGradWithSgdAndStaticBufferSizeOp)

一個 XLA 運算,用於執行密集-稀疏矩陣乘法的 SGD 優化器更新。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
clip_weight_min::mlir::FloatAttr32 位元浮點屬性
clip_weight_max::mlir::FloatAttr32 位元浮點屬性
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
activation_gradients 32 位元浮點數值的張量
learning_rate 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
updated_embedding_table 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulWithCsrInput (TF::XlaSparseDenseMatmulWithCsrInputOp)

Aaa

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
input_size::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
quantization_config_low::mlir::FloatAttr32 位元浮點屬性
quantization_config_high::mlir::FloatAttr32 位元浮點屬性
quantization_config_num_buckets::mlir::IntegerAttr64 位元無號整數屬性
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
activations 32 位元浮點數值的張量

tf.XlaSparseDenseMatmulWithStaticBufferSize (TF::XlaSparseDenseMatmulWithStaticBufferSizeOp)

一個 XLA 運算,用於執行密集-稀疏矩陣乘法。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
input_size::mlir::IntegerAttr最小值為 0 的 64 位元無號整數屬性
quantization_config_low::mlir::FloatAttr32 位元浮點屬性
quantization_config_high::mlir::FloatAttr32 位元浮點屬性
quantization_config_num_buckets::mlir::IntegerAttr64 位元無號整數屬性
max_ids_per_sparse_core (每個稀疏核心的最大 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
max_unique_ids_per_sparse_core (每個稀疏核心的最大不重複 ID 數)::mlir::IntegerAttr64 位元無號整數屬性,其最小值為 1
table_name::mlir::StringAttr字串屬性

運算元

運算元 描述
row_pointers 32 位元整數值的張量
sorted_sample_ids 32 位元整數值的張量
sorted_token_ids 32 位元整數值的張量
sorted_gains 32 位元浮點數值的張量
embedding_table 32 位元浮點數值的張量
num_minibatches_per_physical_sparse_core (每個實體稀疏核心的小批次數量) 32 位元整數值的張量

結果

結果 描述
activations 32 位元浮點數值的張量

tf.XlaSpmdFullToShardShape (TF::XlaSpmdFullToShardShapeOp)

XLA SPMD 分割器用來從自動分割切換到

手動分割的運算。它使用手動分割使用的相同分shard註解輸入(完整形狀,要自動分割),並輸出一個 shard 形狀的張量,供後續手動分割的運算使用。如果形狀無法均勻分割,則填補區域將以 0 遮罩。轉換可以部分在子群組中發生,方法是指定 dim 屬性,其中只會轉換該 dim。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
manual_sharding::mlir::StringAttr字串屬性
dim::mlir::IntegerAttr64 位元無號整數屬性
unspecified_dims::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaSpmdShardToFullShape (TF::XlaSpmdShardToFullShapeOp)

XLA SPMD 分割器用來從手動分割切換到

自動分割的運算。它會將 shard 形狀的手動分割輸入轉換為完整形狀的張量,以便使用手動分割使用的相同分shard自動分割。轉換可以部分在子群組中發生,方法是指定 dim 屬性,其中只會轉換該 dim。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
manual_sharding::mlir::StringAttr字串屬性
full_shape::mlir::AttributeTensorFlow 形狀屬性
dim::mlir::IntegerAttr64 位元無號整數屬性
unspecified_dims::mlir::ArrayAttr64 位元整數陣列屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 tf.dtype 值的張量

結果

結果 描述
輸出 tf.dtype 值的張量

tf.XlaSvd (TF::XlaSvdOp)

計算一批自伴隨矩陣的特徵分解

(注意:僅支援實數輸入)。

計算張量中最內層 M 乘 N 矩陣的特徵值和特徵向量,使得 tensor[...,:,:] = u[..., :, :] * Diag(s[..., :]) * Transpose(v[...,:,:])。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
max_iter::mlir::IntegerAttr64 位元無號整數屬性
epsilon::mlir::FloatAttr32 位元浮點屬性
precision_config::mlir::StringAttr字串屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
a 數字值的張量

結果

結果 描述
s 數字值的張量
u 數字值的張量
v 數字值的張量

tf.XlaVariadicReduce (TF::XlaVariadicReduceOp)

包裝 variadic XLA Reduce 運算子。

語意文件位於 https://tensorflow.dev.org.tw/performance/xla/operation_semantics#variadic_reduce

此版本僅限於相同 dtype 的運算元。XlaVariadicReduceV2 是支援異質運算元的版本。

特性:AlwaysSpeculatableImplTraitSameVariadicOperandSize

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimensions_to_reduce::mlir::ArrayAttr64 位元整數陣列屬性
reducer::mlir::SymbolRefAttr符號參考屬性
N::mlir::Attribute衍生屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
輸入 bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的 variadic 張量
init_value bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的 variadic 張量

結果

結果 描述
輸出 bfloat16 或 bool 或 128 位元複數或 64 位元複數或 16 位元浮點數或 32 位元浮點數或 64 位元浮點數或 16 位元整數或 32 位元整數或 64 位元整數或 8 位元整數或 16 位元量化整數或 32 位元量化整數或 8 位元量化整數或 16 位元量化無號整數或 8 位元量化無號整數或 16 位元無號整數或 32 位元無號整數或 64 位元無號整數或 8 位元無號整數值的 variadic 張量

tf.XlaVariadicReduceV2 (TF::XlaVariadicReduceV2Op)

包裝 variadic XLA Reduce 運算子。

語意文件位於 https://tensorflow.dev.org.tw/performance/xla/operation_semantics#variadic_reduce

這是 XlaVariadicReduce 的擴展版本,支援不同 dtype 的運算元,並改進了形狀推斷。

Traits: AlwaysSpeculatableImplTrait, AttrSizedOperandSegments

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
dimensions_to_reduce::mlir::ArrayAttr64 位元整數陣列屬性
reducer::mlir::SymbolRefAttr符號參考屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數
init_values tf.dtype 值的張量的可變參數

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf.XlaVariadicSort (TF::XlaVariadicSortOp)

包裝 XLA Sort 運算子,文件位於

https://tensorflow.dev.org.tw/performance/xla/operation_semantics#sort .

排序一個或多個張量,支援自訂比較子、維度和 is_stable 屬性。

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
comparator::mlir::SymbolRefAttr符號參考屬性
is_stable::mlir::BoolAttr布林屬性
T::mlir::Attribute衍生屬性

運算元

運算元 描述
inputs tf.dtype 值的張量的可變參數
dimension 32 位元整數值的張量

結果

結果 描述
outputs tf.dtype 值的張量的可變參數

tf.Xlog1py (TF::Xlog1pyOp)

如果 x == 0 則傳回 0,否則傳回 x * log1p(y),逐元素計算。

Traits: AlwaysSpeculatableImplTrait, TF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量
y 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.Xlogy (TF::XlogyOp)

如果 x == 0 則傳回 0,否則傳回 x * log(y),逐元素計算。

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShapeTF_SameOperandsAndResultElementTypeResolveRef

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 浮點數或複數值的張量
y 浮點數或複數值的張量

結果

結果 描述
z 浮點數或複數值的張量

tf.Yield (TF::YieldOp)

Yield 運算

「yield」運算代表結構化控制流程(例如,if 和 while)的條件和主體內的傳回運算。此運算接受可變數量的運算元,且不產生任何結果。輸入的數量和類型必須符合包含區域的運算的簽名。

特性:AlwaysSpeculatableImplTraitHasParent<CaseRegionOp, IfRegionOp, WhileRegionOp, GeneratorDatasetRegionOp>ReturnLikeTerminator

介面:ConditionallySpeculatableNoMemoryEffect (MemoryEffectOpInterface)RegionBranchTerminatorOpInterface

Effects: MemoryEffects::Effect{}

運算元

運算元 描述
«unnamed» 任何類型的 variadic

tf.ZerosLike (TF::ZerosLikeOp)

傳回與 x 具有相同形狀和類型的零張量。

Traits: AlwaysSpeculatableImplTrait, InferTensorType, TF::SameOperandsAndResultTypeResolveRef, TF_Idempotent

Interfaces: ConditionallySpeculatable, InferShapedTypeOpInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x tf.dtype 值的張量

結果

結果 描述
y tf.dtype 值的張量

tf.Zeta (TF::ZetaOp)

計算 Hurwitz zeta 函數 \(\zeta(x, q)\)。

Hurwitz zeta 函數定義為

\(\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}\)

特性:AlwaysSpeculatableImplTraitResultsBroadcastableShape

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

屬性

屬性MLIR 類型描述
T::mlir::Attribute衍生屬性

運算元

運算元 描述
x 32/64 位元浮點數值的張量
q 32/64 位元浮點數值的張量

結果

結果 描述
z 32/64 位元浮點數值的張量