Skip to content

Commit d92f069

Browse files
committed
Merge branch 'refs/heads/master' into submission-v4.1
2 parents 513dcf1 + b5c4cc3 commit d92f069

File tree

10 files changed

+33
-250
lines changed

10 files changed

+33
-250
lines changed

flutter/assets/tasks.pbtxt

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -216,86 +216,12 @@ task {
216216
}
217217
}
218218

219-
task {
220-
id: "image_classification"
221-
name: "Image Classification"
222-
min_query_count: 1024
223-
min_duration: 60
224-
max_duration: 600
225-
max_throughput: 1000
226-
max_accuracy: 1.0
227-
scenario: "SingleStream"
228-
datasets {
229-
type: IMAGENET
230-
full {
231-
name: "Imagenet classification validation set"
232-
input_path: "local:///mlperf_datasets/imagenet/img"
233-
groundtruth_path: "local:///mlperf_datasets/imagenet/imagenet_val_full.txt"
234-
}
235-
lite {
236-
name: "Open images subset for classification"
237-
input_path: "https://github.com/mlcommons/mobile_models/raw/main/v0_7/datasets/imagenet.zip"
238-
groundtruth_path: ""
239-
}
240-
tiny {
241-
name: "Imagenet dataset for integration test"
242-
input_path: "https://github.com/mlcommons/mobile_models/raw/main/v0_7/datasets/imagenet_tiny.zip"
243-
groundtruth_path: "https://github.com/mlcommons/mobile_models/raw/main/v3_0/assets/imagenet_tiny-groundtruth.txt"
244-
}
245-
}
246-
model {
247-
id: "mobilenetedgetpu_224_v1_0"
248-
name: "MobileNetEdgeTPU 224 1.0"
249-
offset: 1
250-
image_width: 224
251-
image_height: 224
252-
num_classes: 1000
253-
}
254-
}
255-
256-
task {
257-
id: "image_classification_offline"
258-
name: "Image Classification (Offline)"
259-
min_query_count: 24576
260-
min_duration: 0
261-
max_duration: 0
262-
max_throughput: 2000
263-
max_accuracy: 1.0
264-
scenario: "Offline"
265-
datasets {
266-
type: IMAGENET
267-
full {
268-
name: "Imagenet classification validation set"
269-
input_path: "local:///mlperf_datasets/imagenet/img"
270-
groundtruth_path: "local:///mlperf_datasets/imagenet/imagenet_val_full.txt"
271-
}
272-
lite {
273-
name: "Open images subset for classification"
274-
input_path: "https://github.com/mlcommons/mobile_models/raw/main/v0_7/datasets/imagenet.zip"
275-
groundtruth_path: ""
276-
}
277-
tiny {
278-
name: "Imagenet dataset for integration test"
279-
input_path: "https://github.com/mlcommons/mobile_models/raw/main/v0_7/datasets/imagenet_tiny.zip"
280-
groundtruth_path: "https://github.com/mlcommons/mobile_models/raw/main/v3_0/assets/imagenet_tiny-groundtruth.txt"
281-
}
282-
}
283-
model {
284-
id: "mobilenetedgetpu_224_v1_0"
285-
name: "MobileNetEdgeTPU 224 1.0"
286-
offset: 1
287-
image_width: 224
288-
image_height: 224
289-
num_classes: 1000
290-
}
291-
}
292-
293219
task {
294220
id: "stable_diffusion"
295221
name: "Stable Diffusion"
296-
min_query_count: 5
222+
min_query_count: 1024
297223
min_duration: 60
298-
max_duration: 600
224+
max_duration: 300
299225
max_throughput: 2000
300226
max_accuracy: 1.0
301227
scenario: "SingleStream"

flutter/cpp/datasets/coco_gen.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ float CocoGen::ComputeAccuracy() {
139139
total_score += score;
140140
}
141141
float avg_score = total_score / total_samples;
142-
return avg_score;
142+
return avg_score / 100;
143143
}
144144

