| 37 | namespace gl { |
| 38 | |
| 39 | SingleOpModel::SingleOpModel(Operation&& operation, |
| 40 | const std::vector<TensorRef<BHWC>>& inputs, |
| 41 | const std::vector<TensorRef<BHWC>>& outputs) { |
| 42 | auto node = graph_.NewNode(); |
| 43 | node->operation = std::move(operation); |
| 44 | |
| 45 | for (int i = 0; i < inputs.size(); ++i) { |
| 46 | auto input = graph_.NewValue(); |
| 47 | input->tensor = inputs[i]; |
| 48 | graph_.AddConsumer(node->id, input->id).IgnoreError(); |
| 49 | TensorFloat32 tensor; |
| 50 | tensor.id = input->tensor.ref; |
| 51 | tensor.shape = input->tensor.shape; |
| 52 | inputs_.emplace_back(std::move(tensor)); |
| 53 | } |
| 54 | |
| 55 | for (int i = 0; i < outputs.size(); ++i) { |
| 56 | auto output = graph_.NewValue(); |
| 57 | output->tensor = outputs[i]; |
| 58 | graph_.SetProducer(node->id, output->id).IgnoreError(); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | bool SingleOpModel::PopulateTensor(int index, std::vector<float>&& data) { |
| 63 | if (index >= inputs_.size() || |
nothing calls this directly
no test coverage detected