[tf.lite] Mark the tensor # as the tensor name for testing

For synthetic kernel tests, use the tensor index # as the tensor name to
simplify debugging.

PiperOrigin-RevId: 356391830
Change-Id: I0f52876c2080a68574b550cfb8ec90cf3c776a7a
This commit is contained in:
Jared Duke 2021-02-08 17:33:51 -08:00 committed by TensorFlower Gardener
parent 6df72f44ff
commit dac302eeed
2 changed files with 22 additions and 15 deletions

View File

@ -112,10 +112,13 @@ int SingleOpModel::AddIntermediate(TensorType type,
CreateQuantizationParameters(builder_, /*min=*/0, /*max=*/0,
builder_.CreateVector<float>(scale),
builder_.CreateVector<int64_t>(zero_point));
tensors_.push_back(CreateTensor(builder_, builder_.CreateVector<int>({}),
type,
/*buffer=*/0,
/*name=*/0, q_params, false));
tensors_.push_back(
CreateTensor(builder_, builder_.CreateVector<int>({}), type,
/*buffer=*/0,
/*name=*/
builder_.CreateString("Intermediate:" +
std::to_string(intermediates_.size())),
q_params, false));
intermediates_.push_back(id);
return id;
}

View File

@ -277,7 +277,8 @@ class SingleOpModel {
tensors_.push_back(CreateTensor(
builder_, builder_.CreateVector<int>(t.shape), t.type,
/*buffer=*/buffer_id,
/*name=*/0, /*quantization=*/0, /*is_variable=*/false, s_param));
/*name=*/builder_.CreateString(std::to_string(tensors_.size())),
/*quantization=*/0, /*is_variable=*/false, s_param));
inputs_.push_back(id);
tensor_data_[id] = t;
@ -361,11 +362,12 @@ class SingleOpModel {
}
}
tensors_.push_back(
CreateTensor(builder_, builder_.CreateVector<int>(t.shape),
symmetric_quantize ? TensorType_INT8 : t.type,
/*buffer=*/buffer_id,
/*name=*/0, q_params, /*is_variable=*/false, s_param));
tensors_.push_back(CreateTensor(
builder_, builder_.CreateVector<int>(t.shape),
symmetric_quantize ? TensorType_INT8 : t.type,
/*buffer=*/buffer_id,
/*name=*/builder_.CreateString(std::to_string(tensors_.size())),
q_params, /*is_variable=*/false, s_param));
inputs_.push_back(id);
tensor_data_[id] = t;
@ -683,7 +685,8 @@ class SingleOpModel {
tensors_.push_back(CreateTensor(
builder_, builder_.CreateVector<int>(t.shape), t.type,
/*buffer=*/buffer_id,
/*name=*/0, q_params, is_variable,
/*name=*/builder_.CreateString(std::to_string(tensors_.size())),
q_params, is_variable,
/*sparsity=*/0, builder_.CreateVector<int>(t.shape_signature)));
tensor_data_[id] = t;
@ -797,10 +800,11 @@ class SingleOpModel {
buffers_.push_back(CreateBuffer(builder_, data_buffer));
}
tensors_.push_back(
CreateTensor(builder_, builder_.CreateVector<int>(t.shape), t.type,
/*buffer=*/buffer_id,
/*name=*/0, q_params, /*is_variable=*/false));
tensors_.push_back(CreateTensor(
builder_, builder_.CreateVector<int>(t.shape), t.type,
/*buffer=*/buffer_id,
/*name=*/builder_.CreateString(std::to_string(tensors_.size())),
q_params, /*is_variable=*/false));
tensor_data_[id] = t;
return id;
}