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

Function tune_attribute

src/normalize_attributes.cpp:45–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 */
44template <class Message>
45static auto tune_attribute(const std::vector<int64_t>& vec,
46 const std::vector<int64_t>& axes,
47 const value& val,
48 const shape& input_shape,
49 Message m)
50{
51 std::vector<int64_t> result(vec);
52 if(result.empty())
53 {
54 return result;
55 };
56 int64_t n_rank = input_shape.ndim();
57 std::vector<op::normalize_attribute> vec_attrs = val.to_vector<op::normalize_attribute>();
58 if(contains(vec_attrs, op::normalize_attribute::use_output))
59 {
60 n_rank = n_rank + vec.size();
61 }
62
63 std::vector<int64_t> max_vals(vec.size(), n_rank);
64
65 if(contains(vec_attrs, op::normalize_attribute::use_len))
66 {
67 if(input_shape.dynamic())
68 {
69 // return the unchanged `vec` if the dynamic_dimensions at `axes` are not fixed
70 if(std::any_of(axes.begin(), axes.end(), [&](auto ax) {
71 return not input_shape.dyn_dims().at(ax).is_fixed();
72 }))
73 {
74 return vec;
75 }
76 std::transform(axes.begin(), axes.end(), max_vals.begin(), [&](auto i) {
77 return input_shape.dyn_dims().at(i).max;
78 });
79 }
80 else
81 {
82 std::transform(axes.begin(), axes.end(), max_vals.begin(), [&](auto i) {
83 return input_shape.lens().at(i);
84 });
85 }
86 }
87
88 if(contains(vec_attrs, op::normalize_attribute::clip_max))
89 {
90 if(contains(vec_attrs, op::normalize_attribute::include_max))
91 {
92 std::transform(result.begin(),
93 result.end(),
94 max_vals.begin(),
95 result.begin(),
96 [](auto v, auto mv) { return v > mv ? mv : v; });
97 }
98 else
99 {
100 std::transform(result.begin(),
101 result.end(),
102 max_vals.begin(),

Callers 3

normalize_attributesFunction · 0.85
normalize_axesFunction · 0.85
normalize_indicesFunction · 0.85

Calls 13

containsFunction · 0.85
ndimMethod · 0.80
dynamicMethod · 0.80
is_fixedMethod · 0.80
atMethod · 0.80
lensMethod · 0.80
any_ofFunction · 0.50
transformFunction · 0.50
equalFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected