MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / where

Function where

imperative/python/megengine/xla/rules/tensor.py:219–224  ·  view source on GitHub ↗
(mask, x, y)

Source from the content-addressed store, hash-verified

217
218
219def where(mask, x, y):
220 assert isinstance(mask, HLOTensor), f"mask must be HLOTensor, get {type(mask)}"
221 x = x if isinstance(x, HLOTensor) else HLOTensor(x)
222 y = y if isinstance(y, HLOTensor) else HLOTensor(y)
223
224 return mask * x + (np.array(1.0).astype(x.dtype) - mask) * y
225
226
227def where_grad(dout, mask):

Callers 11

abs_gradFunction · 0.70
hsigmoidFunction · 0.70
hsigmoid_gradFunction · 0.70
relu6_gradFunction · 0.70
hswish_gradFunction · 0.70
logsigmoidFunction · 0.70
softplus_gradFunction · 0.70
resize_linear_helperFunction · 0.70
_parse_subtensor_itemsFunction · 0.70
linspaceFunction · 0.70
where_lowerFunction · 0.70

Calls 3

HLOTensorClass · 0.85
arrayMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected