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

Method apply_get_attr

imperative/src/impl/transformations/eval.cpp:56–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56ValueRefList InterpreterTransformation::apply_get_attr(
57 const GetAttr& get_attr, Span<ValueRef> inputs) {
58 auto& input = inputs.item().cast(m_value_type);
59 ValueRef output;
60 m_channel->set_backtrace(Transformation::get_context().bt);
61 switch (get_attr.attr()) {
62 case GetAttr::DType:
63 output = input.dtype();
64 break;
65 case GetAttr::Shape:
66 output = input.shape();
67 break;
68 case GetAttr::Device:
69 output = input.comp_node();
70 break;
71 case GetAttr::Value:
72 output = HostValue::make(m_channel->get_value(input.handle()->handle()));
73 break;
74 case GetAttr::Data:
75 output = DeviceValue::make(
76 m_channel->get_dev_tensor(input.handle()->handle()));
77 break;
78 default:
79 mgb_throw(
80 MegBrainError, "Interpreter: malformed GetAttr: %s",
81 get_attr.to_string().c_str());
82 }
83 m_channel->clear_backtrace();
84 return {output};
85}
86
87ValueRefList InterpreterTransformation::apply_create_tensor(
88 const CreateTensor& create_tensor, Span<ValueRef> inputs) {

Callers

nothing calls this directly

Calls 13

set_backtraceMethod · 0.80
attrMethod · 0.80
get_dev_tensorMethod · 0.80
clear_backtraceMethod · 0.80
makeFunction · 0.50
castMethod · 0.45
itemMethod · 0.45
dtypeMethod · 0.45
shapeMethod · 0.45
comp_nodeMethod · 0.45
get_valueMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected