#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include "dnnl.hpp"
#include "example_utils.hpp"
IC = 3,
IH = 227,
IW = 227;
std::vector<float> src_data(product(src_dims));
std::vector<float> weights_data(product(weights_dims));
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::fill(weights_data.begin(), weights_data.end(), 0.3f);
auto user_src_mem =
memory({src_dims, dt::f32, tag::nchw},
engine);
auto user_weights_mem =
memory({weights_dims, dt::f32, tag::nchw},
engine);
auto user_dst_mem =
memory({dst_dims, dt::f32, tag::nchw},
engine);
write_to_dnnl_memory(src_data.data(), user_src_mem);
write_to_dnnl_memory(weights_data.data(), user_weights_mem);
auto prelu_weights_mem = user_weights_mem;
if (prelu_pd.weights_desc() != user_weights_mem.
get_desc()) {
prelu_weights_mem =
memory(prelu_pd.weights_desc(),
engine);
reorder(user_weights_mem, prelu_weights_mem)
.
execute(engine_stream, user_weights_mem, prelu_weights_mem);
}
std::unordered_map<int, memory> prelu_args;
prelu_prim.execute(engine_stream, prelu_args);
read_from_dnnl_memory(dst_data.data(), user_dst_mem);
}
int main(int argc, char **argv) {
return handle_example_errors(prelu_example, parse_engine_kind(argc, argv));
}