Skip to content

Commit ef9eec1

Browse files
author
ssjia
committed
Update
[ghstack-poisoned]
2 parents 7bcefe2 + 9e2428d commit ef9eec1

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

backends/vulkan/runtime/graph/ops/impl/BinaryScalarOp.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,13 @@ namespace vkcompute {
2424

2525
namespace {
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-
*/
3927
vkapi::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
}

backends/vulkan/test/op_tests/cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)