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

Function TEST

tensorflow/lite/experimental/writer/writer_lib_test.cc:26–55  ·  view source on GitHub ↗

Make an interpreter that has no tensors and no nodes TODO(b/113731921): add more tests.

Source from the content-addressed store, hash-verified

24// Make an interpreter that has no tensors and no nodes
25// TODO(b/113731921): add more tests.
26TEST(Writer, BasicTest) {
27 Interpreter interpreter;
28 interpreter.AddTensors(3);
29 float foo[] = {1, 2, 3};
30 interpreter.SetTensorParametersReadWrite(0, kTfLiteFloat32, "a", {3},
31 TfLiteQuantizationParams());
32 interpreter.SetTensorParametersReadOnly(
33 1, kTfLiteFloat32, "b", {3}, TfLiteQuantizationParams(),
34 reinterpret_cast<char*>(foo), sizeof(foo));
35 interpreter.SetTensorParametersReadWrite(2, kTfLiteFloat32, "c", {3},
36 TfLiteQuantizationParams());
37 interpreter.SetInputs({0, 1});
38 interpreter.SetOutputs({2});
39 const char* initial_data = "";
40 tflite::ops::builtin::BuiltinOpResolver resolver;
41 TfLiteAddParams* builtin_data =
42 reinterpret_cast<TfLiteAddParams*>(malloc(sizeof(TfLiteAddParams)));
43 builtin_data->activation = kTfLiteActNone;
44 const TfLiteRegistration* reg = resolver.FindOp(BuiltinOperator_ADD, 1);
45 interpreter.AddNodeWithParameters({0, 1}, {2}, initial_data, 0,
46 reinterpret_cast<void*>(builtin_data), reg);
47
48 InterpreterWriter writer(&interpreter);
49 writer.Write("/tmp/test.tflite");
50 std::unique_ptr<FlatBufferModel> model =
51 FlatBufferModel::BuildFromFile("/tmp/test.tflite");
52 InterpreterBuilder builder(*model, resolver);
53 std::unique_ptr<Interpreter> new_interpreter;
54 builder(&new_interpreter);
55}
56
57} // namespace tflite
58

Callers

nothing calls this directly

Calls 8

AddTensorsMethod · 0.45
SetInputsMethod · 0.45
SetOutputsMethod · 0.45
FindOpMethod · 0.45
AddNodeWithParametersMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected