//TEST:SIMPLE(filecheck=CHECK): -target spirv // This is a test that checks that we can apply partial specialization to a function // we won't specialize the function parameters too aggressively. Instead, we will specialize // the parameters at the same time of specializing the arguments. Otherwise, we could lose // the chance to specialize the argument. // // In this test, `matrix_vector_interfaces` will be fully specialized, otherwise the compile // will fail because we don't allow opaque type in the existential type. So as long as the target // spirv code can be generated, we are good. // CHECK: %main public interface ITensor { public T get(int idx); } public interface IRWTensor : ITensor { } public struct RWTensor : IRWTensor { public RWStructuredBuffer buffer; public T get(int idx) { return buffer[idx]; } } public struct GradInOutTensor : IRWTensor { public RWTensor primal; public T get(int idx) { return primal.get(idx); } } struct CallData { GradInOutTensor weights; GradInOutTensor biases; RWStructuredBuffer _result; } ParameterBlock call_data; float matrix_vector_interfaces(ITensor weights, ITensor biases) { return weights.get(0); } [shader("compute")] [numthreads(1, 1, 1)] void main(uint3 dispatchThreadID: SV_DispatchThreadID) { float _result; GradInOutTensor weights; GradInOutTensor biases; weights.primal.buffer = call_data.weights.primal.buffer; biases.primal.buffer = call_data.biases.primal.buffer; _result = matrix_vector_interfaces(weights, biases); call_data._result[0] = _result; }