cyx-6 commented on a change in pull request #51:
URL: https://github.com/apache/tvm-rfcs/pull/51#discussion_r781780791



##########
File path: rfcs/0051-PackedFunc-as-Object.md
##########
@@ -0,0 +1,82 @@
+- Feature Name: PackedFunc as Object
+- Start Date: 2022-01-01
+- RFC PR: https://github.com/apache/tvm-rfcs/pull/51/
+- GitHub Issue: TBD
+
+## 1. Summary
+
+This RFC allows developers to use `PackedFunc` as TVM objects, which completes 
the last missing step of TVM runtime object system.
+
+## 2. Motivation
+
+Historically, several fundamental data structures in TVM are not part of the 
runtime object system, namely `NDArray` (not object), `Module` (not object), 
`String` (not exist), `Array` (not in runtime), `Map` (not in runtime), 
`PackedFunc` (not yet an object).
+
+The rationale of the original design is mainly for simplicity, which is 
desirable for the usecases as a monolithic compiler. As time goes on, the 
community has come to realize the fact that the object system should be 
inclusive enough and by design allow more convenient integration with vendor 
libraries. Therefore, as part of the effort in TVM refactoring and TVM Unity, 
recent work strives to re-implement these core data structures to be consistent 
with the runtime object protocol with stable ABI guarantee, and thus could be 
passed across the DLL boundary.
+
+As the central piece of the TVM ecosystem, this proposal focuses on making 
`PackedFunc` a TVM object. By doing so, it completes the last missing piece of 
the object ecosystem, allows TVM containers to carry `PackedFunc`s, and enables 
`PackedFunc`s to be passed across the DLL boundary to bring convenience to the 
vendor library integration.
+
+
+## 3. Guide-level introduction
+
+This is mainly a developer-facing feature, and thus there is no sensible 
change to the existing functionalities to the end users, who are still supposed 
to use the same `PackedFunc` API.
+
+Only one major object is introduced, `PackedFuncObj`, a TVM object in the 
runtime system (detailed in the next section) which is an ABI stable data 
structure for packed functions that could be shared across language and DLL 
boundary.
+
+To avoid API misuse from developers, the `PackedFuncObj` cannot be created or 
manipulated directly, and the specialization of its creation 
`make_object<PackedFuncObj>` will be deleted for safety. Instead, the 
developer-facing class `PackedFunc` remains responsible for creating and 
managing the object, and for properly setting its content.

Review comment:
       Sure. Since the `PackedFuncObj` is an abstract object only, it is not 
allowed to be created directly, while its derived classes are allowed to do so. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to