@@ -94,7 +94,6 @@ ComputeContext* NeuralNet::createComputeContext(
9494 ConfigParser& cfg) {
9595 (void )gpuIdxs;
9696 (void )logger;
97- (void )loadedModel;
9897
9998 ComputeContext* context = new ComputeContext ();
10099 context->nnXLen = nnXLen;
@@ -105,11 +104,12 @@ ComputeContext* NeuralNet::createComputeContext(
105104 // nvonnxparser (the default). trtDisableOnnx=true falls back to the hand-built ModelParser, which
106105 // supports convnets only (transformer models will error in createComputeHandle).
107106 context->useOnnx = !(cfg.contains (" trtDisableOnnx" ) ? cfg.getBool (" trtDisableOnnx" ) : false );
108- // ONNX transformer emitter layout. Default is NCHW (genuine channel-major attention/FFN): benchmarks
109- // show it matches or slightly beats the NHWC bubble path at the saturated throughput operating point
110- // KataGo runs at, and it's the simpler graph. trtTransformerNHWC=true opts into the NHWC path (whole
111- // trunk channel-last with NCHW<->NHWC conversions around it), which wins on single-stream latency.
112- context->transformerNHWC = cfg.contains (" trtTransformerNHWC" ) ? cfg.getBool (" trtTransformerNHWC" ) : false ;
107+ // Transformer trunks default to NHWC, which benchmarks at least as fast as NCHW across tested GPUs
108+ // and TensorRT versions. Explicit false remains available for hardware-specific tuning. Normalize
109+ // convnets to false since the ONNX builder ignores this setting for models without transformers.
110+ context->transformerNHWC =
111+ (cfg.contains (" trtTransformerNHWC" ) ? cfg.getBool (" trtTransformerNHWC" ) : true ) &&
112+ NeuralNet::getModelDesc (loadedModel).hasAnyTransformerBlocks ();
113113 // Debugging: if set, the ONNX-emitter path dumps the emitted ONNX model and the built engine's
114114 // per-layer info (precision/format/tactic, via a detailed-profiling build + IEngineInspector) into
115115 // this directory. Files are disambiguated by board size, FP16/FP32, and exact/max NN-length so the
0 commit comments