| 54 | } |
| 55 | |
| 56 | ValueRefList 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 | |
| 87 | ValueRefList InterpreterTransformation::apply_create_tensor( |
| 88 | const CreateTensor& create_tensor, Span<ValueRef> inputs) { |
nothing calls this directly
no test coverage detected