| 91 | }; |
| 92 | |
| 93 | const core::ModulePortSpec kBatchNorm1dEvalInputs[] = { |
| 94 | {"input", core::PortKind::Activation, false}, |
| 95 | {"scale", core::PortKind::Parameter, false}, |
| 96 | {"bias", core::PortKind::Parameter, true}, |
| 97 | }; |
| 98 | |
| 99 | const core::ModuleSchema kBatchNorm1dEvalSchema = { |
| 100 | "BatchNorm1dEval", |
| 101 | "nn.normalization", |
| 102 | kBatchNorm1dEvalInputs, |
| 103 | 3, |
| 104 | kNormOutputs, |
| 105 | 1, |
| 106 | "Applies precomputed 1D batch-normalization eval scale and bias to channel-first tensors.", |
| 107 | }; |
| 108 | |
| 109 | core::TensorValue ensure_f32( |
| 110 | core::ModuleBuildContext & ctx, |
| 111 | const core::TensorValue & value) { |
| 112 | if (value.type == GGML_TYPE_F32) { |
| 113 | return value; |
| 114 | } |
| 115 | return core::wrap_tensor(ggml_cast(ctx.ggml, value.tensor, GGML_TYPE_F32), value.shape, GGML_TYPE_F32); |
| 116 | } |
| 117 | |
| 118 | bool same_shape(const core::TensorShape & lhs, const core::TensorShape & rhs) { |
| 119 | if (lhs.rank != rhs.rank) { |
no test coverage detected