#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include "example_utils.hpp"
IC = 3,
IH = 227,
IW = 227,
OC = 96;
std::vector<float> src_data(product(src_dims));
std::vector<float> weights_data(product(weights_dims));
std::vector<float> bias_data(OC);
std::vector<float> dst_data(product(dst_dims));
std::generate(src_data.begin(), src_data.end(), []() {
static int i = 0;
return std::cos(i++ / 10.f);
});
std::generate(weights_data.begin(), weights_data.end(), []() {
static int i = 0;
return std::sin(i++ * 2.f);
});
std::generate(bias_data.begin(), bias_data.end(), []() {
static int i = 0;
return std::tanh(i++);
});
auto user_weights_mem =
memory({weights_dims, dt::f32, tag::oihw},
engine);
write_to_dnnl_memory(src_data.data(), src_mem);
write_to_dnnl_memory(bias_data.data(), bias_mem);
write_to_dnnl_memory(weights_data.data(), user_weights_mem);
auto inner_product_weights_md
inner_product_weights_md, bias_md,
dst_md);
const float scale = 1.0f;
const float alpha = 0.f;
const float beta = 0.f;
auto inner_product_weights_mem = user_weights_mem;
if (inner_product_pd.weights_desc() != user_weights_mem.get_desc()) {
inner_product_weights_mem
reorder(user_weights_mem, inner_product_weights_mem)
.
execute(engine_stream, user_weights_mem,
inner_product_weights_mem);
}
std::unordered_map<int, memory> inner_product_args;
inner_product_prim.execute(engine_stream, inner_product_args);
read_from_dnnl_memory(dst_data.data(), dst_mem);
}
int main(int argc, char **argv) {
return handle_example_errors(
inner_product_example, parse_engine_kind(argc, argv));
}