Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit a4d2336

Browse files
committed
Add useXLA flag to TFFunction.execute.
1 parent 217b644 commit a4d2336

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/TensorFlow/Core/LazyTensorTFFunctionBuilder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class TFFunction {
269269
checkOk(status)
270270
}
271271

272-
func execute(_ inputs: [TFETensorHandle]) -> [TFETensorHandle] {
272+
func execute(_ inputs: [TFETensorHandle], useXLA: Bool = false) -> [TFETensorHandle] {
273273
let status: CTFStatus = TF_NewStatus()
274274
defer { TF_DeleteStatus(status) }
275275

@@ -286,6 +286,11 @@ class TFFunction {
286286
checkOk(status)
287287
}
288288

289+
if useXLA {
290+
debugLog("Enabling XLA compilation")
291+
TFE_OpSetAttrBool(eagerOp, "_XlaCompile", 1)
292+
}
293+
289294
for input in inputs {
290295
TFE_OpAddInput(eagerOp, input._cTensorHandle, status)
291296
checkOk(status)

0 commit comments

Comments
 (0)