#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include "example_utils.hpp"
IC = 3,
IH = 227,
IW = 227;
std::vector<float> src_data(product(src_dims));
std::vector<float> scale_shift_data(product(scale_shift_dims));
std::generate(src_data.begin(), src_data.end(), []() {
static int i = 0;
return std::cos(i++ / 10.f);
});
auto mid = scale_shift_data.begin() + IC;
std::generate(scale_shift_data.begin(), mid, []() {
static int i = 0;
return std::sin(i++ * 2.f);
});
std::generate(mid, scale_shift_data.end(), []() {
static int i = 0;
return std::tan(i++);
});
auto scale_shift_md =
memory::desc(scale_shift_dims, dt::f32, tag::nc);
write_to_dnnl_memory(src_data.data(), src_mem);
write_to_dnnl_memory(scale_shift_data.data(), scale_shift_mem);
auto bnorm_pd
auto variance_mem =
memory(bnorm_pd.variance_desc(),
engine);
auto workspace_mem =
memory(bnorm_pd.workspace_desc(),
engine);
std::unordered_map<int, memory> bnorm_args;
bnorm_prim.execute(engine_stream, bnorm_args);
engine_stream.wait();
read_from_dnnl_memory(src_data.data(), src_mem);
}
int main(int argc, char **argv) {
return handle_example_errors(
batch_normalization_example, parse_engine_kind(argc, argv));
}