MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / elements

Method elements

src/targets/gpu/compile_gen.cpp:59–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59vectorize vectorize::elements(std::size_t axis,
60 const std::vector<shape>& inputs,
61 const std::vector<std::size_t>& sizes)
62{
63 // disable vectorization for fp8 types
64 if(std::any_of(inputs.begin(), inputs.end(), [&](auto ishape) {
65 return contains(fp8_types{}.get(), ishape.type());
66 }))
67 return {1, axis};
68 if(std::all_of(
69 inputs.begin(), inputs.end(), [&](const auto& s) { return s.lens()[axis] == 1; }))
70 return {1, axis};
71 std::vector<std::size_t> max_vec_size;
72 std::transform(inputs.begin(),
73 inputs.end(),
74 std::back_inserter(max_vec_size),
75 [&](const auto& input) -> std::size_t {
76 auto stride = input.strides()[axis];
77 auto len = input.lens()[axis];
78 if(not contains({0, 1}, stride))
79 return 1;
80 if(len == 1 and input.elements() > sizes.front())
81 return sizes.front();
82 auto it = std::find_if(sizes.begin(), sizes.end(), [&](auto vsize) {
83 // The len is divisible by the size and all the strides are divisible by
84 // the size
85 return (len % vsize) == 0 and
86 std::all_of(
87 input.strides().begin(), input.strides().end(), [&](auto i) {
88 return contains({0, 1}, i) or i % vsize == 0;
89 });
90 });
91 if(it != sizes.end())
92 return *it;
93 return 1;
94 });
95 return {*std::min_element(max_vec_size.begin(), max_vec_size.end()), axis};
96}
97
98vectorize vectorize::elements(context& ctx, std::size_t axis, const std::vector<shape>& inputs)
99{

Callers 15

qparam_broadcast_opMethod · 0.45
offload_to_mlirFunction · 0.45
add_neg_opMethod · 0.45
compute_shapeMethod · 0.45
setMethod · 0.45
generate_reduceFunction · 0.45
computeMethod · 0.45
read_scalarMethod · 0.45
computeMethod · 0.45
pointwise_applyFunction · 0.45
computeMethod · 0.45
computeMethod · 0.45

Calls 15

containsFunction · 0.85
min_elementFunction · 0.85
vector_sizesFunction · 0.85
accumulateFunction · 0.85
compute_tile_factorFunction · 0.85
lensMethod · 0.80
frontMethod · 0.80
get_cu_countMethod · 0.80
ndimMethod · 0.80
backMethod · 0.80
type_sizeMethod · 0.80

Tested by

no test coverage detected