MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / apply_get_attr

Method apply_get_attr

imperative/src/impl/transformations/trace.cpp:742–769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740}
741
742ValueRefList CompiledTransformation::apply_get_attr(
743 const GetAttr& get_attr, Span<ValueRef> inputs) {
744 if (auto* traced_value = inputs[0].as(m_value_type)) {
745 ValueRef output;
746 switch (get_attr.attr()) {
747 case GetAttr::Shape:
748 output = traced_value->shape();
749 break;
750 case GetAttr::Data:
751 output = traced_value->data();
752 break;
753 case GetAttr::Value:
754 output = traced_value->value();
755 break;
756 case GetAttr::DType:
757 output = traced_value->dtype();
758 break;
759 case GetAttr::Device:
760 output = traced_value->comp_node();
761 break;
762 default:
763 break;
764 }
765 return {output};
766 } else {
767 return imperative::apply(get_attr, inputs);
768 }
769}
770
771ValueRefList CompiledTransformation::apply_create_tensor(
772 const CreateTensor& create_tensor, Span<ValueRef> inputs) {

Callers

nothing calls this directly

Calls 8

attrMethod · 0.80
applyFunction · 0.50
asMethod · 0.45
shapeMethod · 0.45
dataMethod · 0.45
valueMethod · 0.45
dtypeMethod · 0.45
comp_nodeMethod · 0.45

Tested by

no test coverage detected