  Shape optimization approaches to inverse design offer low-dimensional,
physically-guided parameterizations of structures by representing them as
combinations of shape primitives. However, on discretized rectilinear
simulation grids, computing the gradient of a user objective via the adjoint
variables method requires a sum reduction of the forward/adjoint field
solutions and the Jacobian of the simulation material distribution with respect
to the structural shape parameters. These shape parameters often perturb large
or global parts of the simulation grid resulting in many non-zero Jacobian
entries, which are typically computed by finite-difference in practice.
Consequently, the gradient calculation can be non-trivial. In this work we
propose to accelerate the gradient calculation by invoking automatic
differentiation (AutoDiff) in instantiations of structural material
distributions. In doing so, we develop extensible differentiable mappings from
shape parameters to shape primitives and differentiable effective logic
operations (denoted AutoDiffGeo). These AutoDiffGeo definitions may introduce
some additional discretization error into the field solutions because they
relax notions of sub-pixel smoothing along shape boundaries. However, we show
that some mappings (e.g. simple cuboids) can achieve zero error with respect to
volumetric averaging strategies. We demonstrate AutoDiff enhanced shape
optimization using three integrated photonic examples: a multi-etch blazed
grating coupler, a non-adiabatic waveguide transition taper, and a
polarization-splitting grating coupler. We find accelerations of the gradient
calculation by AutoDiff relative to finite-difference often exceed 50x,
resulting in total wall time accelerations of 4x or more on the same hardware
with little or no compromise to final device performance. Our code is available
open source at https://github.com/smhooten/emopt
