问题描述:

自定义算子内容与bug相关部分(变量seed)内容如下:

# image_ops.py

class SampleDistortedBoundingBox(PrimitiveWithInfer):

'''  '''

    @prim_attr_register

    def __init__(self, seed=0, aspect_ratio_range=[0.75, 1.33], area_range=[0.05, 1.], max_attempts=100, use_image_if_no_bounding_boxes=False):

    

    ''' '''

    validator.check_value_type("seed", seed, [int], self.name)

    self.seed=seed

void SampleDistortedBoundingBoxCPUKernel::InitKernel(const CNodePtr &kernel_node){

/*''' '''*/

//int SampleDistortedBoundingBoxCPUKernel::seed_

//通过std::cout排查bug发生在下面这一句

seed_ = AnfAlgo::GetNodeAttr<int>(kernel_node, "seed");

    /*''' '''*/

}

调用该算子时报错如下:()

 

求问

引起错误: Cast failed, original value: 1, type: Int64Imm的原因可能有哪些?

解答:

Python侧的int在C++侧解析成了int64类型,你改成GetNodeAttr<int64_t>试试。

https://www.mindspore.cn/docs/programming_guide/zh-CN/r1.6/dtype.html?highlight=int64 官网提到int类型。

Logo

昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

更多推荐