MCPcopy Create free account
hub / github.com/ARM-software/armnn / VisitCastOperator

Function VisitCastOperator

delegate/opaque/src/Redefine.hpp:12–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10{
11
12TfLiteStatus VisitCastOperator(DelegateData& delegateData,
13 TfLiteOpaqueContext* tfLiteContext,
14 TfLiteOpaqueNode* tfLiteNode,
15 int nodeIndex,
16 int32_t operatorCode)
17{
18 TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
19 TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
20 int numInputs = 0;
21 const int* inputTensors;
22 if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk)
23 {
24 return kTfLiteError;
25 }
26
27 // This layer only has 1 input, so we can directly assign tensor[0] to a new opaque tensor
28 const TfLiteOpaqueTensor*
29 tfLiteInputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[numInputs-1]);
30 if (!IsValid(tfLiteContext, tfLiteInputTensor, operatorCode, nodeIndex))
31 {
32 return kTfLiteError;
33 }
34
35 int numOutputs = 0;
36 const int* outputTensors;
37 if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors, &numOutputs) != kTfLiteOk)
38 {
39 return kTfLiteError;
40 }
41
42 // This layer only has 1 output, so we can directly assign tensor[0] to a new opaque tensor
43 const TfLiteOpaqueTensor*
44 tfLiteOutputTensor = TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputTensors[numOutputs-1]);
45 if (!IsValid(tfLiteContext, tfLiteOutputTensor, operatorCode, nodeIndex))
46 {
47 return kTfLiteError;
48 }
49
50 const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor);
51 const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteOutputTensor, true);
52
53 bool isSupported = false;
54 armnn::BackendId setBackend;
55 auto validateFunc = [&](const armnn::TensorInfo& outInfo, bool& isSupported) {
56 FORWARD_LAYER_OPAQUE_SUPPORT_FUNC("CAST",
57 tfLiteContext,
58 IsCastSupported,
59 delegateData.m_Backends,
60 isSupported,
61 setBackend,
62 inputTensorInfo,
63 outInfo);
64 };
65
66 // If the m_Network is a nullptr, this signals that a prerequisite TfLite callback is required to clarify the
67 // support for the operator
68 // If supported, VisitCastOperator will be called again to add the layer to the network as seen further below
69 if (!delegateData.m_Network)

Callers 1

VisitNodeMethod · 0.70

Calls 12

GetNameFunction · 0.85
AddCastLayerMethod · 0.80
GetOutputSlotMethod · 0.80
ValidateNumInputsFunction · 0.70
ValidateNumOutputsFunction · 0.70
IsValidFunction · 0.70
ProcessInputsFunction · 0.70
ConnectFunction · 0.70
c_strMethod · 0.45
SetBackendIdMethod · 0.45
SetTensorInfoMethod · 0.45

Tested by

no test coverage detected