File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,22 +24,13 @@ namespace vkcompute {
2424
2525namespace {
2626
27- /*
28- * Currently, only a few shader variants are generated for "compatible" tensor
29- * dtype / scalar dtype pairs. In particular float/half tensor + float scalar,
30- * and int32 tensor + int32 scalar. This function coerces the scalar dtype so
31- * that a "higher precision" tensor dtype (i.e. float, half) can be used with a
32- * "lower precision" scalar dtype (i.e. int32) with the current generated shader
33- * variants. "Lower precision" tensor dtype (i.e. int32) + "higher precision"
34- * scalar dtype (i.e. float/half) are currently not supported because the shader
35- * currently casts the scalar to the tensor dtype before computation. Though
36- * these combinations are not expected to be needed, if they are required in the
37- * future, update the shaders with more robust dtype handling.
38- */
3927vkapi::ScalarType resolve_scalar_extract_dtype (
4028 ComputeGraph& graph,
4129 const ValueRef scalar,
4230 const vkapi::ScalarType tensor_dtype) {
31+ // For float tensors, ensure that the scalar argument is extracted as a float
32+ // to avoid having to generate additional shader variants for float/half
33+ // tensor + int scalar.
4334 if (tensor_dtype == vkapi::kFloat || tensor_dtype == vkapi::kHalf ) {
4435 return vkapi::kFloat ;
4536 }
Original file line number Diff line number Diff line change @@ -2247,6 +2247,6 @@ def get_eq_scalar_inputs():
22472247 "utils::kWidthPacked" ,
22482248 "utils::kChannelsPacked" ,
22492249 ]
2250- test_suite .dtypes = ["at::kInt" ]
2250+ test_suite .dtypes = ["at::kInt" , "at::kFloat" ]
22512251 test_suite .data_gen = "make_seq_tensor"
22522252 return test_suite
You can’t perform that action at this time.
0 commit comments