* Create an tuple TVMArray input array. * * The input array can be passed to tvm runtime function * and needs to b explicitly disposed. * * @param inputs The input array * @returns The result array.
(
inputs: Array<any>
)
| 1654 | * @returns The result array. |
| 1655 | */ |
| 1656 | makeTVMArray( |
| 1657 | inputs: Array<any> |
| 1658 | ): TVMArray { |
| 1659 | const CALL_STACK_LIMIT = 30000; |
| 1660 | const inputsLength = inputs.length; |
| 1661 | if (inputsLength <= CALL_STACK_LIMIT) { |
| 1662 | return this.ctx.arrayMake(...inputs) as TVMArray; |
| 1663 | } |
| 1664 | // If too many elements, TypeScript would complain `Maximum call stack size exceeded` |
| 1665 | // So we make several arrays and concatenate them |
| 1666 | const listOfArrays: Array<TVMArray> = []; |
| 1667 | for (let begin = 0; begin < inputsLength; begin += CALL_STACK_LIMIT) { |
| 1668 | const end = Math.min(inputsLength, begin + CALL_STACK_LIMIT); |
| 1669 | const chunk: Array<any> = inputs.slice(begin, end); |
| 1670 | listOfArrays.push(this.ctx.arrayMake(...chunk) as TVMArray); |
| 1671 | } |
| 1672 | return this.ctx.arrayConcat(...listOfArrays) as TVMArray; |
| 1673 | } |
| 1674 | |
| 1675 | /** |
| 1676 | * Join a sequence of Tensors that represent embeddings. |
no test coverage detected