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

Function compute_broadcasted_dyn_dims

src/common.cpp:54–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 return out_lens;
53}
54std::vector<shape::dynamic_dimension>
55compute_broadcasted_dyn_dims(std::vector<shape::dynamic_dimension> dds0,
56 std::vector<shape::dynamic_dimension> dds1)
57{
58 if(dds0.size() > dds1.size())
59 {
60 std::swap(dds0, dds1);
61 }
62 auto offset = dds1.size() - dds0.size();
63 std::vector<shape::dynamic_dimension> out_dims(dds1);
64 std::transform(dds0.cbegin(),
65 dds0.cend(),
66 dds1.cbegin() + offset,
67 out_dims.begin() + offset,
68 [&](auto a, auto b) {
69 if(a == b or b == 1)
70 {
71 return a;
72 }
73 else if(a == 1)
74 {
75 return b;
76 }
77 else
78 {
79 auto intersect = a.intersection(b);
80 if(intersect.has_value())
81 {
82 return intersect.value();
83 }
84 MIGRAPHX_THROW("COMPUTE_BROADCASTED_DYN_DIMS: dynamic shapes {" +
85 migraphx::to_string_range(dds0) + "} and {" +
86 migraphx::to_string_range(dds1) + "} mismatch!");
87 }
88 });
89 return out_dims;
90}
91
92std::vector<shape::dynamic_dimension> compute_broadcasted_dyn_dims(shape s0, shape s1)
93{

Callers 2

compute_common_dyn_dimsFunction · 0.85
compute_shapeMethod · 0.85

Calls 7

swapFunction · 0.85
to_string_rangeFunction · 0.85
to_dynamicMethod · 0.80
transformFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected