Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 84d348f

Browse files
committed
Use C10::InferenceMode
1 parent 06f1c76 commit 84d348f

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

HelloWorld/HelloWorld/HelloWorld.xcodeproj/project.pbxproj

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
5EDE19DE85D83B5F6A4AC5A3 /* libPods-HelloWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CEAC4E4A977111B97FB776B4 /* libPods-HelloWorld.a */; };
1011
A0497B682352FFA000D70E9E /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = A0497B672352FFA000D70E9E /* image.png */; };
1112
A07753C62343DDEE00186969 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07753C52343DDEE00186969 /* AppDelegate.swift */; };
1213
A07753CA2343DDEE00186969 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07753C92343DDEE00186969 /* ViewController.swift */; };
@@ -20,6 +21,7 @@
2021
/* End PBXBuildFile section */
2122

2223
/* Begin PBXFileReference section */
24+
621D5B56BD99964F2B91D12F /* Pods-HelloWorld.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.debug.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.debug.xcconfig"; sourceTree = "<group>"; };
2325
A0497B672352FFA000D70E9E /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = "<group>"; };
2426
A07753C22343DDEE00186969 /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; };
2527
A07753C52343DDEE00186969 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -34,24 +36,39 @@
3436
A07753E12343F9AD00186969 /* model.pt */ = {isa = PBXFileReference; lastKnownFileType = file; path = model.pt; sourceTree = "<group>"; };
3537
A07753E22343F9AD00186969 /* words.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = words.txt; sourceTree = "<group>"; };
3638
A07753E92343FDEC00186969 /* UIImage+Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+Helper.swift"; sourceTree = "<group>"; };
39+
A3E3E5EDF7DC90E8181E130E /* Pods-HelloWorld.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.release.xcconfig"; sourceTree = "<group>"; };
40+
CEAC4E4A977111B97FB776B4 /* libPods-HelloWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld.a"; sourceTree = BUILT_PRODUCTS_DIR; };
3741
/* End PBXFileReference section */
3842

3943
/* Begin PBXFrameworksBuildPhase section */
4044
A07753BF2343DDEE00186969 /* Frameworks */ = {
4145
isa = PBXFrameworksBuildPhase;
4246
buildActionMask = 2147483647;
4347
files = (
48+
5EDE19DE85D83B5F6A4AC5A3 /* libPods-HelloWorld.a in Frameworks */,
4449
);
4550
runOnlyForDeploymentPostprocessing = 0;
4651
};
4752
/* End PBXFrameworksBuildPhase section */
4853

4954
/* Begin PBXGroup section */
55+
142D72B14004724085B7503E /* Pods */ = {
56+
isa = PBXGroup;
57+
children = (
58+
621D5B56BD99964F2B91D12F /* Pods-HelloWorld.debug.xcconfig */,
59+
A3E3E5EDF7DC90E8181E130E /* Pods-HelloWorld.release.xcconfig */,
60+
);
61+
name = Pods;
62+
path = Pods;
63+
sourceTree = "<group>";
64+
};
5065
A07753B92343DDEE00186969 = {
5166
isa = PBXGroup;
5267
children = (
5368
A07753C42343DDEE00186969 /* HelloWorld */,
5469
A07753C32343DDEE00186969 /* Products */,
70+
142D72B14004724085B7503E /* Pods */,
71+
C3020C4AB708B2526D0511C7 /* Frameworks */,
5572
);
5673
sourceTree = "<group>";
5774
};
@@ -99,13 +116,22 @@
99116
path = model;
100117
sourceTree = "<group>";
101118
};
119+
C3020C4AB708B2526D0511C7 /* Frameworks */ = {
120+
isa = PBXGroup;
121+
children = (
122+
CEAC4E4A977111B97FB776B4 /* libPods-HelloWorld.a */,
123+
);
124+
name = Frameworks;
125+
sourceTree = "<group>";
126+
};
102127
/* End PBXGroup section */
103128

104129
/* Begin PBXNativeTarget section */
105130
A07753C12343DDEE00186969 /* HelloWorld */ = {
106131
isa = PBXNativeTarget;
107132
buildConfigurationList = A07753D62343DDEF00186969 /* Build configuration list for PBXNativeTarget "HelloWorld" */;
108133
buildPhases = (
134+
13E44292D2F978BF9B935BF2 /* [CP] Check Pods Manifest.lock */,
109135
A07753BE2343DDEE00186969 /* Sources */,
110136
A07753BF2343DDEE00186969 /* Frameworks */,
111137
A07753C02343DDEE00186969 /* Resources */,
@@ -169,6 +195,31 @@
169195
};
170196
/* End PBXResourcesBuildPhase section */
171197

198+
/* Begin PBXShellScriptBuildPhase section */
199+
13E44292D2F978BF9B935BF2 /* [CP] Check Pods Manifest.lock */ = {
200+
isa = PBXShellScriptBuildPhase;
201+
buildActionMask = 2147483647;
202+
files = (
203+
);
204+
inputFileListPaths = (
205+
);
206+
inputPaths = (
207+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
208+
"${PODS_ROOT}/Manifest.lock",
209+
);
210+
name = "[CP] Check Pods Manifest.lock";
211+
outputFileListPaths = (
212+
);
213+
outputPaths = (
214+
"$(DERIVED_FILE_DIR)/Pods-HelloWorld-checkManifestLockResult.txt",
215+
);
216+
runOnlyForDeploymentPostprocessing = 0;
217+
shellPath = /bin/sh;
218+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
219+
showEnvVarsInLog = 0;
220+
};
221+
/* End PBXShellScriptBuildPhase section */
222+
172223
/* Begin PBXSourcesBuildPhase section */
173224
A07753BE2343DDEE00186969 /* Sources */ = {
174225
isa = PBXSourcesBuildPhase;
@@ -319,6 +370,7 @@
319370
};
320371
A07753D72343DDEF00186969 /* Debug */ = {
321372
isa = XCBuildConfiguration;
373+
baseConfigurationReference = 621D5B56BD99964F2B91D12F /* Pods-HelloWorld.debug.xcconfig */;
322374
buildSettings = {
323375
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
324376
CLANG_ENABLE_MODULES = YES;
@@ -341,6 +393,7 @@
341393
};
342394
A07753D82343DDEF00186969 /* Release */ = {
343395
isa = XCBuildConfiguration;
396+
baseConfigurationReference = A3E3E5EDF7DC90E8181E130E /* Pods-HelloWorld.release.xcconfig */;
344397
buildSettings = {
345398
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
346399
CLANG_ENABLE_MODULES = YES;

HelloWorld/HelloWorld/HelloWorld/TorchBridge/TorchModule.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ - (nullable instancetype)initWithFileAtPath:(NSString*)filePath {
2222
- (NSArray<NSNumber*>*)predictImage:(void*)imageBuffer {
2323
try {
2424
at::Tensor tensor = torch::from_blob(imageBuffer, {1, 3, 224, 224}, at::kFloat);
25-
torch::autograd::AutoGradMode guard(false);
26-
at::AutoNonVariableTypeMode non_var_type_mode(true);
25+
c10::InferenceMode();
2726
auto outputTensor = _impl.forward({tensor}).toTensor();
2827
float* floatBuffer = outputTensor.data_ptr<float>();
2928
if (!floatBuffer) {

0 commit comments

Comments
 (0)