Skip to content

Commit

Permalink
add fake bert model to benchmark (#219)
Browse files Browse the repository at this point in the history
* add fake bert model

* add fake bert model to c++ benchmark

* remove global step from variable list
  • Loading branch information
lgarithm authored and luomai committed Nov 26, 2019
1 parent a3e9e8e commit 0f38a09
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 6 deletions.
83 changes: 83 additions & 0 deletions tests/cpp/integration/bert.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#pragma once
#include <vector>

inline std::vector<int> bert_grad_sizes()
{
return {
23440896, 1536, 393216, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 589824,
768, 589824, 768, 589824, 768, 768, 768, 2359296,
3072, 2359296, 768, 768, 768, 589824, 768, 1536,
2, 23440896, 23440896, 1536, 1536, 393216, 393216, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 589824, 589824, 768, 768, 589824,
589824, 768, 768, 768, 768, 768, 768, 2359296,
2359296, 3072, 3072, 2359296, 2359296, 768, 768, 768,
768, 768, 768, 1536, 1536, 2, 2,
};
}
15 changes: 9 additions & 6 deletions tests/cpp/integration/fake_model.hpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#pragma once
#include <cstdlib>
#include <map>
#include <numeric>
#include <string>
#include <vector>

#include "bert.hpp"
#include "resnet50_info.hpp"
#include "vgg_info.hpp"

inline std::vector<int> parameter_sizes(const std::string &model, bool fuse)
{
std::vector<int> sizes;
if (model == std::string("resnet50-imagenet")) {
sizes = resnet50_grad_sizes();
} else if (model == std::string("vgg16-imagenet")) {
sizes = vgg16_grad_sizes();
} else {
static const std::map<std::string, std::vector<int>> model_sizes({
{"resnet50-imagenet", resnet50_grad_sizes()},
{"vgg16-imagenet", vgg16_grad_sizes()},
{"bert", bert_grad_sizes()},
});
if (model_sizes.count(model) == 0) {
fprintf(stderr, "invalid model name: %s\n", model.c_str());
exit(1);
}
std::vector<int> sizes = model_sizes.at(model);
if (fuse) {
const int tot = std::accumulate(sizes.begin(), sizes.end(), 0);
sizes = {tot};
Expand Down
79 changes: 79 additions & 0 deletions tests/go/fakemodel/bert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package fakemodel

var bert = []int{
23440896, 1536, 393216, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
589824, 768, 589824, 768, 589824, 768, 768, 768,
2359296, 3072, 2359296, 768, 768, 768, 589824, 768,
1536, 2, 23440896, 23440896, 1536, 1536, 393216, 393216,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 589824, 589824, 768, 768,
589824, 589824, 768, 768, 768, 768, 768, 768,
2359296, 2359296, 3072, 3072, 2359296, 2359296, 768, 768,
768, 768, 768, 768, 1536, 1536, 2, 2,
}
1 change: 1 addition & 0 deletions tests/go/fakemodel/fakemodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Models = map[string][]int{
"resnet50-imagenet": resnet50Imagenet,
"vgg16-imagenet": vgg16Imagenet,
"slp-mnist": slpMNIST,
"bert": bert,
}

var Names = func(m map[string][]int) []string {
Expand Down

0 comments on commit 0f38a09

Please sign in to comment.