MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _convert_random_with_param

Function _convert_random_with_param

tensorflow/python/ops/parallel_for/pfor.py:2565–2589  ·  view source on GitHub ↗
(pfor_input)

Source from the content-addressed store, hash-verified

2563@RegisterPFor("RandomGamma")
2564@RegisterPFor("RandomPoissonV2")
2565def _convert_random_with_param(pfor_input):
2566 shape = pfor_input.unstacked_input(0)
2567 # param is lam (Poisson rate) or alpha (Gamma shape).
2568 param, param_stacked, _ = pfor_input.input(1)
2569 logging.warning(
2570 "Note that %s inside pfor op may not give same output as "
2571 "inside a sequential loop.", pfor_input.op_type)
2572
2573 if param_stacked:
2574 samples = _create_op(
2575 pfor_input.op_type,
2576 inputs=[shape, param],
2577 op_dtypes=[x.dtype for x in pfor_input.outputs],
2578 attrs=pfor_input.op.node_def.attr).outputs[0]
2579 loop_dim = array_ops.shape(shape)[0]
2580 stacked_samples = _transpose_dim_to_front(samples, loop_dim)
2581 else:
2582 shape = array_ops.concat([pfor_input.pfor.loop_len_vector, shape], axis=0)
2583 stacked_samples = _create_op(
2584 pfor_input.op_type,
2585 inputs=[shape, param],
2586 op_dtypes=[x.dtype for x in pfor_input.outputs],
2587 attrs=pfor_input.op.node_def.attr).outputs[0]
2588
2589 return wrap(stacked_samples, True)
2590
2591
2592@RegisterPFor("Multinomial")

Callers

nothing calls this directly

Calls 7

_create_opFunction · 0.85
_transpose_dim_to_frontFunction · 0.85
unstacked_inputMethod · 0.80
wrapFunction · 0.70
inputMethod · 0.45
shapeMethod · 0.45
concatMethod · 0.45

Tested by

no test coverage detected