@@ -2519,8 +2519,8 @@ def bmm(x: Tensor, y: Tensor, name: str | None = None) -> Tensor:
25192519def histogram (
25202520 input : Tensor ,
25212521 bins : int = 100 ,
2522- min : int = 0 ,
2523- max : int = 0 ,
2522+ min : float = 0. 0 ,
2523+ max : float = 0. 0 ,
25242524 weight : Tensor | None = None ,
25252525 density : bool = False ,
25262526 name : str | None = None ,
@@ -2533,8 +2533,8 @@ def histogram(
25332533 input (Tensor): A Tensor with shape :math:`[N_1, N_2,..., N_k]` . The data type of the input Tensor
25342534 should be float32, float64, int32, int64.
25352535 bins (int, optional): number of histogram bins. Default: 100.
2536- min (int , optional): lower end of the range (inclusive). Default: 0.
2537- max (int , optional): upper end of the range (inclusive). Default: 0.
2536+ min (float , optional): lower end of the range (inclusive). Default: 0. 0.
2537+ max (float , optional): upper end of the range (inclusive). Default: 0. 0.
25382538 weight (Tensor, optional): If provided, it must have the same shape as input. Each value in input contributes its associated
25392539 weight towards the bin count (instead of 1). Default: None.
25402540 density (bool, optional): If False, the result will contain the count (or total weight) in each bin. If True, the result is the
@@ -2555,6 +2555,11 @@ def histogram(
25552555 Tensor(shape=[4], dtype=int64, place=Place(cpu), stop_gradient=True,
25562556 [0, 2, 1, 0])
25572557 """
2558+ if isinstance (min , int ):
2559+ min = float (min )
2560+ if isinstance (max , int ):
2561+ max = float (max )
2562+
25582563 if in_dynamic_or_pir_mode ():
25592564 return _C_ops .histogram (input , weight , bins , min , max , density )
25602565 else :
@@ -2596,8 +2601,8 @@ def histogram(
25962601def histogram_bin_edges (
25972602 input : Tensor ,
25982603 bins : int = 100 ,
2599- min : int = 0 ,
2600- max : int = 0 ,
2604+ min : float = 0. 0 ,
2605+ max : float = 0. 0 ,
26012606 name : str | None = None ,
26022607) -> Tensor :
26032608 """
@@ -2607,8 +2612,8 @@ def histogram_bin_edges(
26072612 Args:
26082613 input (Tensor): The data type of the input Tensor should be float32, float64, int32, int64.
26092614 bins (int, optional): number of histogram bins.
2610- min (int , optional): lower end of the range (inclusive). Default: 0.
2611- max (int , optional): upper end of the range (inclusive). Default: 0.
2615+ min (float , optional): lower end of the range (inclusive). Default: 0. 0.
2616+ max (float , optional): upper end of the range (inclusive). Default: 0. 0.
26122617 name (str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
26132618
26142619 Returns:
@@ -2625,6 +2630,11 @@ def histogram_bin_edges(
26252630 Tensor(shape=[5], dtype=float32, place=Place(cpu), stop_gradient=True,
26262631 [0. , 0.75000000, 1.50000000, 2.25000000, 3. ])
26272632 """
2633+ if isinstance (min , int ):
2634+ min = float (min )
2635+ if isinstance (max , int ):
2636+ max = float (max )
2637+
26282638 check_type (input , 'input' , (Variable ), 'histogram_bin_edges' )
26292639 check_dtype (
26302640 input .dtype ,
@@ -2633,13 +2643,13 @@ def histogram_bin_edges(
26332643 'histogram_bin_edges' ,
26342644 )
26352645 check_type (bins , 'bins' , int , 'histogram_bin_edges' )
2636- if max == 0 and min == 0 :
2646+ if max == 0.0 and min == 0. 0 :
26372647 min = paddle .min (input )
26382648 max = paddle .max (input )
26392649 else :
26402650 if max < min :
26412651 raise ValueError ("max must be larger than min in range parameter" )
2642- if (min - max ) == 0 :
2652+ if (min - max ) == 0.0 :
26432653 max = max + 0.5
26442654 min = min - 0.5
26452655 return paddle .linspace (min , max , bins + 1 , name = name )
0 commit comments