[tf.data] Add a pass-thru implementation of ModelDataset for tf-mobile.

Mobile already has a pass-thru for `OptimizeDataset` and hence doesn't benefit from the modeling.

PiperOrigin-RevId: 332944390
Change-Id: If5b085a7ec77ff003f514e685fc08269185e4f07
This commit is contained in:
Zachary Garrett 2020-09-21 15:09:41 -07:00 committed by TensorFlower Gardener
parent fcd71326f3
commit 5c1a75db45
2 changed files with 38 additions and 0 deletions

View File

@ -1449,6 +1449,7 @@ filegroup(
exclude = [
"dataset_ops*", # includes grappler dependency, which isn't supported on mobile.
"optimize_dataset_op.*", # includes grappler dependency, which isn't supported on mobile.
"model_dataset_op.*", # not supported on mobile.
"rewrite_utils*", # includes grappler dependency, which isn't supported on mobile.
"*test.cc",
"*test.h",

View File

@ -0,0 +1,37 @@
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/core/framework/dataset.h"
namespace tensorflow {
namespace data {
class ModelDatasetOp : public UnaryDatasetOpKernel {
public:
explicit ModelDatasetOp(OpKernelConstruction* ctx)
: UnaryDatasetOpKernel(ctx) {}
void MakeDataset(OpKernelContext* ctx, DatasetBase* input,
DatasetBase** output) {
input->Ref();
*output = input;
}
};
namespace {
REGISTER_KERNEL_BUILDER(Name("ModelDataset").Device(DEVICE_CPU),
ModelDatasetOp);
} // namespace
} // namespace data
} // namespace tensorflow