* Register an object constructor. * @param typeKey The name of the function. * @param func Function to be registered. * @param override Whether overwrite function in existing registry.
(
typeKey: string,
func: FObjectConstructor,
override = false
)
| 1743 | * @param override Whether overwrite function in existing registry. |
| 1744 | */ |
| 1745 | registerObjectConstructor( |
| 1746 | typeKey: string, |
| 1747 | func: FObjectConstructor, |
| 1748 | override = false |
| 1749 | ): void { |
| 1750 | const typeIndex = this.typeKey2Index(typeKey); |
| 1751 | if (this.objFactory.has(typeIndex)) { |
| 1752 | if (!override) { |
| 1753 | throw new Error("Type " + typeKey + " already registered"); |
| 1754 | } |
| 1755 | } |
| 1756 | this.objFactory.set(typeIndex, func); |
| 1757 | } |
| 1758 | |
| 1759 | /** |
| 1760 | * Wrap a function obtained from tvm runtime as AsyncPackedFunc |
no test coverage detected