| 769 | } |
| 770 | |
| 771 | ValueRefList CompiledTransformation::apply_create_tensor( |
| 772 | const CreateTensor& create_tensor, Span<ValueRef> inputs) { |
| 773 | if (create_tensor.kind() == CreateTensor::NoTrace) { |
| 774 | return imperative::apply(create_tensor, inputs); |
| 775 | } |
| 776 | auto& item = next_instruction(); |
| 777 | trace_assert(item.op == nullptr, "operator mismatch"); |
| 778 | auto input_id = item.inputs[0]; |
| 779 | auto output_id = item.outputs[0]; |
| 780 | ValueRef tensor; |
| 781 | if (create_tensor.kind() == CreateTensor::Const) { |
| 782 | auto args = create_tensor.parse(inputs); |
| 783 | if (args.host) { |
| 784 | // performance issue |
| 785 | tensor = HostValue::make(*args.host); |
| 786 | } |
| 787 | } |
| 788 | if (!tensor) { |
| 789 | tensor = imperative::apply(create_tensor, inputs)[0]; |
| 790 | } |
| 791 | return {trace_output(output_id, trace_input(input_id, tensor))}; |
| 792 | } |
| 793 | |
| 794 | ValueRefList CompiledTransformation::apply_transformation( |
| 795 | const Operator& op, Span<ValueRef> inputs) { |