diff options
author | 2018-08-30 11:17:57 -0700 | |
---|---|---|
committer | 2018-08-30 11:23:53 -0700 | |
commit | 9e12f1df3270b5e0b310645e6c3cae9fbd3f5dfc (patch) | |
tree | 6fb67b08ce4747aaf27f40d71a42edab04ea176c /tensorflow/contrib/lite/kernels/pad.cc | |
parent | 35bae087dce1e88c66007907f9e1b6b5b2958f10 (diff) |
Consolidate refactoring of runtime shapes.
PiperOrigin-RevId: 210945714
Diffstat (limited to 'tensorflow/contrib/lite/kernels/pad.cc')
-rw-r--r-- | tensorflow/contrib/lite/kernels/pad.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tensorflow/contrib/lite/kernels/pad.cc b/tensorflow/contrib/lite/kernels/pad.cc index 4be8c243c1..55bcf3b533 100644 --- a/tensorflow/contrib/lite/kernels/pad.cc +++ b/tensorflow/contrib/lite/kernels/pad.cc @@ -134,12 +134,22 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { after_padding.push_back(paddings_data[idx * 2 + 1]); } -#define TF_LITE_PAD(type, scalar, pad_value) \ - type::PadV2(GetTensorData<scalar>(op_context.input), \ - GetTensorDims(op_context.input), before_padding, after_padding, \ - GetTensorData<scalar>(op_context.output), \ - GetTensorDims(op_context.output), pad_value) - +#define TF_LITE_PAD(type, scalar, pad_value) \ + TF_LITE_ENSURE_EQ(context, before_padding.size(), 4); \ + TF_LITE_ENSURE_EQ(context, after_padding.size(), 4); \ + tflite::PadParams op_params; \ + op_params.left_padding_count = 4; \ + op_params.right_padding_count = 4; \ + for (int i = 0; i < 4; ++i) { \ + op_params.left_padding[i] = before_padding[3 - i]; \ + op_params.right_padding[i] = after_padding[3 - i]; \ + } \ + const scalar pad_value_copy = pad_value; \ + \ + type::Pad(op_params, GetTensorShape(op_context.input), \ + GetTensorData<scalar>(op_context.input), &pad_value_copy, \ + GetTensorShape(op_context.output), \ + GetTensorData<scalar>(op_context.output)) switch (op_context.input->type) { case kTfLiteFloat32: { float pad_value = op_context.constant_values == nullptr |