Coder Social home page Coder Social logo

Comments (3)

ZhangZhiPku avatar ZhangZhiPku commented on August 29, 2024

听说是numpy新版中移除了这个函数:

numpy.asscalar(a)
将大小为1的数组转换为其标量等效值。

1.16 版后已移除: 弃用,使用 numpy.ndarray.item() 相反。

from ppq.

ZhangZhiPku avatar ZhangZhiPku commented on August 29, 2024

问题将在下一次更新中修复,你可以使用下面的写法替换 util.py

def convert_value(
    value: Union[int, float, np.ndarray, torch.Tensor],
    export_as_float: bool, dtype: DataType = DataType.FP32) -> Union[float, list]:
    """Converting value from any to python native data dtype, ready for export.

    Args:
        value (Union[int, float, np.ndarray, torch.Tensor]): exporting value.
        export_as_list (bool): export value as a list.
        dtype (DataType, optional): exporting dtype.

    Returns:
        Union[float, list]: Converted value
    """
    if dtype not in {DataType.FP32, DataType.INT32}:
        raise ValueError(f'Can Only export dtype fp32 and int32, '
                         f'while you are requiring to dump a {dtype.name} value')
    value = convert_any_to_numpy(value, accepet_none=False)
    value = value.astype(dtype=DataType.to_numpy(dtype))
    if export_as_float:
        value = value[0].item()
        assert type(value) in {int, float}, (
            f'Trying to dump a tensorwise quantization value {value}. '
            f'It is Expected to be a int or float value, while {type(value)} was given')
        return value
    else:
        value = convert_any_to_numpy(value, accepet_none=False)
        return value.tolist()

from ppq.

ZhangZhiPku avatar ZhangZhiPku commented on August 29, 2024

问题已经在0.6.5的更新中修复

from ppq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.