Skip to content

optimize_for_inference.py should remove Dropout operations #5867

@mattrajca

Description

@mattrajca

When I first tried using an exported MNIST model with TensorFlow on iOS, I got the following error:

Invalid argument: No OpKernel was registered to support Op 'RandomUniform' with these attrs.  Registered devices: [CPU], Registered kernels:
  <no registered kernels>

     [[Node: dropout/random_uniform/RandomUniform = RandomUniform[T=DT_INT32, dtype=DT_FLOAT, seed=0, seed2=0](dropout/Shape)]]

Since Dropout operations are no-ops during inference (we pass in a keep probability of 1), it would be nice if they were removed (or turned into no-ops of some kind that can be parsed and ignored by the iOS library).

While I was able to work around this by explicitly exporting a separate graph that does not contain Dropout, it was pretty tedious and it would be nice if the optimize_for_inference.py script did this automatically.

Environment info

Operating System: macOS 10.12

Installed version of CUDA and cuDNN:
None

Source:
This week's tip-of-tree (around d93d526)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions