Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 60194ec

Browse files
Adding NVIDIA Example Models
1 parent 653ea0a commit 60194ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+11403
-3
lines changed

tftrt/examples/benchmark_utils.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,35 @@ def aggregate_data(self, y_pred, y):
190190
self._predicted[key][idx_start:idx_stop] = y_pred[key]
191191
for key, val in self._expected.items():
192192
self._expected[key][idx_start:idx_stop] = y[key]
193+
194+
195+
def patch_dali_dataset(dataset):
196+
import nvidia.dali.plugin.tf as dali_tf
197+
198+
if not isinstance(dataset, dali_tf.DALIDataset):
199+
raise TypeError(
200+
"Dataset supplied should be an instance of `DALIDataset`."
201+
f"Received: `{type(dataset)}`"
202+
)
203+
204+
def take(self, limit):
205+
class _Dataset(self.__class__):
206+
207+
def __init__(self, _ds, _limit):
208+
self._ds = _ds
209+
self._limit = _limit
210+
211+
def __iter__(self):
212+
idx = 0
213+
for data in self._ds:
214+
if idx >= self._limit:
215+
break
216+
yield data
217+
idx += 1
218+
219+
return _Dataset(self, limit)
220+
221+
# Monkey Patch
222+
dataset.__class__.take = take
223+
224+
return dataset

tftrt/examples/image_classification/image_classification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def evaluate_model(self, predictions, expected, bypass_data_to_eval):
219219
This computes overall accuracy, mAP, etc. Returns the
220220
metric value and a metric_units string naming the metric.
221221
222-
Note: script arguments can be accessed using `args.attr`
222+
Note: script arguments can be accessed using `self._args.attr`
223223
"""
224224

225225
return (
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
2+
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
3+
4+
signature_def['__saved_model_init_op']:
5+
The given SavedModel SignatureDef contains the following input(s):
6+
The given SavedModel SignatureDef contains the following output(s):
7+
outputs['__saved_model_init_op'] tensor_info:
8+
dtype: DT_INVALID
9+
shape: unknown_rank
10+
name: NoOp
11+
Method name is:
12+
13+
signature_def['serving_default']:
14+
The given SavedModel SignatureDef contains the following input(s):
15+
inputs['input_mask'] tensor_info:
16+
dtype: DT_INT32
17+
shape: (-1, 384)
18+
name: serving_default_input_mask:0
19+
inputs['input_type_ids'] tensor_info:
20+
dtype: DT_INT32
21+
shape: (-1, 384)
22+
name: serving_default_input_type_ids:0
23+
inputs['input_word_ids'] tensor_info:
24+
dtype: DT_INT32
25+
shape: (-1, 384)
26+
name: serving_default_input_word_ids:0
27+
The given SavedModel SignatureDef contains the following output(s):
28+
outputs['end_positions'] tensor_info:
29+
dtype: DT_FLOAT
30+
shape: (-1, 384)
31+
name: StatefulPartitionedCall:0
32+
outputs['start_positions'] tensor_info:
33+
dtype: DT_FLOAT
34+
shape: (-1, 384)
35+
name: StatefulPartitionedCall:1
36+
Method name is: tensorflow/serving/predict
37+
38+
Defined Functions:
39+
Function Name: '__call__'
40+
Option #1
41+
Callable with:
42+
Argument #1
43+
DType: list
44+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_word_ids'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_mask'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_type_ids'), ]
45+
Argument #2
46+
DType: bool
47+
Value: True
48+
Argument #3
49+
DType: NoneType
50+
Value: None
51+
Option #2
52+
Callable with:
53+
Argument #1
54+
DType: list
55+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/0'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/1'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/2'), ]
56+
Argument #2
57+
DType: bool
58+
Value: True
59+
Argument #3
60+
DType: NoneType
61+
Value: None
62+
Option #3
63+
Callable with:
64+
Argument #1
65+
DType: list
66+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_word_ids'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_mask'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_type_ids'), ]
67+
Argument #2
68+
DType: bool
69+
Value: False
70+
Argument #3
71+
DType: NoneType
72+
Value: None
73+
Option #4
74+
Callable with:
75+
Argument #1
76+
DType: list
77+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/0'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/1'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/2'), ]
78+
Argument #2
79+
DType: bool
80+
Value: False
81+
Argument #3
82+
DType: NoneType
83+
Value: None
84+
85+
Function Name: '_default_save_signature'
86+
Option #1
87+
Callable with:
88+
Argument #1
89+
DType: list
90+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_word_ids'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_mask'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_type_ids'), ]
91+
92+
Function Name: 'call_and_return_all_conditional_losses'
93+
Option #1
94+
Callable with:
95+
Argument #1
96+
DType: list
97+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/0'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/1'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/2'), ]
98+
Argument #2
99+
DType: bool
100+
Value: True
101+
Argument #3
102+
DType: NoneType
103+
Value: None
104+
Option #2
105+
Callable with:
106+
Argument #1
107+
DType: list
108+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/0'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/1'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='inputs/2'), ]
109+
Argument #2
110+
DType: bool
111+
Value: False
112+
Argument #3
113+
DType: NoneType
114+
Value: None
115+
Option #3
116+
Callable with:
117+
Argument #1
118+
DType: list
119+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_word_ids'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_mask'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_type_ids'), ]
120+
Argument #2
121+
DType: bool
122+
Value: True
123+
Argument #3
124+
DType: NoneType
125+
Value: None
126+
Option #4
127+
Callable with:
128+
Argument #1
129+
DType: list
130+
Value: [TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_word_ids'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_mask'), TensorSpec(shape=(None, 384), dtype=tf.int32, name='input_type_ids'), ]
131+
Argument #2
132+
DType: bool
133+
Value: False
134+
Argument #3
135+
DType: NoneType
136+
Value: None

0 commit comments

Comments
 (0)