Skip to content

Commit

Permalink
Conditionally build the TestApp benchmark based on lite interpreter (p…
Browse files Browse the repository at this point in the history
…ytorch#86314)

The TestApp benchmark was recently re-added, however it seems it only builds when pytorch is built with the lite interpreter. This diff adds a macro to compile out the benchmark when pytorch is built as full jit. This should fix our full jit simulator nightly builds.
Pull Request resolved: pytorch#86314
Approved by: https://github.com/malfet
  • Loading branch information
jmdetloff authored and pytorchmergebot committed Oct 6, 2022
1 parent 936e930 commit 85c3b74
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ios/TestApp/TestApp/Benchmark.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef BUILD_LITE_INTERPRETER

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -10,3 +12,4 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END
#endif
3 changes: 3 additions & 0 deletions ios/TestApp/TestApp/Benchmark.mm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef BUILD_LITE_INTERPRETER

#import "Benchmark.h"
#include <string>
#include <vector>
Expand Down Expand Up @@ -103,3 +105,4 @@ + (NSString*)run {
}

@end
#endif
7 changes: 7 additions & 0 deletions ios/TestApp/TestApp/ViewController.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#import "ViewController.h"


#ifdef BUILD_LITE_INTERPRETER
#import "Benchmark.h"
#endif

@interface ViewController ()
@property(nonatomic, strong) UITextView* textView;
Expand All @@ -11,6 +14,7 @@ @implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];

#ifdef BUILD_LITE_INTERPRETER
self.textView = [[UITextView alloc] initWithFrame:self.view.bounds];
self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.textView];
Expand All @@ -30,8 +34,10 @@ - (void)viewDidLoad {

[Benchmark setup:config];
[self runBenchmark];
#endif
}

#ifdef BUILD_LITE_INTERPRETER
- (void)runBenchmark {
self.textView.text = @"Start benchmarking...\n";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
Expand All @@ -41,5 +47,6 @@ - (void)runBenchmark {
});
});
}
#endif

@end
5 changes: 5 additions & 0 deletions ios/TestApp/benchmark/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
config.build_settings['LIBRARY_SEARCH_PATHS'] = libraries_search_path
config.build_settings['OTHER_LDFLAGS'] = other_linker_flags
config.build_settings['ENABLE_BITCODE'] = 'No'
if (options[:lite])
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', "BUILD_LITE_INTERPRETER"]
else
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)']
end
dev_team_id = options[:team_id]
if dev_team_id
config.build_settings['DEVELOPMENT_TEAM'] = dev_team_id
Expand Down

0 comments on commit 85c3b74

Please sign in to comment.