Convert a variable to another format(possibily added after `input`). Args: input: A variable. format: The target format. Returns: A variable. If `input` is already `format`, then return `input` directly, otherwize add a variable after `input` with `format`. */
| 529 | A variable. If `input` is already `format`, then return `input` directly, otherwize add a variable after `input` with `format`. |
| 530 | */ |
| 531 | VARP _Convert(VARP input, Dimensionformat format) { |
| 532 | if (nullptr != input->getInfo()) { |
| 533 | auto source = input->getInfo()->order; |
| 534 | if (source == format) { |
| 535 | return input; |
| 536 | } |
| 537 | } |
| 538 | std::unique_ptr<OpT> convert(new OpT); |
| 539 | convert->type = OpType_ConvertTensor; |
| 540 | convert->main.type = OpParameter_TensorConvertInfo; |
| 541 | convert->main.value = new TensorConvertInfoT; |
| 542 | convert->main.AsTensorConvertInfo()->dest = (MNN_DATA_FORMAT)Utils::convertFormat(format); |
| 543 | return (Variable::create(Expr::create(convert.get(), {input}))); |
| 544 | } |
| 545 | /*Splits a variable value into a list of sub variables. |
| 546 | Args: |
| 547 | value: The variable to split. |