I’ve been working on porting CTC loss to THNN and got confused by the sparse documentation out there.
The particular implementation I’m basing my work on computes loss and gradients in a single operation (or rather doesn’t even calculate an absolute loss). The easiest way to fit this into THNN would be to run the whole alignment twice, once in updateOutput and once in updateGradInput but that is obviously twice as slow as doing it once.
Some old documentation mentions that updateGradInput has to run after updateOutput which I interpret that there is some way data is shareable between both functions. All other *Criterion.c implementations just calculate the gradient directly from input and target arguments and I am not even pretending to understand the preprocessor hell that is most of THNN.
If there’s someone knowledgeable of THNN around I’d also like to know the amount of error checking functions are expected to perform. Some do this rather extensively, others only basic sanity checks.