MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CopyShapeAndType

Function CopyShapeAndType

tensorflow/lite/delegates/flex/util.cc:29–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29TfLiteStatus CopyShapeAndType(TfLiteContext* context,
30 const tensorflow::Tensor& src,
31 TfLiteTensor* tensor) {
32 tensor->type = GetTensorFlowLiteType(static_cast<TF_DataType>(src.dtype()));
33 if (tensor->type == kTfLiteNoType) {
34 context->ReportError(context,
35 "TF Lite does not support TensorFlow data type: %s",
36 DataTypeString(src.dtype()).c_str());
37 return kTfLiteError;
38 }
39
40 int num_dims = src.dims();
41 TfLiteIntArray* shape = TfLiteIntArrayCreate(num_dims);
42 for (int j = 0; j < num_dims; ++j) {
43 // We need to cast from TensorFlow's int64 to TF Lite's int32. Let's
44 // make sure there's no overflow.
45 if (src.dim_size(j) >= std::numeric_limits<int>::max()) {
46 context->ReportError(context,
47 "Dimension value in TensorFlow shape is larger than "
48 "supported by TF Lite");
49 TfLiteIntArrayFree(shape);
50 return kTfLiteError;
51 }
52 shape->data[j] = static_cast<int>(src.dim_size(j));
53 }
54 return context->ResizeTensor(context, tensor, shape);
55}
56
57TF_DataType GetTensorFlowDataType(TfLiteType type) {
58 switch (type) {

Callers 2

EvalFunction · 0.85
TESTFunction · 0.85

Calls 11

GetTensorFlowLiteTypeFunction · 0.85
TfLiteIntArrayCreateFunction · 0.85
TfLiteIntArrayFreeFunction · 0.85
c_strMethod · 0.80
ResizeTensorMethod · 0.80
DataTypeStringFunction · 0.50
maxFunction · 0.50
dtypeMethod · 0.45
ReportErrorMethod · 0.45
dimsMethod · 0.45
dim_sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68