| 68 | } |
| 69 | |
| 70 | Status SpectrogramShapeFn(InferenceContext* c) { |
| 71 | ShapeHandle input; |
| 72 | TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &input)); |
| 73 | int32 window_size; |
| 74 | TF_RETURN_IF_ERROR(c->GetAttr("window_size", &window_size)); |
| 75 | int32 stride; |
| 76 | TF_RETURN_IF_ERROR(c->GetAttr("stride", &stride)); |
| 77 | |
| 78 | DimensionHandle input_length = c->Dim(input, 0); |
| 79 | DimensionHandle input_channels = c->Dim(input, 1); |
| 80 | |
| 81 | DimensionHandle output_length; |
| 82 | if (!c->ValueKnown(input_length)) { |
| 83 | output_length = c->UnknownDim(); |
| 84 | } else { |
| 85 | const int64 input_length_value = c->Value(input_length); |
| 86 | const int64 length_minus_window = (input_length_value - window_size); |
| 87 | int64 output_length_value; |
| 88 | if (length_minus_window < 0) { |
| 89 | output_length_value = 0; |
| 90 | } else { |
| 91 | output_length_value = 1 + (length_minus_window / stride); |
| 92 | } |
| 93 | output_length = c->MakeDim(output_length_value); |
| 94 | } |
| 95 | |
| 96 | DimensionHandle output_channels = |
| 97 | c->MakeDim(1 + NextPowerOfTwo(window_size) / 2); |
| 98 | c->set_output(0, |
| 99 | c->MakeShape({input_channels, output_length, output_channels})); |
| 100 | return Status::OK(); |
| 101 | } |
| 102 | |
| 103 | Status MfccShapeFn(InferenceContext* c) { |
| 104 | ShapeHandle spectrogram; |
nothing calls this directly
no test coverage detected