Example #1
0
# noinspection PyUnusedLocal
@ChainerConverter.register_handler("Clip")
def _convert_clip(converter: ChainerConverter, c_op: "chainer.functions.Clip"):
    # TODO
    raise NotImplementedError("[ChainerConverter] Clip is not supported")


# noinspection PyUnusedLocal
@ChainerConverter.register_handler("BatchDet")
def _convert_batch_det(converter: ChainerConverter,
                       c_op: "chainer.functions.BatchDet"):
    # TODO
    raise NotImplementedError("[ChainerConverter] BatchDet is not supported")


ChainerConverter.register_handler("Exp")(unary_op_handler(Exp))

ChainerConverter.register_handler("Log")(unary_op_handler(Log))


@ChainerConverter.register_handler("Log10")
def _convert_log10(converter: ChainerConverter,
                   c_op: "chainer.functions.Log10"):
    x = converter.get_variable(c_op.inputs[0])
    y, = Log(None)(x) / np.log(10)
    converter.set_variable(c_op.outputs[0](), y)


@ChainerConverter.register_handler("Log2")
def _convert_log2(converter: ChainerConverter, c_op: "chainer.functions.Log2"):
    x = converter.get_variable(c_op.inputs[0])
Example #2
0
from webdnn.graph.operators.elementwise_pow import ElementwisePow
from webdnn.graph.operators.tensordot import Tensordot
from webdnn.graph.order import Order
from webdnn.graph.variables.constant_variable import ConstantVariable


# noinspection PyUnusedLocal
@ChainerConverter.register_handler("Neg")
def _convert_neg(converter: ChainerConverter,
                 c_op: "chainer.functions.math.basic_math.Neg"):
    x = converter.get_variable(c_op.inputs[0])
    y = -x
    converter.set_variable(c_op.outputs[0](), y)


ChainerConverter.register_handler("Absolute")(unary_op_handler(Abs))

ChainerConverter.register_handler("Add")(
    elementwise_binary_op_handler(ElementwiseAdd))


@ChainerConverter.register_handler("AddConstant")
def _convert_add_constant(
        converter: ChainerConverter,
        c_op: "chainer.functions.math.basic_math.AddConstant"):
    x = converter.get_variable(c_op.inputs[0])
    y = x + c_op.value
    converter.set_variable(c_op.outputs[0](), y)


@ChainerConverter.register_handler("Sub")