Source code for webdnn.graph.operators.tan

import numpy as np

from webdnn.graph.graph import Graph
from webdnn.graph.operators.elementwise import Elementwise
from webdnn.graph.optimize_rule import OptimizeRule
from webdnn.graph.variables.constant_variable import ConstantVariable


[docs]class Tan(Elementwise): """Tan(name) Elementwise tan operator. Args: name (str): Operator name. Signature .. code:: y, = op(x0) - **x0** - Input variable. - **y** - Output variable. """ def fold_constance(self, graph: Graph): x0 = self.inputs["x0"] # type: ConstantVariable y = self.outputs["y"] self.remove_all() y_new = ConstantVariable(x0.data, x0.order).change_order(y.order) y_new.data = np.tan(y_new.data) OptimizeRule.replace_variable(graph, y, y_new)