Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions diopi_test/python/conformance/diopi_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,8 @@ def cross_entropy(
weight = weight
else:
weight = None

totalWeight = Tensor((1,), input.get_dtype())

sizeI = input.size().data
sizeO = [sizeI[0]] + sizeI[2:]
Expand All @@ -956,7 +958,7 @@ def cross_entropy(
out = Tensor((), input.get_dtype())

reduction_mode = convert_reduction(reduction)
func = check_function("diopiCrossEntropyLoss")
func = check_function("diopiCrossEntropyLossWithTotalWeight")
ret = func(
input.context(),
out,
Expand All @@ -968,6 +970,7 @@ def cross_entropy(
label_smoothing,
)
check_returncode(ret)
GLOBAL_STATE["cross_entropy_totalWeight"] = totalWeight
return out


Expand Down Expand Up @@ -4640,9 +4643,11 @@ def cross_entropy_backward(
weight = weight
else:
weight = None

totalWeight = GLOBAL_STATE.pop("cross_entropy_totalWeight")

reduction_mode = convert_reduction(reduction)
func = check_function("diopiCrossEntropyLossBackward")
func = check_function("diopiCrossEntropyLossWithTotalWeightBackward")
ret = func(
input.context(),
grad_input,
Expand Down
8 changes: 8 additions & 0 deletions impl/ascend/convert_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,11 @@
- diopiMaxPool2dBackward:
tensor_dtype:
indices: (int64)->int32

- diopiCrossEntropyLossWithTotalWeight:
dtype: (float64)->float32
layout: ND

- diopiCrossEntropyLossWithTotalWeightBackward:
dtype: (float64)->float32
layout: ND
Loading