Menooker commented on a change in pull request #5601:
URL: https://github.com/apache/incubator-tvm/pull/5601#discussion_r428427694



##########
File path: include/tvm/runtime/c_runtime_api.h
##########
@@ -114,6 +114,7 @@ typedef enum {
   kTVMNNVMLast = 20U,
   // The following section of code is used for non-reserved types.
   kTVMExtReserveEnd = 64U,
+  kTVMBFloat = 65U,

Review comment:
       If we remove this type from TVM runtime, we cannot pass a bf16 array to 
TVM via Python and users can only pass bf16 buffers via C runtime (or in some 
awkward way to construct a bf16 DLTensor via Python). Currently, with  
kTVMBFloat defined, we can:
   
   ```python
           A = te.placeholder((32, ), dtype='bfloat16')
           B = te.placeholder((32, ), dtype='bfloat16')
           d = te.compute((32, ), lambda x: A[x] + B[x])
           sch = te.create_schedule(d.op)
           module = tvm.build(sch, [A, B, d])
           npa = np.random.rand(32).astype('float32')
           npb = np.random.rand(32).astype('float32')
           a_ = np_float2tvm_bf16(npa)
           b_ = np_float2tvm_bf16(npb)
           c_ = tvm.nd.empty((32,), 'bfloat16')
           module(a_, b_, c_)
   ```
   
   Which is useful for testing and prototyping.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to