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

Method rebase

src/shape_transform_descriptor.cpp:745–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743};
744
745shape_transform_descriptor shape_transform_descriptor::rebase(const std::vector<std::size_t>& dims,
746 bool broadcast) const
747{
748 auto result = *this;
749 auto axes_map = rebase_ambiguity_resolver{result, dims}.resolve();
750 for(auto& [axis, subs] : axes_map)
751 {
752 assert(axis < dims.size());
753 auto dim = dims[axis];
754 if(dim == len(subs))
755 {
756 if(not broadcast)
757 {
758 for(auto* sub : subs)
759 sub->expose();
760 }
761 }
762 else if(dim == 1)
763 {
764 for(auto* sub : subs)
765 {
766 if(not sub->has_hidden_axis())
767 sub->len = 1;
768 }
769 }
770 else if(subs.size() == 1)
771 {
772 subs.front()->len = dim;
773 if(broadcast)
774 subs.front()->hide();
775 else
776 subs.front()->expose();
777 }
778 else if(dim == visible_len(subs))
779 {
780 for(auto* sub : subs)
781 {
782 if(sub->has_hidden_axis())
783 {
784 sub->expose();
785 sub->len = 1;
786 }
787 }
788 }
789 else
790 return {};
791 }
792 for(auto& dim : result.dimensions)
793 remove_empty_sub_dims(dim.subdimensions);
794 if(broadcast and not is_broadcast_only(dimensions, result.dimensions))
795 return {};
796
797 return result;
798}
799static dimension::sub* get_last_subdimension(std::vector<dimension>& dims)
800{
801 if(dims.empty())

Callers 5

generateMethod · 0.95
TEST_CASEFunction · 0.80
make_descriptorMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80

Calls 10

lenFunction · 0.85
visible_lenFunction · 0.85
remove_empty_sub_dimsFunction · 0.85
is_broadcast_onlyFunction · 0.85
resolveMethod · 0.80
exposeMethod · 0.80
frontMethod · 0.80
hideMethod · 0.80
sizeMethod · 0.45
has_hidden_axisMethod · 0.45

Tested by

no test coverage detected