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

Commit 3fdaa61

Browse files
authored
Cleanup: remove _cdecl and _silgen annotations. (#371)
* Cleanup: remove `_cdecl` and `_silgen` annotations. * Remove unused setAttrShapeList
1 parent 6b5c521 commit 3fdaa61

File tree

1 file changed

+0
-41
lines changed

1 file changed

+0
-41
lines changed

Sources/TensorFlow/Core/Runtime.swift

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,6 @@ internal func dumpCTensorHandleContent(_ idx: Int, _ inputTensorHandle: CTensorH
11041104
}
11051105

11061106
@inlinable
1107-
@_cdecl("_swift_tfc_EagerExecute")
11081107
func _TFCEagerExecute(
11091108
_ op: CTFEOp,
11101109
_ retvals: UnsafeMutablePointer<OpaquePointer?>,
@@ -1136,25 +1135,19 @@ func _TFCEagerExecute(
11361135
//===----------------------------------------------------------------------===//
11371136

11381137
@usableFromInline
1139-
@_cdecl("_swift_tfc_GetGlobalEagerContext")
11401138
func _TFCGetGlobalEagerContext() -> CTFEContext {
11411139
debugLog("Calling _GetGlobalEagerContext()")
11421140
return _ExecutionContext.global.eagerContext
11431141
}
11441142

1145-
// Some of the functions are marked with @silgen_name instead of @_cdecl, because their input/output
1146-
// data types are not C-compatible (e.g., AnyTensorHandle).
1147-
11481143
/// Adds `handle` as an input to `op`.
11491144
@usableFromInline
1150-
@_silgen_name("_swift_tfc_OpAddInputFromTensorHandle")
11511145
func _TFCOpAddInputFromTensorHandle(_ op: CTFEOp, _ handle: _AnyTensorHandle, _ status: CTFStatus) {
11521146
TFE_OpAddInput(op, handle._cTensorHandle, status)
11531147
}
11541148

11551149
/// Adds `t` as an input or inputs to `op`. Returns the number of inputs added.
11561150
@usableFromInline
1157-
@_silgen_name("_swift_tfc_OpAddInputFromTensorGroup")
11581151
func _TFCOpAddInputFromTensorGroup<T: TensorArrayProtocol>(
11591152
_ op: CTFEOp,
11601153
_ t: T,
@@ -1187,7 +1180,6 @@ func _TFCOpAddInputFromAnyTensors(_ op: CTFEOp, _ tensors: [AnyTensor], _ status
11871180
// can read.
11881181

11891182
@usableFromInline
1190-
@_silgen_name("_swift_tfc_OpSetAttrTypeArray")
11911183
func _TFCOpSetAttrTypeArray(
11921184
_ op: CTFEOp,
11931185
_ attrName: UnsafePointer<Int8>,
@@ -1201,38 +1193,6 @@ func _TFCOpSetAttrTypeArray(
12011193
}
12021194
}
12031195

1204-
/// Given dimensions and ranks in the form described below, makes the appropriate call to
1205-
/// `TFE_OpSetAttrShapeList(op, attrName, ..., status)`.
1206-
///
1207-
/// - Parameters
1208-
/// - flattenedDims: all the shapes' dimensions concatenated together in order.
1209-
/// - ranks: all the shapes' ranks (-1 denotes unknown rank).
1210-
fileprivate func setAttrShapeList(
1211-
op: CTFEOp,
1212-
attrName: UnsafePointer<Int8>,
1213-
flattenedDims: Array<Int64>,
1214-
ranks: Array<Int32>,
1215-
status: CTFStatus
1216-
) {
1217-
flattenedDims.withUnsafeBufferPointer { flattenedDimsBuffer in
1218-
var dimsPtr: UnsafePointer<Int64>? = flattenedDimsBuffer.baseAddress
1219-
var dims: [UnsafePointer<Int64>?] = []
1220-
for rank in ranks {
1221-
dims.append(dimsPtr)
1222-
if rank >= 0 {
1223-
dimsPtr = dimsPtr.map { $0.advanced(by: Int(rank)) }
1224-
}
1225-
}
1226-
dims.withUnsafeMutableBufferPointer { dimsBuffer in
1227-
ranks.withUnsafeBufferPointer { ranksBuffer in
1228-
TFE_OpSetAttrShapeList(
1229-
op, attrName, dimsBuffer.baseAddress, ranksBuffer.baseAddress,
1230-
Int32(ranksBuffer.count), status)
1231-
}
1232-
}
1233-
}
1234-
}
1235-
12361196
/// A class to keep around thread local state.
12371197
class _ThreadLocalState {
12381198
var deviceScopes = DeviceScopes()
@@ -1287,7 +1247,6 @@ struct DeviceScopes {
12871247
}
12881248

12891249
@usableFromInline
1290-
@_cdecl("_swift_tfc_OpSetDeviceFromScope")
12911250
func _TFCOpSetDeviceFromScope(_ op: CTFEOp, _ status: CTFStatus) {
12921251
if let deviceName = _ExecutionContext.global.currentDeviceName {
12931252
TFE_OpSetDevice(op, deviceName, status)

0 commit comments

Comments
 (0)