aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/tensorrt/ops/trt_engine_op.cc
blob: e0c7b6272379a20e3dacb6cd7c3b39de735d844d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* 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.
==============================================================================*/

#if GOOGLE_CUDA
#if GOOGLE_TENSORRT

#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/shape_inference.h"
#include "tensorflow/core/framework/tensor_shape.h"

namespace tensorflow {

namespace shape_inference {
extern Status TRTEngineOpShapeInference(InferenceContext* c);
}

REGISTER_OP("TRTEngineOp")
    .Attr("serialized_segment: string")
    .Attr("input_shapes: list(shape)")
    .Attr("output_shapes: list(shape)")
    .Attr("segment_funcdef_name: string")
    .Attr("InT: list({int8,float16,float32})")
    .Attr("OutT: list({int8,float16,float32})")
    .Attr("static_engine: bool = true")
    .Attr("fixed_input_size: bool = true")
    .Attr("cached_engine_batches: list(int) = []")
    .Attr("max_cached_engines_count: int = 1")
    .Attr("workspace_size_bytes: int")
    .Attr("precision_mode: {'FP32', 'FP16', 'INT8', 'INT8CALIB'}")
    .Attr("calibration_data: string = ''")
    .Input("in_tensor: InT")
    .Output("out_tensor: OutT");
// TODO(jie): TF requires concrete output shape for concrete input shapes.
// This is tricky for batch dimension, since we cannot ensure which input
// would carry the correct batch dimension (for the current stage of the
// implementation, we do require all input tensor to carry the same batch
// size, but this could change in the future). Hence we disable shape
// inference function as a workaround.
// .SetShapeFn(shape_inference::TRTEngineOpShapeInference);

}  // namespace tensorflow

#endif  // GOOGLE_TENSORRT
#endif  // GOOGLE_CUDA