提交 594aabd1 编写于 作者: L liuqi

Change the way to sync at batch norm opencl benchmark.

上级 918aae3b
...@@ -39,14 +39,14 @@ static void BatchNorm( ...@@ -39,14 +39,14 @@ static void BatchNorm(
// Warm-up // Warm-up
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
net.RunOp(D); net.RunOp(D);
net.Sync();
} }
net.Sync();
mace::testing::StartTiming(); mace::testing::StartTiming();
while (iters--) { while (iters--) {
net.RunOp(D); net.RunOp(D);
net.Sync();
} }
net.Sync();
} }
#define BM_BATCH_NORM_MACRO(N, C, H, W, TYPE, DEVICE) \ #define BM_BATCH_NORM_MACRO(N, C, H, W, TYPE, DEVICE) \
......
...@@ -141,6 +141,7 @@ class OpsTestNet { ...@@ -141,6 +141,7 @@ class OpsTestNet {
net_def.add_op()->CopyFrom(op_def_); net_def.add_op()->CopyFrom(op_def_);
VLOG(3) << net_def.DebugString(); VLOG(3) << net_def.DebugString();
net_ = CreateNet(net_def, &ws_, device); net_ = CreateNet(net_def, &ws_, device);
device_ = device;
return net_->Run(); return net_->Run();
} }
...@@ -151,7 +152,7 @@ class OpsTestNet { ...@@ -151,7 +152,7 @@ class OpsTestNet {
} }
void Sync() { void Sync() {
if (net_) { if (net_ && device_ == DeviceType::OPENCL) {
OpenCLRuntime::Get()->command_queue().finish(); OpenCLRuntime::Get()->command_queue().finish();
} }
} }
...@@ -160,6 +161,7 @@ class OpsTestNet { ...@@ -160,6 +161,7 @@ class OpsTestNet {
Workspace ws_; Workspace ws_;
OperatorDef op_def_; OperatorDef op_def_;
std::unique_ptr<NetBase> net_; std::unique_ptr<NetBase> net_;
DeviceType device_;
}; };
class OpsTestBase : public ::testing::Test { class OpsTestBase : public ::testing::Test {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册