MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SpectrogramShapeFn

Function SpectrogramShapeFn

tensorflow/core/ops/audio_ops.cc:70–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70Status 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
103Status MfccShapeFn(InferenceContext* c) {
104 ShapeHandle spectrogram;

Callers

nothing calls this directly

Calls 11

ValueKnownMethod · 0.80
UnknownDimMethod · 0.80
NextPowerOfTwoFunction · 0.50
WithRankMethod · 0.45
inputMethod · 0.45
GetAttrMethod · 0.45
DimMethod · 0.45
ValueMethod · 0.45
MakeDimMethod · 0.45
set_outputMethod · 0.45
MakeShapeMethod · 0.45

Tested by

no test coverage detected