MCPcopy Create free account
hub / github.com/apache/tvm-ffi / add_one_cpu

Function add_one_cpu

tests/python/test_build.cc:29–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#include <tvm/ffi/function.h>
28
29void add_one_cpu(tvm::ffi::TensorView x, tvm::ffi::TensorView y) {
30 TVM_FFI_ICHECK(x.ndim() == 1) << "x must be a 1D tensor";
31 DLDataType f32_dtype{kDLFloat, 32, 1};
32 TVM_FFI_ICHECK(x.dtype() == f32_dtype) << "x must be a float tensor";
33 TVM_FFI_ICHECK(y.ndim() == 1) << "y must be a 1D tensor";
34 TVM_FFI_ICHECK(y.dtype() == f32_dtype) << "y must be a float tensor";
35 TVM_FFI_ICHECK(x.size(0) == y.size(0)) << "x and y must have the same shape";
36 for (int i = 0; i < x.size(0); ++i) {
37 static_cast<float*>(y.data_ptr())[i] = static_cast<float*>(x.data_ptr())[i] + 1;
38 }
39}
40
41TVM_FFI_DLL_EXPORT_TYPED_FUNC(add_one_cpu, add_one_cpu)

Callers 1

RunFunction · 0.85

Calls 4

ndimMethod · 0.45
dtypeMethod · 0.45
sizeMethod · 0.45
data_ptrMethod · 0.45

Tested by

no test coverage detected