mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55114 Test Plan: CI Reviewed By: ezyang, bhosmer Differential Revision: D27472768 fbshipit-source-id: 76f17ef7de40f6e04e2968f8958027b5f93e1c0c
37 lines
928 B
Plaintext
37 lines
928 B
Plaintext
#import <XCTest/XCTest.h>
|
|
|
|
#include <torch/script.h>
|
|
|
|
@interface TestAppTests : XCTestCase
|
|
|
|
@end
|
|
|
|
@implementation TestAppTests {
|
|
torch::jit::Module _module;
|
|
}
|
|
|
|
+ (void)setUp {
|
|
[super setUp];
|
|
}
|
|
|
|
- (void)setUp {
|
|
[super setUp];
|
|
NSString* modelPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"model"
|
|
ofType:@"pt"];
|
|
XCTAssertTrue([NSFileManager.defaultManager fileExistsAtPath:modelPath],
|
|
@"model.pt doesn't exist!");
|
|
_module = torch::jit::load(modelPath.UTF8String);
|
|
}
|
|
|
|
- (void)testForward {
|
|
_module.eval();
|
|
c10::InferenceMode mode;
|
|
std::vector<c10::IValue> inputs;
|
|
inputs.push_back(torch::ones({1, 3, 224, 224}, at::ScalarType::Float));
|
|
auto outputTensor = _module.forward(inputs).toTensor();
|
|
float* outputBuffer = outputTensor.data_ptr<float>();
|
|
XCTAssertTrue(outputBuffer != nullptr, @"");
|
|
}
|
|
|
|
@end
|