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 @@ -961,10 +961,12 @@ def cross_entropy(
out = Tensor((), input.get_dtype())

reduction_mode = convert_reduction(reduction)
func = check_function("diopiCrossEntropyLoss")
totalWeight = Tensor((1,), input.get_dtype())
func = check_function("diopiCrossEntropyLossWithTotalWeight")
ret = func(
input.context(),
out,
totalWeight,
input,
target,
weight,
Expand All @@ -973,6 +975,7 @@ def cross_entropy(
label_smoothing,
)
check_returncode(ret)
GLOBAL_STATE["cross_entropy_totalWeight"] = totalWeight
return out


Expand Down Expand Up @@ -4713,14 +4716,16 @@ def cross_entropy_backward(
weight = None

reduction_mode = convert_reduction(reduction)
func = check_function("diopiCrossEntropyLossBackward")
func = check_function("diopiCrossEntropyLossWithTotalWeightBackward")
totalWeight = GLOBAL_STATE.pop("cross_entropy_totalWeight")
ret = func(
input.context(),
grad_input,
grad_outputs[0],
input,
target,
weight,
totalWeight,
reduction_mode,
ignore_index,
label_smoothing,
Expand Down
10 changes: 9 additions & 1 deletion impl/ascend/convert_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,19 @@
tensor_dtype:
indices: (int64)->int32

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

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

- diopiBatchNormStats:
dtype: (float64)->float32

- diopiBatchNormGatherStatsWithCounts:
dtype: (float64)->float32

- diopiBatchNormBackwardReduce:
dtype: (float64)->float32
dtype: (float64)->float32
25 changes: 1 addition & 24 deletions impl/ascend/device_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,30 +308,7 @@
rtol=1e-4,
),

'cross_entropy': dict(
name=['cross_entropy'],
tensor_para=dict(
args=[
{
"ins": ['input'],
"shape": [Skip((1024, 81)),Skip((3, 9)),Skip((64, 9)),Skip((5, 9, 12, 4)),Skip((0, 16)),Skip((0, 5, 6)),Skip((4, 6, 0, 3)),],
},
]
),
),

'cross_entropy_empty_tensor': dict(
name=['cross_entropy'],
tensor_para=dict(
args=[
{
"ins": ['input'],
"shape": [Skip((5, 0)),],
},
]
),
),

# target not implemented for DT_FLOAT, should be in dtype support list [DT_INT64,DT_UINT8,DT_INT32,].
'cross_entropy_prob_target': dict(
name=['cross_entropy'],
tensor_para=dict(
Expand Down
Loading