145145
std::string CocoGen::ComputeAccuracyString() {

flutter/integration_test/expected_accuracy.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ key: <accelerator> OR <accelerator>|<backendName>
1616
- neuron > Android MediaTek
1717
*/
1818

19-
const Map<String, Interval> _imageClassification = {
20-
'cpu': Interval(min: 1.00, max: 1.00),
21-
'npu': Interval(min: 0.89, max: 0.91),
22-
'tpu': Interval(min: 0.89, max: 0.91),
23-
'ane': Interval(min: 1.00, max: 1.00),
24-
'cpu&gpu&ane': Interval(min: 1.00, max: 1.00),
25-
'snpe_dsp': Interval(min: 0.78, max: 0.82),
26-
'psnpe_dsp': Interval(min: 0.78, max: 0.82),
27-
'neuron-mdla': Interval(min: 0.88, max: 0.91),
28-
};
29-
3019
const Map<String, Interval> _imageClassificationV2 = {
3120
'cpu': Interval(min: 0.88, max: 0.91),
3221
'npu': Interval(min: 0.88, max: 0.91),
@@ -100,13 +89,11 @@ const Map<String, Interval> _stableDiffusion = {
10089
};
10190

10291
const benchmarkExpectedAccuracy = {
103-
BenchmarkId.imageClassification: _imageClassification,
10492
BenchmarkId.imageClassificationV2: _imageClassificationV2,
10593
BenchmarkId.objectDetection: _objectDetection,
10694
BenchmarkId.imageSegmentationV2: _imageSegmentation,
10795
BenchmarkId.naturalLanguageProcessing: _naturalLanguageProcessing,
10896
BenchmarkId.superResolution: _superResolution,
10997
BenchmarkId.stableDiffusion: _stableDiffusion,
110-
BenchmarkId.imageClassificationOffline: _imageClassification,
11198
BenchmarkId.imageClassificationOfflineV2: _imageClassificationV2,
11299
};

flutter/integration_test/expected_throughput.dart

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,6 @@ const _kDN2103 = 'DN2103'; // OnePlus DN2103
2929
const _kIphoneOnGitHubAction = 'iPhone15,3';
3030
const _kIphoneOnMacbookM1 = 'iPhone14,7';
3131

32-
const Map<String, Map<String, Interval>> _imageClassification = {
33-
_kTFLiteBackend: {
34-
_kCloudBuildX23: Interval(min: 4, max: 12),
35-
_kCloudBuildX28: Interval(min: 4, max: 13),
36-
_kRyzen5600: Interval(min: 31, max: 37),
37-
_kPixel5: Interval(min: 80, max: 130),
38-
_kPixel6: Interval(min: 600, max: 1100),
39-
_kIphoneOnGitHubAction: Interval(min: 1, max: 8),
40-
_kIphoneOnMacbookM1: Interval(min: 19, max: 27),
41-
},
42-
_kCoreMLBackend: {
43-
_kIphoneOnGitHubAction: Interval(min: 1, max: 12),
44-
},
45-
_kPixelBackend: {
46-
_kPixel6: Interval(min: 700, max: 1200),
47-
},
48-
_kQtiBackend: {
49-
_kS22Ultra: Interval(min: 1600, max: 2400),
50-
},
51-
_kMediatekBackend: {
52-
_kDN2103: Interval(min: 30, max: 55),
53-
},
54-
};
55-
5632
const Map<String, Map<String, Interval>> _imageClassificationV2 = {
5733
_kTFLiteBackend: {
5834
_kCloudBuildX23: Interval(min: 1, max: 9),
@@ -198,30 +174,6 @@ const Map<String, Map<String, Interval>> _stableDiffusion = {
198174
},
199175
};
200176

201-
const Map<String, Map<String, Interval>> _imageClassificationOffline = {
202-
_kTFLiteBackend: {
203-
_kCloudBuildX23: Interval(min: 8, max: 14),
204-
_kCloudBuildX28: Interval(min: 7, max: 16),
205-
_kRyzen5600: Interval(min: 45, max: 60),
206-
_kPixel5: Interval(min: 120, max: 190),
207-
_kPixel6: Interval(min: 800, max: 1700),
208-
_kIphoneOnGitHubAction: Interval(min: 2, max: 15),
209-
_kIphoneOnMacbookM1: Interval(min: 30, max: 45),
210-
},
211-
_kCoreMLBackend: {
212-
_kIphoneOnGitHubAction: Interval(min: 2, max: 20),
213-
},
214-
_kPixelBackend: {
215-
_kPixel6: Interval(min: 900, max: 1800),
216-
},
217-
_kQtiBackend: {
218-
_kS22Ultra: Interval(min: 2400, max: 3500),
219-
},
220-
_kMediatekBackend: {
221-
_kDN2103: Interval(min: 75, max: 140),
222-
},
223-
};
224-
225177
const Map<String, Map<String, Interval>> _imageClassificationOfflineV2 = {
226178
_kTFLiteBackend: {
227179
_kCloudBuildX23: Interval(min: 1, max: 9),
@@ -247,13 +199,11 @@ const Map<String, Map<String, Interval>> _imageClassificationOfflineV2 = {
247199
};
248200

249201
const benchmarkExpectedThroughput = {
250-
BenchmarkId.imageClassification: _imageClassification,
251202
BenchmarkId.imageClassificationV2: _imageClassificationV2,
252203
BenchmarkId.objectDetection: _objectDetection,
253204
BenchmarkId.imageSegmentationV2: _imageSegmentationV2,
254205
BenchmarkId.naturalLanguageProcessing: _naturalLanguageProcessing,
255206
BenchmarkId.superResolution: _superResolution,
256207
BenchmarkId.stableDiffusion: _stableDiffusion,
257-
BenchmarkId.imageClassificationOffline: _imageClassificationOffline,
258208
BenchmarkId.imageClassificationOfflineV2: _imageClassificationOfflineV2,
259209
};

flutter/lib/app_constants.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,19 @@ class WidgetKeys {
1616
}
1717

1818
class BenchmarkId {
19-
static const imageClassification = 'image_classification';
2019
static const objectDetection = 'object_detection';
2120
static const imageSegmentationV2 = 'image_segmentation_v2';
2221
static const naturalLanguageProcessing = 'natural_language_processing';
2322
static const superResolution = 'super_resolution';
24-
static const imageClassificationOffline = 'image_classification_offline';
2523
static const imageClassificationV2 = 'image_classification_v2';
2624
static const imageClassificationOfflineV2 = 'image_classification_offline_v2';
2725
static const stableDiffusion = 'stable_diffusion';
2826

2927
static const allIds = [
30-
imageClassification,
3128
objectDetection,
3229
imageSegmentationV2,
3330
naturalLanguageProcessing,
3431
superResolution,
35-
imageClassificationOffline,
3632
imageClassificationV2,
3733
imageClassificationOfflineV2,
3834
stableDiffusion,

flutter/lib/benchmark/info.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ class BenchmarkInfo {
2727

2828
BenchmarkLocalizationInfo getLocalizedInfo(AppLocalizations stringResources) {
2929
switch (task.id) {
30-
case (BenchmarkId.imageClassification):
31-
return BenchmarkLocalizationInfo(
32-
name: stringResources.benchNameImageClassification,
33-
detailsTitle: stringResources.benchInfoImageClassification,
34-
detailsContent: stringResources.benchInfoImageClassificationDesc,
35-
);
36-
case (BenchmarkId.imageClassificationOffline):
37-
return BenchmarkLocalizationInfo(
38-
name: stringResources.benchNameImageClassificationOffline,
39-
detailsTitle: stringResources.benchInfoImageClassification,
40-
detailsContent: stringResources.benchInfoImageClassificationDesc,
41-
);
4230
case (BenchmarkId.imageClassificationV2):
4331
return BenchmarkLocalizationInfo(
4432
name: stringResources.benchNameImageClassification,

flutter/lib/ui/icons.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,21 @@ class AppIcons {
6666

6767
class BenchmarkIcons {
6868
static final darkSet = {
69-
BenchmarkId.imageClassification: AppIcons.imageClassification,
7069
BenchmarkId.imageClassificationV2: AppIcons.imageClassification,
7170
BenchmarkId.objectDetection: AppIcons.objectDetection,
7271
BenchmarkId.imageSegmentationV2: AppIcons.imageSegmentation,
7372
BenchmarkId.naturalLanguageProcessing: AppIcons.languageProcessing,
7473
BenchmarkId.superResolution: AppIcons.superResolution,
75-
BenchmarkId.imageClassificationOffline: AppIcons.imageClassificationOffline,
7674
BenchmarkId.imageClassificationOfflineV2:
7775
AppIcons.imageClassificationOffline,
7876
};
7977

8078
static final lightSet = {
81-
BenchmarkId.imageClassification: AppIcons.imageClassificationWhite,
8279
BenchmarkId.imageClassificationV2: AppIcons.imageClassificationWhite,
8380
BenchmarkId.objectDetection: AppIcons.objectDetectionWhite,
8481
BenchmarkId.imageSegmentationV2: AppIcons.imageSegmentationWhite,
8582
BenchmarkId.naturalLanguageProcessing: AppIcons.languageProcessingWhite,
8683
BenchmarkId.superResolution: AppIcons.superResolutionWhite,
87-
BenchmarkId.imageClassificationOffline:
88-
AppIcons.imageClassificationOfflineWhite,
8984
BenchmarkId.imageClassificationOfflineV2:
9085
AppIcons.imageClassificationOfflineWhite,
9186
};

mobile_back_tflite/cpp/backend_tflite/stable_diffusion_invoker.cc

Lines changed: 16 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -44,79 +44,31 @@ std::vector<float> StableDiffusionInvoker::encode_prompt(
4444
std::vector<float> StableDiffusionInvoker::diffusion_step(
4545
const std::vector<float>& latent, const std::vector<float>& t_emb,
4646
const std::vector<float>& context) {
47-
// Prepare the first model's inputs
48-
49-
auto first_input_details =
50-
TfLiteInterpreterGetInputTensor(backend_data_->first_interpreter, 0);
51-
auto second_input_details =
52-
TfLiteInterpreterGetInputTensor(backend_data_->first_interpreter, 1);
53-
auto third_input_details =
54-
TfLiteInterpreterGetInputTensor(backend_data_->first_interpreter, 2);
47+
auto latent_input_details =
48+
TfLiteInterpreterGetInputTensor(backend_data_->sd_interpreter, 0);
49+
auto context_input_details =
50+
TfLiteInterpreterGetInputTensor(backend_data_->sd_interpreter, 1);
51+
auto time_stamp_embedding_input_details =
52+
TfLiteInterpreterGetInputTensor(backend_data_->sd_interpreter, 2);
5553

5654
std::copy(context.begin(), context.end(),
57-
reinterpret_cast<float*>(TfLiteTensorData(first_input_details)));
55+
reinterpret_cast<float*>(TfLiteTensorData(context_input_details)));
5856
std::copy(t_emb.begin(), t_emb.end(),
59-
reinterpret_cast<float*>(TfLiteTensorData(second_input_details)));
57+
reinterpret_cast<float*>(
58+
TfLiteTensorData(time_stamp_embedding_input_details)));
6059
std::copy(latent.begin(), latent.end(),
61-
reinterpret_cast<float*>(TfLiteTensorData(third_input_details)));
60+
reinterpret_cast<float*>(TfLiteTensorData(latent_input_details)));
6261

63-
// Invoke the first model
64-
if (TfLiteInterpreterInvoke(backend_data_->first_interpreter) != kTfLiteOk) {
62+
// Invoke the model
63+
if (TfLiteInterpreterInvoke(backend_data_->sd_interpreter) != kTfLiteOk) {
6564
std::cerr << "Failed to invoke the first diffusion model!" << std::endl;
6665
exit(-1);
6766
}
6867

69-
// Output names from the first model and corresponding input names for the
70-
// second model
71-
std::vector<std::string> output_names = {
72-
"Identity_6", "Identity_4", "Identity", "input_1", "Identity_12",
73-
"Identity_11", "Identity_3", "Identity_10", "Identity_9", "Identity_5",
74-
"Identity_8", "Identity_7", "Identity_2"};
75-
76-
std::vector<std::string> input_names = {
77-
"args_0", "args_0_1", "args_0_2", "args_0_4", "args_0_3",
78-
"args_0_5", "args_0_6", "args_0_7", "args_0_8", "args_0_9",
79-
"args_0_10", "args_0_11", "args_0_12"};
80-
81-
// Copy outputs of the first model to the inputs of the second model based on
82-
// names
83-
for (size_t i = 0; i < input_names.size(); ++i) {
84-
int input_index = get_tensor_index_by_name(
85-
backend_data_->second_interpreter, input_names[i], true);
86-
int output_index = get_tensor_index_by_name(
87-
backend_data_->first_interpreter, output_names[i], false);
88-
89-
if (input_index == -1 || output_index == -1) {
90-
std::cerr << "Failed to find matching input or output tensor by name!"
91-
<< std::endl;
92-
exit(-1);
93-
}
94-
95-
auto first_model_output_details = TfLiteInterpreterGetOutputTensor(
96-
backend_data_->first_interpreter, output_index);
97-
98-
float* output_data =
99-
reinterpret_cast<float*>(TfLiteTensorData(first_model_output_details));
100-
int output_size =
101-
TfLiteTensorByteSize(first_model_output_details) / sizeof(float);
102-
103-
float* input_data = reinterpret_cast<float*>(
104-
TfLiteTensorData(TfLiteInterpreterGetInputTensor(
105-
backend_data_->second_interpreter, input_index)));
106-
107-
std::copy(output_data, output_data + output_size, input_data);
108-
}
109-
110-
// Invoke the second model
111-
if (TfLiteInterpreterInvoke(backend_data_->second_interpreter) != kTfLiteOk) {
112-
std::cerr << "Failed to invoke the second diffusion model!" << std::endl;
113-
exit(-1);
114-
}
115-
11668
float* output = reinterpret_cast<float*>(TfLiteTensorData(
117-
TfLiteInterpreterGetOutputTensor(backend_data_->second_interpreter, 0)));
69+
TfLiteInterpreterGetOutputTensor(backend_data_->sd_interpreter, 0)));
11870
int output_size = TfLiteTensorByteSize(TfLiteInterpreterGetOutputTensor(
119-
backend_data_->second_interpreter, 0)) /
71+
backend_data_->sd_interpreter, 0)) /
12072
sizeof(float);
12173
return std::vector<float>(output, output + output_size);
12274
}
@@ -201,9 +153,9 @@ std::vector<float> StableDiffusionInvoker::run_inference(
201153

202154
// Access the input tensors
203155
void* pos_ids_input_data =
204-
TfLiteTensorData(TfLiteInterpreterGetInputTensor(interpreter, 0));
205-
void* encoded_input_data =
206156
TfLiteTensorData(TfLiteInterpreterGetInputTensor(interpreter, 1));
157+
void* encoded_input_data =
158+
TfLiteTensorData(TfLiteInterpreterGetInputTensor(interpreter, 0));
207159

208160
// Copy data to input tensors (type cast required for correct copy operation)
209161
std::memcpy(pos_ids_input_data, pos_ids.data(), pos_ids.size() * sizeof(int));

0 commit comments

Comments
 (0)