Move test_spec in TensorFlowLiteSwift.podspec.template into subspec, so that the Delegate tests are only done in corresponding delegates.
PiperOrigin-RevId: 313321621 Change-Id: Ibf39faa449315b75e9b61a4b6a91fac14e454232
This commit is contained in:
parent
0a1449a983
commit
ddb921bf77
@ -26,7 +26,16 @@ Pod::Spec.new do |s|
|
|||||||
s.subspec 'Core' do |core|
|
s.subspec 'Core' do |core|
|
||||||
core.dependency 'TensorFlowLiteC', "#{s.version}"
|
core.dependency 'TensorFlowLiteC', "#{s.version}"
|
||||||
core.source_files = swift_dir + 'Sources/*.swift'
|
core.source_files = swift_dir + 'Sources/*.swift'
|
||||||
core.exclude_files = swift_dir + 'Sources/*Delegate.swift'
|
core.exclude_files = swift_dir + 'Sources/{CoreML,Metal}Delegate.swift'
|
||||||
|
|
||||||
|
core.test_spec 'Tests' do |ts|
|
||||||
|
ts.source_files = swift_dir + 'Tests/*.swift'
|
||||||
|
ts.exclude_files = swift_dir + 'Tests/MetalDelegateTests.swift'
|
||||||
|
ts.resources = [
|
||||||
|
tfl_dir + 'testdata/add.bin',
|
||||||
|
tfl_dir + 'testdata/add_quantized.bin',
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
s.subspec 'CoreML' do |coreml|
|
s.subspec 'CoreML' do |coreml|
|
||||||
@ -39,14 +48,13 @@ Pod::Spec.new do |s|
|
|||||||
metal.source_files = swift_dir + 'Sources/MetalDelegate.swift'
|
metal.source_files = swift_dir + 'Sources/MetalDelegate.swift'
|
||||||
metal.dependency 'TensorFlowLiteC/Metal', "#{s.version}"
|
metal.dependency 'TensorFlowLiteC/Metal', "#{s.version}"
|
||||||
metal.dependency 'TensorFlowLiteSwift/Core', "#{s.version}"
|
metal.dependency 'TensorFlowLiteSwift/Core', "#{s.version}"
|
||||||
end
|
|
||||||
|
|
||||||
|
metal.test_spec 'Tests' do |ts|
|
||||||
s.test_spec 'Tests' do |ts|
|
ts.source_files = swift_dir + 'Tests/{Interpreter,MetalDelegate}Tests.swift'
|
||||||
ts.source_files = swift_dir + 'Tests/*.swift'
|
ts.resources = [
|
||||||
ts.resources = [
|
tfl_dir + 'testdata/add.bin',
|
||||||
tfl_dir + 'testdata/add.bin',
|
tfl_dir + 'testdata/add_quantized.bin',
|
||||||
tfl_dir + 'testdata/add_quantized.bin',
|
]
|
||||||
]
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,26 +50,6 @@ class InterpreterTests: XCTestCase {
|
|||||||
XCTAssertNil(interpreter.delegates)
|
XCTAssertNil(interpreter.delegates)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInitWithDelegate() throws {
|
|
||||||
let metalDelegate = MetalDelegate()
|
|
||||||
let interpreter = try Interpreter(modelPath: AddQuantizedModel.path, delegates: [metalDelegate])
|
|
||||||
XCTAssertEqual(interpreter.delegates?.count, 1)
|
|
||||||
XCTAssertNil(interpreter.options)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testInitWithOptionsAndDelegate() throws {
|
|
||||||
var options = Interpreter.Options()
|
|
||||||
options.threadCount = 1
|
|
||||||
let metalDelegate = MetalDelegate()
|
|
||||||
let interpreter = try Interpreter(
|
|
||||||
modelPath: AddQuantizedModel.path,
|
|
||||||
options: options,
|
|
||||||
delegates: [metalDelegate]
|
|
||||||
)
|
|
||||||
XCTAssertNotNil(interpreter.options)
|
|
||||||
XCTAssertEqual(interpreter.delegates?.count, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testInputTensorCount() {
|
func testInputTensorCount() {
|
||||||
XCTAssertEqual(interpreter.inputTensorCount, AddModel.inputTensorCount)
|
XCTAssertEqual(interpreter.inputTensorCount, AddModel.inputTensorCount)
|
||||||
}
|
}
|
||||||
@ -268,7 +248,7 @@ class InterpreterOptionsTests: XCTestCase {
|
|||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
|
|
||||||
/// Values for the `add.bin` model.
|
/// Values for the `add.bin` model.
|
||||||
private enum AddModel {
|
enum AddModel {
|
||||||
static let info = (name: "add", extension: "bin")
|
static let info = (name: "add", extension: "bin")
|
||||||
static let inputTensorCount = 1
|
static let inputTensorCount = 1
|
||||||
static let outputTensorCount = 1
|
static let outputTensorCount = 1
|
||||||
@ -301,7 +281,7 @@ private enum AddModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Values for the `add_quantized.bin` model.
|
/// Values for the `add_quantized.bin` model.
|
||||||
private enum AddQuantizedModel {
|
enum AddQuantizedModel {
|
||||||
static let info = (name: "add_quantized", extension: "bin")
|
static let info = (name: "add_quantized", extension: "bin")
|
||||||
static let inputOutputIndex = 0
|
static let inputOutputIndex = 0
|
||||||
static let shape: Tensor.Shape = [2]
|
static let shape: Tensor.Shape = [2]
|
||||||
|
@ -32,6 +32,26 @@ class MetalDelegateTests: XCTestCase {
|
|||||||
XCTAssertTrue(delegate.options.allowsPrecisionLoss)
|
XCTAssertTrue(delegate.options.allowsPrecisionLoss)
|
||||||
XCTAssertEqual(delegate.options.waitType, .active)
|
XCTAssertEqual(delegate.options.waitType, .active)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testInitInterpreterWithDelegate() throws {
|
||||||
|
let metalDelegate = MetalDelegate()
|
||||||
|
let interpreter = try Interpreter(modelPath: AddQuantizedModel.path, delegates: [metalDelegate])
|
||||||
|
XCTAssertEqual(interpreter.delegates?.count, 1)
|
||||||
|
XCTAssertNil(interpreter.options)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInitInterpreterWithOptionsAndDelegate() throws {
|
||||||
|
var options = Interpreter.Options()
|
||||||
|
options.threadCount = 1
|
||||||
|
let metalDelegate = MetalDelegate()
|
||||||
|
let interpreter = try Interpreter(
|
||||||
|
modelPath: AddQuantizedModel.path,
|
||||||
|
options: options,
|
||||||
|
delegates: [metalDelegate]
|
||||||
|
)
|
||||||
|
XCTAssertNotNil(interpreter.options)
|
||||||
|
XCTAssertEqual(interpreter.delegates?.count, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MetalDelegateOptionsTests: XCTestCase {
|
class MetalDelegateOptionsTests: XCTestCase {
|
||||||
|
Loading…
Reference in New Issue
Block a user